/* ── Variables ─────────────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:      #C8102E;
  --primary-dark: #8C0D20;
  --primary-light:#E52535;
  --primary-subtle:#FFF0F2;
  --primary-50:   #FFE8EB;

  /* Semantic */
  --success:      #16A34A;
  --success-light:#F0FFF4;
  --success-dark: #15803D;
  --warning:      #D97706;
  --warning-light:#FFFBEB;
  --warning-dark: #B45309;
  --error:        #DC2626;
  --error-light:  #FEF2F2;
  --error-dark:   #B91C1C;
  --info:         #2563EB;
  --info-light:   #EFF6FF;
  --info-dark:    #1D4ED8;

  /* Gray scale */
  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Legacy aliases remapped to A4 tokens 2026-04-17.
     Prior to this, --navy and --accent both pointed at --primary (red),
     and --border was pinkish #F0D6D9. Every inline-styled element in the
     app inherited that "everything pink/red" palette and fought the new
     A4 sans-workspace aesthetic. Remapping the aliases to real navy +
     cool gray cascades through hundreds of inline styles at once, no
     per-surface rewrite needed. --accent stays red so explicit CTAs
     (primary buttons, link accents) keep brand emphasis. */
  --navy:       #0F1C3A;
  --navy-dk:    #0A1428;
  --navy-lt:    #1E3A68;
  --gold:       #B8860B;
  --gold-lt:    #E9C763;
  --accent:     var(--primary);

  /* Surfaces — A4 cool off-white + blue-gray borders */
  --bg:         #FAFCFE;
  --card:       #FFFFFF;
  --text:       #1A2540;
  --muted:      #5A6A85;
  --border:     #D6DEEB;

  /* Layout */
  --sidebar-w:  240px;
  --header-h:   60px;
  --radius:     12px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.12);
  --shadow-xl:  0 24px 60px rgba(0,0,0,0.2);

  /* Spacing (4px base) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ── A4 direction tokens (sans workspace + mono briefing) ──
     Used by the Phase-1+ shell rewrite. Kept as a separate namespace
     from the legacy aliases above so migration is additive, not a
     big-bang swap. Paired with BB.ws* helpers inside the JS BB library. */
  --a4-bg:          #FAFCFE;
  --a4-surface:     #FFFFFF;
  --a4-panel:       #F4F7FC;
  --a4-border:      #D6DEEB;
  --a4-row-div:     #EAEFF7;
  --a4-ink:         #1A2540;
  --a4-navy:        #0F1C3A;
  --a4-muted:       #5A6A85;
  --a4-faint:       #6B7A95;
  --a4-red:         #C8102E;
  --a4-good:        #0EA5A0;
  --a4-good-soft:   #E6FAF8;
  --a4-warn:        #D97706;
  --a4-warn-soft:   #FFFBEB;
  --a4-blue-hi:     #2563EB;
  --a4-blue-chip:   #EFF4FF;

  --a4-radius-sm:   6px;
  --a4-radius-md:   10px;
  --a4-radius-lg:   12px;
  --a4-radius-xl:   14px;

  --a4-shadow-hover: 0 2px 8px rgba(15,28,58,0.06);
  --a4-shadow-card:  0 1px 2px rgba(15,28,58,0.04);

  --a4-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --a4-mono:  'IBM Plex Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--a4-sans);
       background: var(--a4-bg); color: var(--a4-ink); font-size: 15px; line-height: 1.5;
       --focus-ring: var(--primary); }

/* ── Custom Scrollbars ──────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.15) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }
.sidebar { scrollbar-color: rgba(255,255,255,0.15) transparent; }
.sidebar ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
.sidebar ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ── Focus Rings ───────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth Screen ────────────────────────────────────────────────── */
@keyframes authGradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes authFadeUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes authPulseGlow {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 0.6; }
}
@keyframes authFloatOrb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(30px, -20px) scale(1.05); }
  66%      { transform: translate(-15px, 15px) scale(0.97); }
}
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%      { transform: translateY(-8px); }
}
@keyframes countUp {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

#authScreen {
  display: flex; align-items: stretch;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999; background: #0A0A0A;
}

.auth-hero {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 32px clamp(24px, 4vw, 52px);
  background: linear-gradient(135deg, #0D0008, #1A0008, #2A0011, #3A0011, #C8102E, #8C0D20, #2A000D);
  background-size: 500% 500%;
  animation: authGradientShift 16s ease infinite;
  color: #fff; position: relative; overflow: hidden;
}
.auth-hero-grid {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 50px 50px;
}
.auth-hero-orb { position: absolute; border-radius: 50%; pointer-events: none; filter: blur(80px); z-index: 0; }
.auth-hero-orb--1 { width: 500px; height: 500px; top: -15%; right: -10%; background: radial-gradient(circle, rgba(255,107,122,0.2), transparent 70%); animation: authFloatOrb 10s ease-in-out infinite; }
.auth-hero-orb--2 { width: 400px; height: 400px; bottom: -10%; left: -10%; background: radial-gradient(circle, rgba(200,16,46,0.25), transparent 70%); animation: authFloatOrb 12s ease-in-out infinite reverse; }
.auth-hero-orb--3 { width: 250px; height: 250px; top: 35%; left: 45%; background: radial-gradient(circle, rgba(255,255,255,0.06), transparent 70%); animation: authPulseGlow 7s ease-in-out infinite; }

.auth-hero-top { position: relative; z-index: 1; margin-bottom: 24px; flex-shrink: 0; }
.auth-hero-brand {
  font-size: clamp(24px, 3.5vw, 38px); font-weight: 800; letter-spacing: -1px; margin-bottom: 6px;
  animation: authFadeUp 0.8s ease both; white-space: nowrap;
}
.auth-hero-brand span {
  background: linear-gradient(135deg, #FFB3BB, #FF6B7A);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.auth-hero-headline {
  font-size: 17px; font-weight: 300; opacity: 0.7; line-height: 1.6;
  animation: authFadeUp 0.8s ease 0.1s both;
}

/* Mock Dashboard Preview */
.auth-mock-container { position: relative; z-index: 1; animation: authFadeUp 0.9s ease 0.2s both; margin-bottom: 20px; flex-shrink: 1; min-height: 0; overflow: hidden; }
.auth-mock-window { background: #111; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px rgba(200,16,46,0.08); animation: float 6s ease-in-out infinite; }
.auth-mock-titlebar { background: #1A1A1A; padding: 10px 14px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.auth-mock-dot { width: 10px; height: 10px; border-radius: 50%; }
.auth-mock-dot:nth-child(1) { background: #FF5F56; }
.auth-mock-dot:nth-child(2) { background: #FFBD2E; }
.auth-mock-dot:nth-child(3) { background: #27C93F; }
.auth-mock-url { margin-left: 12px; background: rgba(255,255,255,0.06); border-radius: 6px; padding: 4px 12px; font-size: 11px; color: rgba(255,255,255,0.4); flex: 1; max-width: 240px; }
.auth-mock-body { display: flex; min-height: 200px; }
.auth-mock-sidebar { width: 52px; background: #C8102E; padding: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.auth-mock-sidebar-logo { width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; color: #fff; margin-bottom: 6px; }
.auth-mock-sidebar-item { width: 28px; height: 28px; border-radius: 6px; background: rgba(255,255,255,0.08); }
.auth-mock-sidebar-item.active { background: rgba(255,255,255,0.25); }
.auth-mock-main { flex: 1; padding: 16px; background: #0F0F0F; }
.auth-mock-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.auth-mock-title { font-size: 14px; font-weight: 700; color: #fff; }
.auth-mock-search { width: 120px; height: 24px; border-radius: 6px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); }
.auth-mock-stats { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-mock-stat { flex: 1; background: rgba(255,255,255,0.04); border-radius: 8px; padding: 10px; border: 1px solid rgba(255,255,255,0.06); }
.auth-mock-stat-label { font-size: 8px; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.auth-mock-stat-value { font-size: 18px; font-weight: 800; color: #fff; animation: countUp 0.6s ease 1.2s both; }
.auth-mock-stat-value.red { color: #FF6B7A; }
.auth-mock-stat-value.green { color: #48BB78; }
.auth-mock-stat-change { font-size: 8px; color: #48BB78; margin-top: 2px; }
.auth-mock-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.auth-mock-row:nth-child(1) { animation: slideInRight 0.5s ease 1.4s both; }
.auth-mock-row:nth-child(2) { animation: slideInRight 0.5s ease 1.6s both; }
.auth-mock-row:nth-child(3) { animation: slideInRight 0.5s ease 1.8s both; }
.auth-mock-avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, #C8102E, #FF6B7A); flex-shrink: 0; }
.auth-mock-row-name { font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.85); }
.auth-mock-row-sub { font-size: 9px; color: rgba(255,255,255,0.35); }
.auth-mock-tag { font-size: 8px; padding: 3px 8px; border-radius: 10px; font-weight: 600; }
.auth-mock-tag.hot { background: rgba(200,16,46,0.15); color: #FF6B7A; }
.auth-mock-tag.warm { background: rgba(255,189,46,0.12); color: #FFBD2E; }
.auth-mock-tag.new { background: rgba(72,187,120,0.12); color: #48BB78; }
.auth-mock-score { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.5); width: 28px; text-align: right; }

/* Feature pills */
.auth-feature-pills { display: flex; flex-wrap: wrap; gap: 8px; position: relative; z-index: 1; animation: authFadeUp 0.8s ease 0.5s both; margin-bottom: 16px; flex-shrink: 0; }
.auth-feature-pill { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 13px; color: rgba(255,255,255,0.85); transition: all 0.3s; }
.auth-feature-pill:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.18); transform: translateY(-2px); }
.auth-pill-icon { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, rgba(255,107,122,0.2), rgba(200,16,46,0.15)); border: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center; font-size: 14px; }
.auth-pill-text { font-weight: 600; font-size: 12px; }

.auth-hero-footer {
  position: relative; z-index: 1; padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 11px; opacity: 0.3; letter-spacing: 0.5px;
  animation: authFadeUp 0.7s ease 0.6s both;
}

/* Right login panel */
.auth-panel {
  width: 460px; flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; padding: 48px;
  background: #fff; position: relative;
}
.auth-panel::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px;
  background: linear-gradient(90deg, #C8102E, #FF6B7A, transparent);
}
.auth-card {
  width: 100%; max-width: 340px; text-align: left;
  animation: authFadeUp 0.6s ease 0.2s both;
}
.auth-card-icon {
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: #fff;
  margin-bottom: 28px; box-shadow: 0 4px 20px rgba(200,16,46,0.3);
}
.auth-card-welcome {
  font-size: 28px; font-weight: 800; color: #1A202C;
  margin-bottom: 6px; letter-spacing: -0.5px;
}
.auth-card-sub {
  font-size: 14px; color: #718096; margin-bottom: 36px;
}
.auth-logo { display: none; }
.auth-tagline { display: none; }
.auth-label {
  display: block; text-align: left; font-size: 11px; font-weight: 700;
  color: #4A5568; margin-bottom: 6px; margin-top: 24px;
  text-transform: uppercase; letter-spacing: 0.8px;
}
.auth-label:first-of-type { margin-top: 0; }
.auth-input {
  width: 100%; padding: 13px 16px; border: 2px solid #E2E8F0; border-radius: 10px;
  font-size: 15px; transition: all .25s ease; outline: none;
  background: #F7FAFC;
}
.auth-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(200,16,46,0.08), 0 2px 8px rgba(200,16,46,0.1);
  background: #fff;
}
.auth-btn {
  width: 100%; margin-top: 28px; padding: 15px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border-radius: 10px; font-size: 16px; font-weight: 700;
  transition: all .25s ease; letter-spacing: .3px;
  box-shadow: 0 4px 16px rgba(200,16,46,0.3);
  position: relative; overflow: hidden;
}
.auth-btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.15) 50%, transparent 60%);
  background-size: 250% 100%;
  background-position: 100% 0;
  transition: background-position 0.5s ease;
}
.auth-btn:hover {
  background: linear-gradient(135deg, var(--primary-dark), #6B0A18);
  box-shadow: 0 8px 28px rgba(200,16,46,0.4);
  transform: translateY(-2px);
}
.auth-btn:hover::after { background-position: 0 0; }
.auth-btn:active { transform: translateY(0); }
.auth-error { color: #E53E3E; font-size: 13px; margin-top: 12px; min-height: 18px; }

/* Testimonial on login panel */
.auth-testimonial { margin-top: 40px; padding-top: 24px; border-top: 1px solid #EDF2F7; animation: authFadeUp 0.7s ease 0.6s both; }
.auth-testimonial-quote { font-size: 13px; color: #718096; line-height: 1.7; font-style: italic; margin-bottom: 12px; }
.auth-testimonial-author { display: flex; align-items: center; gap: 10px; }
.auth-testimonial-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #C8102E, #FF6B7A); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; }
.auth-testimonial-name { font-size: 12px; font-weight: 700; color: #2D3748; }
.auth-testimonial-role { font-size: 11px; color: #A0AEC0; }

.auth-mobile-brand { display: none; }

/* ── App Shell ──────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar (A4 — sans sentence-case, warmer navy, soft active) ── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0F1C3A 0%, #0B1629 100%);
  display: flex; flex-direction: column;
  flex-shrink: 0; overflow: hidden; height: 100vh;
  font-family: var(--a4-sans);
  border-right: 1px solid rgba(255,255,255,0.04);
}
.sidebar-logo {
  padding: 22px 24px 20px; font-size: 20px; font-weight: 700;
  color: white; letter-spacing: -0.4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 2px;
}
/* The leading "A" in AdvisorProspect — subtle red accent, not gold. */
.sidebar-logo span { color: var(--a4-red); font-weight: 800; }
/* Second span override — the A4 logo has "Prospect" in white; overrule inline. */
.sidebar-logo span[style*="white"] { color: white !important; font-weight: 700 !important; }
.sidebar-subtitle { font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.4);
                    font-style: italic; margin-top: 2px; }
.nav-section { padding: 14px 10px 8px; flex: 1; overflow-y: auto; min-height: 0; }
/* Bottom-fade hint — visible only when nav overflows AND user isn't already
   at the bottom of the scroll. Communicates "more below" without adding
   any visual chrome. Class toggled by setupSidebarFade() on load + scroll
   + viewport resize. */
.nav-section.has-overflow {
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 28px), transparent);
          mask-image: linear-gradient(to bottom, black calc(100% - 28px), transparent);
}
.nav-label { font-size: 11.5px; font-weight: 500; font-style: italic;
             color: rgba(255,255,255,0.42);
             padding: 16px 16px 8px; letter-spacing: 0;
             border-top: none; margin-top: 6px; text-transform: none; }
/* First nav-label (right after brand) shouldn't have extra top margin */
.nav-section > .nav-label:first-child { margin-top: 0; padding-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 16px 10px 13px;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  color: rgba(255,255,255,0.78); font-weight: 500; font-size: 14px;
  letter-spacing: -0.1px;
  transition: all .12s; text-align: left; margin-bottom: 1px;
  font-family: var(--a4-sans);
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: white; }
.nav-item.active {
  background: rgba(200,16,46,0.08);
  border-left-color: var(--a4-red);
  color: white; font-weight: 600;
}
/* Softer focus ring on nav-items — the red rectangular outline from the
   global :focus-visible rule looked jarring against the navy sidebar
   since .active already shows a strong red left-stripe + bg wash.
   Keyboard-focus accessibility preserved via a subtle inset white ring. */
.nav-item:focus-visible { outline: 2px solid rgba(255,255,255,0.3); outline-offset: -2px; }
.nav-item.active::before { content: none; } /* replaced by border-left */
.nav-item.locked { opacity: 0.45; cursor: not-allowed; }
.nav-item .nav-icon { font-size: 16px; flex-shrink: 0; opacity: 0.75; }
.nav-icon-svg { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 1.75; opacity: 0.75; }
.nav-item.active .nav-icon-svg { opacity: 1; }
.mobile-nav-icon { width: 22px; height: 22px; stroke-width: 1.75; }
.more-menu-icon { width: 20px; height: 20px; flex-shrink: 0; stroke-width: 1.75; }
.nav-badge {
  margin-left: auto; background: rgba(255,255,255,0.12); color: white;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  letter-spacing: 0; font-family: var(--a4-sans);
}
.nav-item.active .nav-badge { background: var(--a4-red); }

/* Sidebar footer — avatar + name + role + policy links + change pw + sign out */
.sidebar-footer { padding: 16px 20px 18px; border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0;
                  font-family: var(--a4-sans); }
.sidebar-user { font-size: 13px; color: rgba(255,255,255,0.85); margin-bottom: 10px;
                font-weight: 500; letter-spacing: -0.2px; }
.logout-btn {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.72);
  font-size: 12.5px; font-weight: 500; transition: all .12s;
  font-family: var(--a4-sans); letter-spacing: -0.1px;
}
.logout-btn:hover { background: rgba(255,255,255,0.12); color: white; }

/* ── Global Search (lives in topbar under A4) ──────────────────── */
.global-search {
  padding: 8px 14px; background: var(--a4-panel);
  border: 1px solid var(--a4-border); border-radius: 8px;
  color: var(--a4-ink); font-size: 13px; font-family: var(--a4-sans);
  width: 320px; max-width: 100%; transition: all .12s;
}
.global-search::placeholder { color: var(--a4-muted); font-family: var(--a4-sans); }
.global-search:focus { outline: none; border-color: var(--a4-blue-hi); background: #FFFFFF;
                       box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
.search-results {
  position: absolute; top: 48px; right: 28px; width: 400px;
  background: white; border: 1px solid var(--a4-border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(15,28,58,0.12);
  max-height: 340px; overflow-y: auto; z-index: 100;
}
.search-result-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--a4-row-div);
                      font-size: 13px; color: var(--a4-ink); font-family: var(--a4-sans); }
.search-result-item:hover { background: var(--a4-panel); }
.search-result-item-title { font-weight: 600; }
.search-result-item-subtitle { font-size: 11.5px; color: var(--a4-muted); margin-top: 2px; }

/* ── Activity Timeline ──────────────────────────────────────────────── */
.activity-timeline { border-left: 2px solid var(--border); padding-left: 20px; position: relative; }
.activity-item { margin-bottom: 16px; position: relative; }
.activity-dot { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); left: -29px; top: 2px; }
.activity-time { font-size: 11px; color: var(--muted); font-weight: 500; }
.activity-action { font-size: 13px; font-weight: 600; color: var(--text); margin-top: 2px; }
.activity-details { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Main Content ───────────────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; background: var(--a4-bg); }
/* Topbar — sentence-case sans breadcrumb + search + clock + user chip.
   Same .page-header class as before (JS refs it) — just restyled. */
.page-header {
  background: #FFFFFF; padding: 14px 32px;
  border-bottom: 1px solid var(--a4-border);
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 10;
  font-family: var(--a4-sans);
}
.page-header h1 {
  font-size: 15px; font-weight: 600; flex: 1;
  color: var(--a4-ink); letter-spacing: -0.2px;
}
.page-header .topbar-right { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.page-header .topbar-clock {
  font-family: var(--a4-sans); font-size: 12.5px; color: var(--a4-muted);
}
.page-header .topbar-clock .live-dot { color: var(--a4-red); font-weight: 600; }
.page-header .topbar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px;
  background: var(--a4-panel); border: 1px solid var(--a4-border);
  border-radius: 20px; font-size: 13px; color: var(--a4-ink); font-weight: 500;
}
.page-header .topbar-user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #C8102E, #F43F5E);
  color: white; display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}
.back-btn {
  padding: 7px 12px; border-radius: 8px;
  background: var(--a4-panel); color: var(--a4-ink);
  font-size: 13.5px; font-weight: 500; font-family: var(--a4-sans);
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--a4-border);
}
.back-btn:hover { background: var(--a4-border); }
.refresh-btn {
  padding: 7px 12px; border-radius: 8px;
  background: var(--a4-panel); color: var(--a4-ink);
  font-size: 13.5px; font-weight: 500; font-family: var(--a4-sans);
  border: 1px solid var(--a4-border);
}
#content { padding: 32px; flex: 1; overflow-x: hidden; font-family: var(--a4-sans); color: var(--a4-ink); }

/* ── Stats Cards ────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: white; border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow-md); border: 1px solid var(--border);
}
.stat-value { font-size: 32px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 6px; font-weight: 500; }
.stat-icon { font-size: 22px; margin-bottom: 10px; }

/* ── Dashboard Welcome ──────────────────────────────────────────── */
.welcome-card {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  border-radius: var(--radius); padding: 28px 32px; color: white; margin-bottom: 24px;
  box-shadow: 0 4px 16px rgba(200,16,46,0.3);
}
.welcome-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.welcome-card p { color: rgba(255,255,255,0.75); font-size: 14px; max-width: 500px; }

/* ── Section Cards ──────────────────────────────────────────────── */
.section-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.section-card {
  background: white; border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow-md); cursor: pointer; transition: all .2s;
  border: 1px solid var(--border);
}
.section-card:hover { border-color: var(--navy); transform: translateY(-2px);
                       box-shadow: var(--shadow-lg); }
.section-card.locked { opacity: 0.6; cursor: not-allowed; }
.section-card.locked:hover { transform: none; border-color: transparent; }
.section-card-icon { font-size: 36px; margin-bottom: 12px; }
.section-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.section-card p { font-size: 13px; color: var(--muted); }
.section-tag {
  display: inline-block; margin-top: 12px; padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 700; background: var(--primary-50); color: var(--primary);
}
.section-tag.soon { background: #FFF3CD; color: #856404; }

/* ── Search / Filter Bar ────────────────────────────────────────── */
.search-bar {
  display: flex; gap: 12px; margin-bottom: 20px;
}
.search-input {
  flex: 1; padding: 11px 16px; border: 2px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; background: white; transition: border-color .2s;
}
.search-input:focus { border-color: var(--navy); }
.filter-select {
  padding: 11px 14px; border: 2px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; background: white; cursor: pointer;
}
.refresh-btn {
  padding: 11px 16px; border-radius: 10px; background: white; border: 2px solid var(--border);
  font-size: 14px; font-weight: 600; color: var(--navy); display: flex; align-items: center; gap: 6px;
  transition: all .15s;
}
.refresh-btn:hover { border-color: var(--navy); background: #EBF4FF; }

/* ── County Grid (A4 — rounded, roomy, subtle hover lift) ──────── */
.county-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.county-card {
  background: var(--a4-surface); border-radius: var(--a4-radius-lg);
  padding: 18px 20px; cursor: pointer;
  transition: all .15s;
  border: 1px solid var(--a4-border);
  display: flex; align-items: center; gap: 14px;
  font-family: var(--a4-sans);
}
.county-card:hover {
  border-color: var(--a4-navy);
  box-shadow: var(--a4-shadow-hover);
  transform: translateY(-1px);
}
.county-icon { font-size: 22px; flex-shrink: 0; opacity: 0.9; }
.county-name { font-weight: 600; font-size: 14.5px; color: var(--a4-navy); letter-spacing: -0.2px; }
.county-meta { font-size: 12px; color: var(--a4-muted); margin-top: 3px; font-weight: 400; }
.county-card.loaded {
  border-color: rgba(14,165,160,0.25);
  background: var(--a4-good-soft);
}

/* ── Church / Biz / NP / Retiree / Signal / PP / Ref List ────────
   (Shared .church-card class used by all 8 county list renderers.) */
.church-list { display: flex; flex-direction: column; gap: 12px; }
.church-card {
  background: var(--a4-surface); border-radius: var(--a4-radius-lg);
  padding: 20px 22px; cursor: pointer; transition: all .15s;
  border: 1px solid var(--a4-border);
  display: flex; align-items: center; gap: 18px;
  font-family: var(--a4-sans);
}
.church-card:hover {
  border-color: var(--a4-navy);
  box-shadow: var(--a4-shadow-hover);
  transform: translateY(-1px);
}
.church-card-body { flex: 1; min-width: 0; }
.church-card-name {
  font-size: 16px; font-weight: 600;
  color: var(--a4-navy); margin-bottom: 4px;
  letter-spacing: -0.2px;
}
.church-card-address { font-size: 13.5px; color: var(--a4-muted); white-space: nowrap;
                       overflow: hidden; text-overflow: ellipsis; }
.church-card-meta { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.church-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.remove-card-btn {
  width: 26px; height: 26px; border-radius: 50%; background: none; color: var(--muted);
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: all .15s; border: 1px solid transparent; cursor: pointer;
}
.remove-card-btn:hover { background: #FEE2E2; color: #E53E3E; border-color: #FCA5A5; }

/* ── Retiree prospect cards ───────────────────────────────────── */
.ret-score {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.ret-score-high { background: #D8F3DC; color: #2D6A4F; }
.ret-score-med  { background: #FEF3C7; color: #92400E; }
.ret-score-low  { background: #FEE2E2; color: #991B1B; }
.ret-meta-pill {
  display: inline-flex; align-items: center; font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 500;
}
.ret-pill-role { background: #F0EBE3; color: #5A554E; }
.ret-pill-employer { background: #E8F0FE; color: #1A56DB; }
.ret-pill-source { background: #FEF9EC; color: #B5620A; }
.ret-pill-date { background: #F0F0F0; color: #718096; }
.ret-snippet {
  font-size: 13px; color: #5A554E; line-height: 1.6; margin: 8px 0;
  border-left: 2px solid var(--navy); padding-left: 10px; font-style: italic;
}
.ret-signal {
  display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 3px;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: rgba(200,16,46,0.08); color: var(--navy); border: 1px solid rgba(200,16,46,0.2);
}
.ret-source-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--navy); padding: 5px 12px;
  border: 1px solid var(--navy); border-radius: 6px; text-decoration: none; transition: all .15s;
}
.ret-source-link:hover { background: var(--navy); color: white; text-decoration: none; }

.notes-pill {
  display: flex; align-items: center; gap: 4px; background: var(--primary-50); color: var(--primary);
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px;
}
.rating-pill {
  display: flex; align-items: center; gap: 4px; background: #FFFBEB; color: #92400E;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
}
.no-results { text-align: center; padding: 60px 20px; color: var(--muted); }
.no-results-icon { font-size: 48px; margin-bottom: 16px; }
.no-results h3 { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 8px; }

/* ── Church Detail ──────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-full { grid-column: 1 / -1; }
.detail-card {
  background: white; border-radius: var(--radius); padding: 22px 24px;
  box-shadow: var(--shadow-md); border: 1px solid var(--border);
}
.detail-card h3 {
  font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 1px;
  text-transform: uppercase; margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.detail-row { display: flex; gap: 12px; margin-bottom: 12px; align-items: flex-start; }
.detail-row:last-child { margin-bottom: 0; }
.detail-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.detail-value { font-size: 14px; color: var(--text); }
.detail-value a { color: var(--navy-lt); font-weight: 500; }
.detail-header-card {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  border-radius: var(--radius); padding: 24px 28px; color: white;
  box-shadow: 0 4px 16px rgba(200,16,46,0.3); margin-bottom: 20px;
  display: flex; align-items: flex-start; gap: 20px;
}
.detail-header-body { flex: 1; }
.detail-title { font-size: 26px; font-weight: 800; margin-bottom: 6px; line-height: 1.2; }
.detail-address { color: rgba(255,255,255,0.75); font-size: 14px; margin-bottom: 14px; }
.status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status-select {
  padding: 7px 14px; border-radius: 99px; border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15); color: white; font-size: 13px; font-weight: 700;
  cursor: pointer; outline: none; -webkit-appearance: none;
}
.status-select option { background: var(--navy); }
.status-label { font-size: 12px; color: rgba(255,255,255,0.6); }

/* ── Talking Points ─────────────────────────────────────────────── */
.tp-section { margin-bottom: 20px; }
.tp-section:last-child { margin-bottom: 0; }
.tp-stage {
  font-size: 12px; font-weight: 800; color: var(--gold); letter-spacing: 1px;
  text-transform: uppercase; margin-bottom: 8px;
}
.tp-text {
  background: #FFF5F6; border-left: 3px solid #C8102E; border-radius: 0 8px 8px 0;
  padding: 14px 16px; font-size: 14px; line-height: 1.7; color: var(--text);
  font-style: italic;
}
.tp-note { font-size: 12px; color: var(--muted); margin-top: 6px; font-style: normal; }

/* ── CRM Notes ──────────────────────────────────────────────────── */
.add-note-btn {
  width: 100%; padding: 12px; border-radius: 10px; background: var(--navy);
  color: white; font-size: 14px; font-weight: 700; margin-bottom: 16px;
  transition: background .2s; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.add-note-btn:hover { background: var(--navy-dk); }
.note-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 10px;
  position: relative;
}
.note-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.note-type {
  padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 700;
  background: #FFE8EB; color: #C8102E;
}
.note-date { font-size: 12px; color: var(--muted); }
.note-text { font-size: 14px; color: var(--text); margin-bottom: 8px; line-height: 1.6; }
.note-next { font-size: 13px; color: var(--navy-lt); font-weight: 500; }
.note-next::before { content: "→ "; }
.note-delete {
  position: absolute; top: 12px; right: 12px; width: 24px; height: 24px; border-radius: 50%;
  background: none; color: #CBD5E0; font-size: 14px; display: flex; align-items: center;
  justify-content: center; transition: all .15s;
}
.note-delete:hover { background: #FED7D7; color: #C53030; }
.no-notes { text-align: center; padding: 24px; color: var(--muted); font-size: 14px; }

/* ── Events / Links ─────────────────────────────────────────────── */
.event-links { display: flex; flex-direction: column; gap: 10px; }
.event-link-btn {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 10px;
  border: 2px solid var(--border); background: white; color: var(--text); font-size: 14px;
  font-weight: 500; transition: all .15s; text-align: left;
}
.event-link-btn:hover { border-color: var(--navy); background: #F0F4FF; color: var(--navy); }
.event-link-icon { font-size: 20px; }
.event-link-body { flex: 1; }
.event-link-title { font-weight: 700; font-size: 14px; }
.event-link-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Reviews ────────────────────────────────────────────────────── */
.review-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.review-item:last-child { border-bottom: none; }
.review-author { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.review-stars { color: #F6AD55; font-size: 12px; margin-bottom: 4px; }
.review-text { font-size: 13px; color: var(--muted); line-height: 1.5;
               overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 4px 12px; border-radius: 99px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
}
.badge-not-contacted { background: #EDF2F7; color: #4A5568; }
.badge-contacted     { background: var(--primary-50); color: var(--primary); }
.badge-meeting       { background: #FAF5FF; color: #6B46C1; }
.badge-proposal      { background: #FFFAF0; color: #C05621; }
.badge-member        { background: #F0FFF4; color: #276749; }
.badge-not-interested{ background: #FFF5F5; color: #C53030; }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: white; border-radius: 16px; padding: 28px; width: 100%;
  max-width: 500px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
}
.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 11px 14px; border: 2px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; transition: border-color .2s;
}
.form-input:focus { border-color: var(--navy); }
textarea.form-input { resize: vertical; min-height: 80px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-primary {
  flex: 1; padding: 12px; background: var(--navy); color: white; border-radius: 10px;
  font-size: 15px; font-weight: 700; transition: background .2s;
}
.btn-primary:hover { background: var(--navy-dk); }
.btn-secondary {
  padding: 12px 20px; background: var(--bg); color: var(--text); border-radius: 10px;
  font-size: 15px; font-weight: 600; transition: background .2s;
}
.btn-secondary:hover { background: var(--border); }

/* ── Loading ────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,0.85); z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.spinner {
  width: 44px; height: 44px; border: 4px solid var(--border);
  border-top-color: var(--navy); border-radius: 50%; animation: spin 0.8s linear infinite;
}
.loading-text { font-size: 15px; font-weight: 600; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1A202C; color: white; padding: 12px 24px; border-radius: 99px;
  font-size: 14px; font-weight: 600; z-index: 2000; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: fadeInUp .2s ease;
}
@keyframes fadeInUp { from { opacity: 0; transform: translateX(-50%) translateY(10px); }
                      to   { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── Utilities ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { background: #EDF2F7; color: #4A5568; font-size: 12px; font-weight: 600;
       padding: 3px 10px; border-radius: 99px; }
.hours-list { list-style: none; }
.hours-list li { font-size: 13px; color: var(--muted); padding: 3px 0; }
.hours-list li strong { color: var(--text); }

/* ── Mobile ─────────────────────────────────────────────────────── */
/* Hide mobile elements on desktop */
.mobile-bottom-nav { display: none; }
.more-menu-overlay { display: none; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: auto; flex-direction: row; z-index: 100;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  .sidebar-logo, .sidebar-footer, .nav-label, .sidebar-user, .global-search, .search-results { display: none !important; }
  .nav-section {
    display: none; /* Hide desktop nav on mobile */
  }
  .mobile-bottom-nav {
    display: flex; align-items: center; justify-content: space-around;
    padding: 8px 0 calc(12px + env(safe-area-inset-bottom, 8px)); width: 100%;
    background: var(--navy);
  }
  .mobile-nav-btn {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: none; border: none; color: rgba(255,255,255,0.6);
    font-size: 9px; padding: 4px 8px; cursor: pointer; min-width: 56px;
    font-family: inherit;
  }
  .mobile-nav-btn .nav-icon { font-size: 22px; }
  .mobile-nav-btn.active { color: white; }
  .mobile-nav-btn:active { transform: scale(0.92); }

  /* More slide-up menu */
  .more-menu-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 200; opacity: 0; transition: opacity 0.25s ease;
  }
  .more-menu-overlay.open { display: block; opacity: 1; }
  .more-menu {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--navy); border-radius: 16px 16px 0 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 12px));
    z-index: 201; transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    touch-action: none;
  }
  .more-menu-overlay.open .more-menu { transform: translateY(0); }
  .more-menu-handle { width: 36px; height: 4px; background: rgba(255,255,255,0.3); border-radius: 2px; margin: 0 auto 12px; cursor: grab; }
  .more-menu-item {
    display: flex; align-items: center; gap: 12px; padding: 14px 12px;
    color: rgba(255,255,255,0.85); font-size: 15px; border: none;
    background: none; width: 100%; cursor: pointer; border-radius: 8px;
    font-family: inherit;
  }
  .more-menu-item:active { background: rgba(255,255,255,0.1); }
  .more-menu-item .nav-icon { font-size: 20px; width: 28px; text-align: center; }
  .more-menu-item.active { color: white; background: rgba(255,255,255,0.08); }

  .nav-badge { display: none; }
  #app { flex-direction: column; overflow-x: hidden; overflow-y: hidden; height: 100vh; }
  .main { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); width: 100%; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #content { padding: 12px; }
  .page-header { padding: 12px 14px; }
  .page-header h1 { font-size: 17px; }

  /* PWA standalone mode — pad top for status bar / notch */
  @media (display-mode: standalone) {
    .main { padding-top: env(safe-area-inset-top, 20px); }
    #content { padding-top: calc(12px + env(safe-area-inset-top, 20px)) !important; }
    .page-header { padding-top: calc(12px + env(safe-area-inset-top, 20px)) !important; }
  }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 12px; }
  .stat-icon { font-size: 18px; margin-bottom: 6px; }

  /* Dashboard */
  .welcome-card { padding: 20px; margin-bottom: 16px; }
  .welcome-card h2 { font-size: 18px; }
  .welcome-card p { font-size: 13px; }
  .dash-two-col { grid-template-columns: 1fr !important; }
  .dash-stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
  /* County map + list mobile sizing */
  #churchMapContainer, #bizMapContainer, #npMapContainer, #refMapContainer { min-height: 220px !important; }
  #countyGrid, #bizCountyGrid, #npCountyGrid, #refCountyGrid { max-height: 300px !important; }
  .section-cards { grid-template-columns: 1fr; gap: 10px; }
  .section-card { padding: 18px; }
  .section-card-icon { font-size: 28px; margin-bottom: 8px; }
  .section-card h3 { font-size: 16px; }

  /* Search & Filter */
  .search-bar { flex-wrap: wrap; gap: 8px; }
  .search-input { width: 100%; min-width: 0; }
  .filter-select { flex: 1; min-width: 0; font-size: 13px; padding: 10px 12px; }
  .refresh-btn { padding: 10px 12px; font-size: 13px; }

  /* County Grid */
  .county-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* Church Cards */
  .church-card { padding: 14px; gap: 10px; flex-wrap: wrap; }
  .church-card-name { font-size: 14px; }
  .church-card-address { font-size: 12px; white-space: normal; }
  .church-card-meta { gap: 6px; }
  .church-card-right { flex-direction: row; align-items: center; width: 100%; justify-content: flex-end; }

  /* Detail Views */
  .detail-grid { grid-template-columns: 1fr; gap: 10px; }
  .detail-title { font-size: 18px; }

  /* Settings */
  .settings-card { padding: 16px !important; }
  .settings-card h2 { font-size: 17px; }

  /* Admin Panel */
  .admin-card { padding: 16px !important; }
  .admin-card h2 { font-size: 17px; }
  .admin-card table, .settings-card table { font-size: 12px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-card table thead, .settings-card table thead { display: none; }
  .admin-card table tbody, .settings-card table tbody { display: block; }
  .admin-card table tr, .settings-card table tr {
    display: flex; flex-wrap: wrap; padding: 10px 0; gap: 6px; align-items: center;
  }
  .admin-card table td, .settings-card table td { padding: 4px 8px !important; border: none !important; }
  #adminTabBar { flex-wrap: wrap; }
  .admin-tab { padding: 8px 12px !important; font-size: 12px !important; }

  /* Buttons */
  .back-btn { padding: 6px 10px; font-size: 13px; }

  /* Auth screen — mobile: stack vertically */
  #authScreen { flex-direction: column; overflow-y: auto; }
  .auth-hero { display: none; }
  .auth-mobile-brand {
    display: block; text-align: center; padding: 40px 24px 28px;
    background: linear-gradient(135deg, #0D0008, #3A0011, #C8102E);
    background-size: 300% 300%;
    animation: authGradientShift 12s ease infinite;
    color: #fff; position: relative; overflow: hidden;
  }
  .auth-mobile-brand::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image:
      linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
  }
  .auth-mobile-brand-name {
    font-size: 32px; font-weight: 800; letter-spacing: -1px; margin-bottom: 6px;
    position: relative; z-index: 1;
  }
  .auth-mobile-brand-name span {
    background: linear-gradient(135deg, #FFB3BB, #FF6B7A);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  }
  .auth-mobile-brand-tagline {
    font-size: 13px; opacity: 0.7; font-weight: 300;
    position: relative; z-index: 1; margin-bottom: 4px;
  }
  .auth-mobile-mock { position: relative; z-index: 1; margin: 20px auto 0; max-width: 280px; background: rgba(0,0,0,0.3); border-radius: 10px; border: 1px solid rgba(255,255,255,0.1); padding: 10px; overflow: hidden; }
  .auth-mobile-mock-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
  .auth-mobile-mock-dot { width: 20px; height: 20px; border-radius: 50%; background: linear-gradient(135deg, #C8102E, #FF6B7A); flex-shrink: 0; }
  .auth-mobile-mock-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.1); }
  .auth-mobile-mock-tag { font-size: 7px; padding: 2px 6px; border-radius: 8px; background: rgba(200,16,46,0.2); color: #FF6B7A; font-weight: 600; }
  .auth-panel { width: 100%; flex: 1; padding: 32px 24px; align-items: flex-start; background: #fff; }
  .auth-card { max-width: 100%; }
  .auth-testimonial { display: none; }
  .auth-panel::before { display: none; }
  .auth-card { max-width: 100%; }
  .auth-card-icon { width: 40px; height: 40px; font-size: 18px; margin-bottom: 20px; }
  .auth-card-welcome { font-size: 24px; }
  .auth-card-sub { margin-bottom: 24px; }

  /* Detail cards — reduce padding on mobile for more text width */
  .detail-card { padding: 14px 12px !important; }
  .detail-header-card { padding: 16px 14px !important; }

  /* Contact cards — stack Draft Email button below text on mobile */
  .conn-card-inner {
    flex-direction: column !important;
    gap: 10px !important;
  }
  .conn-draft-btn {
    align-self: stretch !important;
    text-align: center !important;
    padding: 12px 14px !important;
  }

  /* Fit Score / AI Profile */
  .fit-score-badge { padding: 8px 12px; gap: 8px; width: auto !important; }
  .fit-score-num { font-size: 28px; }
  .fit-score-reason { font-size: 12px; }

  /* AI Profile mobile — force all inline grids to single column */
  .detail-card [style*="grid-template-columns: 1fr 1fr"],
  .detail-card [style*="grid-template-columns:1fr 1fr"],
  .detail-full [style*="grid-template-columns: 1fr 1fr"],
  .detail-full [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* AI Profile tables — convert to card layout on mobile */
  .ai-table { display: block !important; }
  .ai-table thead { display: none !important; }
  .ai-table tbody { display: block !important; }
  .ai-table tr {
    display: block !important;
    background: #FFFBFC !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    padding: 12px 14px !important;
    margin-bottom: 10px !important;
  }
  .ai-table td {
    display: block !important;
    padding: 3px 0 !important;
    border-bottom: none !important;
    font-size: 13px !important;
    white-space: normal !important;
    word-break: break-word !important;
  }
  .ai-table td:first-child {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: var(--navy) !important;
    padding-bottom: 4px !important;
    border-bottom: 1px solid #f0e0e3 !important;
    margin-bottom: 6px !important;
  }
  .ai-table td:nth-child(2) {
    font-size: 12px !important;
    color: #8C0D20 !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
  }
  .ai-table td:nth-child(3)::before {
    content: 'Notes: ';
    font-weight: 700;
    color: #666;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .ai-table td:nth-child(4)::before {
    content: 'Contact: ';
    font-weight: 700;
    color: #666;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .ai-table td:nth-child(5)::before {
    content: 'Social: ';
    font-weight: 700;
    color: #666;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .ai-table a { word-break: break-all !important; }

  /* Other non-ai-table tables — just allow scroll */
  .detail-card table:not(.ai-table),
  .detail-full table:not(.ai-table) {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    font-size: 12px !important;
  }
  .detail-card table:not(.ai-table) th,
  .detail-card table:not(.ai-table) td,
  .detail-full table:not(.ai-table) th,
  .detail-full table:not(.ai-table) td {
    padding: 6px 8px !important;
    font-size: 12px !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  /* Prevent any child from exceeding viewport in detail cards */
  .detail-card, .detail-full, .detail-card > div, .detail-full > div {
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }
  .detail-card a, .detail-full a {
    word-break: break-all !important;
  }

  /* Church at-a-glance photo + info: stack vertically */
  .detail-card [style*="flex:0 0 280px"] {
    flex: 1 1 100% !important;
    min-height: 160px !important;
  }
  .detail-card [style*="min-width:280px"] {
    min-width: 0 !important;
  }
  .detail-card [style*="min-width:180px"] {
    min-width: 0 !important;
  }

  /* Pastor LinkedIn badge — don't let it overflow */
  .detail-card [style*="word-break:break-all"],
  .detail-full [style*="word-break:break-all"] {
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
  }

  /* Quick links row — wrap nicely on mobile */
  .detail-card [style*="flex-wrap:wrap"] {
    gap: 6px !important;
  }

  /* CRM / Prospect cards */
  .crm-table { font-size: 13px; }

  /* General overflow fix */
  * { max-width: 100%; box-sizing: border-box; }
  img, video, iframe { max-width: 100%; height: auto; }
  table { max-width: 100%; }
  pre, code { overflow-x: auto; max-width: 100%; }
}
@media (max-width: 480px) {
  .county-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-value { font-size: 20px; }
  .mobile-nav-btn { font-size: 8px; padding: 4px 4px; min-width: 48px; }
  .mobile-nav-btn .nav-icon { font-size: 20px; }
  .main { padding-bottom: 62px; }
  .section-card-icon { font-size: 24px; }
  .welcome-card { padding: 16px; }
  .welcome-card h2 { font-size: 16px; }
  #content { padding: 10px; }
  .page-header { padding: 10px 12px; }
  .page-header h1 { font-size: 15px; }
}

/* PWA standalone mode — global safe area override (after all breakpoints) */
@media (display-mode: standalone) {
  .main { padding-top: env(safe-area-inset-top, 20px); }
  #content { padding-top: calc(12px + env(safe-area-inset-top, 20px)) !important; }
  .page-header { padding-top: calc(12px + env(safe-area-inset-top, 20px)) !important; }
}

/* ── AI Profile ─────────────────────────────────────────────────── */
.fit-score-badge {
  display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.15);
  border-radius: 12px; padding: 10px 16px; margin-top: 14px; width: fit-content;
}
.fit-score-num {
  font-size: 36px; font-weight: 900; line-height: 1; color: white;
}
.fit-score-label { font-size: 11px; color: rgba(255,255,255,0.8); font-weight: 600;
                   letter-spacing: 1px; text-transform: uppercase; }
.fit-score-reason { font-size: 13px; color: rgba(255,255,255,0.85); margin-top: 2px; }
.tier-pill {
  background: rgba(255,255,255,0.2); color: white; font-size: 12px; font-weight: 800;
  padding: 4px 12px; border-radius: 99px; letter-spacing: 0.5px;
}

.ai-generate-card {
  background: white; border-radius: var(--radius); padding: 28px 24px;
  box-shadow: var(--shadow-md); text-align: center;
  border: 2px dashed var(--border);
}
.ai-generate-icon { font-size: 40px; margin-bottom: 12px; }
.ai-generate-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.ai-generate-desc { font-size: 14px; color: var(--muted); max-width: 480px;
                    margin: 0 auto 20px; line-height: 1.6; }
.generate-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 13px 28px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary)); color: white;
  border: none; cursor: pointer;
  border-radius: 10px; font-size: 15px; font-weight: 700; transition: all .2s;
  box-shadow: 0 4px 14px rgba(200,16,46,0.3);
}
.generate-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(200,16,46,0.4); }
.generate-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.ai-generating-text { color: var(--muted); font-size: 14px; margin-top: 14px; }

/* AI Profile Progress Bar */
.ai-progress-container {
  margin-top: 16px;
  display: none;
}
.ai-progress-container.active { display: block; }
.ai-progress-bar-track {
  width: 100%;
  height: 8px;
  background: #E2E8F0;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 10px;
}
.ai-progress-bar-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.6s ease;
  width: 0%;
}
.ai-progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.ai-progress-step {
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
  background: #F7FAFC;
  color: #A0AEC0;
  border: 1px solid #E2E8F0;
  transition: all 0.3s ease;
}
.ai-progress-step.active {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: #FEB2B2;
  animation: stepPulse 1.5s infinite;
}
.ai-progress-step.done {
  background: #F0FFF4;
  color: #2F855A;
  border-color: #9AE6B4;
}
.ai-progress-status {
  font-size: 13px;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 6px;
}
.ai-progress-elapsed {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}
@keyframes stepPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
/* ── Social Profile Confirmation ── */
.social-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}
.social-badge-linkedin { background: #EBF8FF; color: #2B6CB0; border: 1px solid #BEE3F8; }
.social-badge-facebook { background: #EBF4FF; color: #2C5282; border: 1px solid #BEE3F8; }
.social-badge-instagram { background: #FFF5F7; color: #97266D; border: 1px solid #FED7E2; }
.social-badge:hover { opacity: 0.85; }
.social-badge.medium-confidence { opacity: 0.75; }
.social-badge.confirmed::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #48BB78;
  border: 2px solid white;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3.5 6L5.5 8L8.5 4' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 10px;
  background-position: center;
  background-repeat: no-repeat;
}
.social-confirm-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 13px;
  opacity: 0.5;
  transition: opacity 0.2s;
  line-height: 1;
}
.social-confirm-btn:hover { opacity: 1; }
.social-confirm-btn.confirm-yes:hover { color: #48BB78; }
.social-confirm-btn.confirm-no:hover { color: #E53E3E; }
.social-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  background: #F7FAFC;
  color: #A0AEC0;
  border: 1px dashed #CBD5E0;
  cursor: pointer;
  transition: all 0.2s;
}
.social-add-btn:hover { background: #EDF2F7; color: #4A5568; border-color: #A0AEC0; }

/* ── Thrivent Social Enrichment ── */
.enrichment-card { border: 2px solid #C53030; background: linear-gradient(135deg,#FFF5F5,#FFF5F7); border-radius: 12px; padding: 20px; }
.enrichment-card.running { animation: enrichPulse 2s ease-in-out infinite; }
@keyframes enrichPulse { 0%,100% { border-color: #C53030; } 50% { border-color: #F56565; } }
.enrichment-progress-bar { width: 100%; height: 8px; background: #E2E8F0; border-radius: 4px; overflow: hidden; margin: 12px 0; }
.enrichment-progress-bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg,#C53030,#F56565); transition: width 0.4s ease; }
.enrichment-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 12px 0; }
.enrichment-stat { text-align: center; padding: 10px 6px; background: white; border-radius: 8px; border: 1px solid #E2E8F0; }
.enrichment-stat-num { font-size: 22px; font-weight: 800; }
.enrichment-stat-label { font-size: 11px; color: var(--muted); }
.enrichment-live-feed { max-height: 200px; overflow-y: auto; font-size: 12px; background: #1A202C; color: #A0AEC0; border-radius: 8px; padding: 10px; margin-top: 10px; font-family: monospace; }
.enrichment-live-feed div { padding: 2px 0; border-bottom: 1px solid #2D3748; }
.enrichment-live-feed .found { color: #68D391; }
.enrichment-live-feed .not-found { color: #FC8181; }
.enrichment-live-feed .searching { color: #63B3ED; }
.enrichment-queue-item { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.enrichment-queue-item .name { font-weight: 700; font-size: 14px; min-width: 180px; }
.enrichment-queue-item .meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.enrichment-filter-tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.enrichment-filter-tab { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: white; cursor: pointer; transition: all 0.2s; }
.enrichment-filter-tab.active { background: #C53030; color: white; border-color: #C53030; }
.enrichment-filter-tab:hover:not(.active) { background: #FFF5F5; }

/* ── Circle Mapping ── */
.circle-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid #E2E8F0; padding-bottom: 0; }
.circle-tab { padding: 10px 16px; font-size: 13px; font-weight: 700; cursor: pointer; border: none; background: none; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.2s; color: var(--muted); }
.circle-tab:hover { color: var(--navy); }
.circle-tab.active { border-bottom-color: currentColor; }
.circle-tab-inner.active { color: #7C3AED; }
.circle-tab-professional.active { color: #3B82F6; }
.circle-tab-community.active { color: #38A169; }
.circle-tab-alumni.active { color: #D69E2E; }
.circle-member-card { background: white; border: 1px solid #E2E8F0; border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.circle-member-card:hover { border-color: #CBD5E0; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.circle-source-badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.circle-source-990 { background: #FFFAF0; color: #C05621; }
.circle-source-web { background: #EBF8FF; color: #2B6CB0; }
.circle-source-crm { background: #F0FFF4; color: #276749; }
.circle-confidence-high { background: #C6F6D5; color: #276749; }
.circle-confidence-medium { background: #FEFCBF; color: #744210; }
.circle-confidence-low { background: #E2E8F0; color: #4A5568; }

/* ── Tier 2 Locked Feature Overlay ── */
.feature-locked-overlay {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}
.feature-locked-blur {
  filter: blur(5px);
  pointer-events: none;
  user-select: none;
  opacity: 0.6;
}
.feature-locked-cta {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  padding: 28px 36px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(4px);
  max-width: 320px;
}
.feature-locked-cta .btn-primary {
  background: var(--primary, #3882F6);
  color: #fff;
  border: none;
}
.feature-locked-cta .btn-primary:hover {
  opacity: 0.9;
}
.ai-profile-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 10px;
}
.ai-profile-header h3 { font-size: 13px; font-weight: 700; color: var(--muted);
                         letter-spacing: 1px; text-transform: uppercase; }
.regenerate-btn {
  padding: 5px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--muted); transition: all .15s;
}
.regenerate-btn:hover { border-color: var(--navy); color: var(--navy); }

.ai-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
.ai-table th {
  background: var(--primary-subtle); color: var(--primary-dark); font-size: 11px; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase; padding: 8px 12px; text-align: left;
}
.ai-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top;
               line-height: 1.5; }
.ai-table tr:last-child td { border-bottom: none; }
.ai-table tr:hover td { background: #FFF8F8; }
.ai-table a { color: var(--primary); font-weight: 600; }
.priority-star { color: var(--primary); }

.action-steps { display: flex; flex-direction: column; gap: 12px; }
.action-step { display: flex; gap: 14px; align-items: flex-start; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: white;
  font-size: 13px; font-weight: 800; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; margin-top: 2px;
}
.step-body { flex: 1; }
.step-action { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.step-timing { font-size: 12px; color: var(--primary); font-weight: 700; }

.key-intel-box {
  background: linear-gradient(135deg, var(--primary-subtle), var(--primary-50)); border-left: 4px solid var(--primary);
  border-radius: 0 10px 10px 0; padding: 16px 18px;
}
.key-intel-label { font-size: 11px; font-weight: 800; color: var(--primary); letter-spacing: 1px;
                   text-transform: uppercase; margin-bottom: 8px; }
.key-intel-text { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.6; }

.ai-generated-at { font-size: 11px; color: var(--muted); margin-top: 8px; text-align: right; }
.conn-card-inner { display: flex; align-items: flex-start; gap: 12px; }
.conn-draft-btn { flex-shrink: 0; align-self: flex-start; }

/* ── Settings ───────────────────────────────────────────────────── */
.settings-card {
  background: white; border-radius: var(--radius); padding: 28px 32px;
  box-shadow: var(--shadow-md); border: 1px solid var(--border); margin-bottom: 20px;
}
/* Connector page — full-width cards */
.connector-full { max-width: 100% !important; }
.connector-upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.connector-upload-grid .settings-card { max-width: 100%; }
.connector-search-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 768px) {
  .connector-upload-grid { grid-template-columns: 1fr; }
  .connector-search-fields { grid-template-columns: 1fr; }
}
.admin-card {
  background: white; border-radius: var(--radius); padding: 28px 32px;
  box-shadow: var(--shadow-md); border: 1px solid var(--border); margin-bottom: 20px;
}
.admin-card h2 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.admin-card p  { font-size: 14px; color: var(--muted); margin-bottom: 20px; line-height: 1.6; }
.settings-card h2 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.settings-card p  { font-size: 14px; color: var(--muted); margin-bottom: 20px; line-height: 1.6; }
.settings-input-row { display: flex; gap: 10px; align-items: center; }
.settings-input {
  flex: 1; padding: 11px 14px; border: 2px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; font-family: monospace; transition: border-color .2s;
}
.settings-input:focus { border-color: var(--navy); }
.settings-save-btn {
  padding: 11px 20px; background: var(--navy); color: white; border-radius: 10px;
  font-size: 14px; font-weight: 700; transition: background .2s; white-space: nowrap;
}
.settings-save-btn:hover { background: var(--navy-dk); }
.settings-status {
  margin-top: 10px; font-size: 13px; font-weight: 600; min-height: 18px;
}
.settings-status.ok  { color: #2D7D46; }
.settings-status.err { color: #C53030; }

/* ── Hidden map div (required for Places API) ───────────────────── */
#gmap { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ── Guided Onboarding Tour ──────────────────────────────────────── */
.tour-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 9990; transition: opacity 0.3s; }
.tour-highlight { position: relative; z-index: 9991; box-shadow: 0 0 0 4px #FF6B7A, 0 0 20px rgba(200,16,46,0.4); border-radius: 8px; transition: all 0.3s; }
.tour-card { position: fixed; z-index: 9992; background: white; border-radius: 16px; padding: 24px 28px; max-width: 380px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: tourFadeIn 0.3s ease; }
@keyframes tourFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.tour-step-num { display: inline-block; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-dark); color: white; text-align: center; line-height: 28px; font-size: 13px; font-weight: 700; margin-right: 8px; }
.tour-title { font-size: 18px; font-weight: 800; color: #1A2D47; margin-bottom: 8px; display: inline; }
.tour-desc { font-size: 14px; color: #4A5568; line-height: 1.6; margin-bottom: 16px; }
.tour-progress { height: 4px; background: #E2E8F0; border-radius: 2px; margin-bottom: 16px; overflow: hidden; }
.tour-progress-fill { height: 100%; background: linear-gradient(90deg, #8C0D20, #FF6B7A); border-radius: 2px; transition: width 0.4s ease; }
.tour-btn-next { padding: 10px 24px; background: var(--primary-dark); color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; }
.tour-btn-next:hover { background: #6B0A18; }
.tour-btn-skip { padding: 10px 16px; background: none; border: none; color: #A0AEC0; font-size: 13px; cursor: pointer; }
.tour-btn-skip:hover { color: #718096; }

/* ── Enhanced Toast System ──────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 2500;
  display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none;
}
.toast-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-radius: 10px; font-size: 14px; font-weight: 600; min-width: 280px; max-width: 420px;
  box-shadow: var(--shadow-lg); pointer-events: auto;
  animation: toastSlideIn 0.3s ease;
  border-left: 4px solid transparent;
}
.toast-item.toast-exit { animation: toastSlideOut 0.3s ease forwards; }
.toast-success { background: #F0FFF4; color: #15803D; border-left-color: #16A34A; }
.toast-error   { background: #FEF2F2; color: #B91C1C; border-left-color: #DC2626; }
.toast-warning { background: #FFFBEB; color: #B45309; border-left-color: #D97706; }
.toast-info    { background: #EFF6FF; color: #1D4ED8; border-left-color: #2563EB; }
.toast-icon { display: flex; flex-shrink: 0; }
.toast-icon svg { width: 18px; height: 18px; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-progress {
  position: absolute; bottom: 0; left: 0; height: 3px; border-radius: 0 0 0 10px;
  animation: toastProgress 3s linear forwards;
}
.toast-success .toast-progress { background: #16A34A; }
.toast-error .toast-progress   { background: #DC2626; }
.toast-warning .toast-progress { background: #D97706; }
.toast-info .toast-progress    { background: #2563EB; }
@keyframes toastSlideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastSlideOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }
@media (max-width: 768px) {
  .toast-container { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); right: 12px; left: 12px; }
  .toast-item { min-width: auto; }
}

/* ── Form Validation States ─────────────────────────────────────── */
.form-input--error, .auth-input--error { border-color: var(--error) !important; }
.form-input--error:focus, .auth-input--error:focus { box-shadow: 0 0 0 3px rgba(220,38,38,0.1) !important; }
.form-input--success, .auth-input--success { border-color: var(--success) !important; }
.form-input--success:focus, .auth-input--success:focus { box-shadow: 0 0 0 3px rgba(22,163,74,0.1) !important; }
.field-error { display: block; font-size: 12px; font-weight: 500; color: var(--error); margin-top: 4px; }
.field-success { display: block; font-size: 12px; font-weight: 500; color: var(--success); margin-top: 4px; }

/* ── Skeleton Loading ───────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 37%, var(--gray-100) 63%);
            background-size: 400% 100%; animation: skeletonShimmer 1.4s ease infinite; border-radius: 8px; }
.skeleton-text { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 65%; }
.skeleton-heading { height: 22px; width: 50%; margin-bottom: 12px; border-radius: 6px; }
.skeleton-card { padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); background: white; }
.skeleton-circle { border-radius: 50%; }
@keyframes skeletonShimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── Empty States ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-state-icon { width: 80px; height: 80px; margin: 0 auto 20px; border-radius: 50%;
  background: var(--gray-100); display: flex; align-items: center; justify-content: center; }
.empty-state-icon svg { width: 36px; height: 36px; color: var(--gray-400); stroke-width: 1.5; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--muted); max-width: 360px; margin: 0 auto 20px; line-height: 1.6; }
.empty-state-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px;
  background: var(--primary); color: white; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.empty-state-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }

/* ── Data Table ────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: var(--gray-50); color: var(--gray-600); font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase; padding: 10px 14px; text-align: left;
  border-bottom: 2px solid var(--gray-200); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.data-table tbody tr:hover td { background: var(--gray-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table a { color: var(--primary); font-weight: 600; }
@media (max-width: 768px) {
  .data-table { display: block; }
  .data-table thead { display: none; }
  .data-table tbody { display: block; }
  .data-table tr { display: block; background: white; border: 1px solid var(--border);
    border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
  .data-table td { display: block; padding: 3px 0; border-bottom: none; font-size: 13px; }
  .data-table td:first-child { font-size: 15px; font-weight: 700; padding-bottom: 6px;
    border-bottom: 1px solid var(--gray-100); margin-bottom: 6px; }
}

/* ── Breadcrumbs ───────────────────────────────────────────────── */
.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; flex: 1; min-width: 0; }
.breadcrumb-item { color: var(--muted); cursor: pointer; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 200px; transition: color 0.15s; }
.breadcrumb-item:hover { color: var(--primary); }
.breadcrumb-sep { color: var(--gray-300); font-size: 12px; flex-shrink: 0; }
.breadcrumb-current { color: var(--text); font-weight: 700; cursor: default; }
.breadcrumb-current:hover { color: var(--text); }

/* ── Choices.js Custom Theme ──────────────────────────────────── */
.choices-custom { font-family: inherit; }
.choices-custom .choices__inner {
  border: 2px solid var(--border); border-radius: 10px; padding: 8px 12px;
  background: white; min-height: auto; font-size: 14px;
}
.choices-custom.is-focused .choices__inner { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(200,16,46,0.08); }
.choices-custom .choices__list--dropdown { border-radius: 10px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); margin-top: 4px; }
.choices-custom .choices__list--dropdown .choices__item--selectable.is-highlighted { background: var(--primary-subtle); color: var(--primary); }
.choices-custom .choices__list--single .choices__item { font-weight: 500; }

/* ── Tippy.js Custom Theme ─────────────────────────────────────── */
.tippy-box[data-theme~='ap'] { background: var(--gray-800); color: white; border-radius: 8px; font-size: 12px; font-weight: 500; padding: 2px 4px; box-shadow: var(--shadow-lg); }
.tippy-box[data-theme~='ap'] .tippy-arrow { color: var(--gray-800); }

/* ── Micro-interactions ─────────────────────────────────────────── */
button:not(.nav-item):not(.mobile-nav-btn):not(.more-menu-item):active { transform: scale(0.97); }
#content { animation: pageContentFade 0.15s ease; }
@keyframes pageContentFade { from { opacity: 0; } to { opacity: 1; } }

/* ── SweetAlert2 Custom Theme ──────────────────────────────────── */
.swal-custom { border-radius: 16px !important; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; }
.swal2-title { font-size: 18px !important; font-weight: 800 !important; }
.swal2-html-container { font-size: 14px !important; line-height: 1.6 !important; color: var(--gray-600) !important; }
.swal2-confirm, .swal2-cancel { border-radius: 10px !important; font-weight: 700 !important; font-size: 14px !important; padding: 10px 24px !important; }
.swal2-input { border-radius: 10px !important; border: 2px solid var(--border) !important; font-size: 14px !important; }
.swal2-input:focus { border-color: var(--primary) !important; box-shadow: 0 0 0 3px rgba(200,16,46,0.1) !important; }

/* Compliance watermark rules — duplicated from the print-window stylesheet
   so they also apply when the watermark div is mounted in the live app
   (e.g. on-screen preview of a dossier). The print window has its own
   copy of these rules inside its generated <style>; the duplication keeps
   both paths covered. Class selectors with no matching element are free. */
.ap-compliance-watermark {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='820' height='440'><g transform='rotate(-28 410 220)'><text x='50%' y='50%' dominant-baseline='middle' text-anchor='middle' font-family='Inter,sans-serif' font-weight='800' font-size='34' fill='%23C8102E' fill-opacity='0.08' letter-spacing='2'>INTERNAL ADVISOR PREP — DO NOT FORWARD</text></g></svg>");
  background-repeat: repeat;
}
.ap-compliance-watermark > span { display: none; }
.compliance-prep-footer {
  position: relative;
  z-index: 2;
  background: #F4F7FC;
}
@media print {
  @page {
    /* Reserve bottom band for the compliance footer — 22mm clears the
       5-line FINRA/Reg BI disclosure even after font-scaling. */
    margin: 18mm 14mm 22mm 14mm;
  }
  .ap-compliance-watermark {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='680' height='360'><g transform='rotate(-28 340 180)'><text x='50%' y='50%' dominant-baseline='middle' text-anchor='middle' font-family='Inter,sans-serif' font-weight='800' font-size='28' fill='%23C8102E' fill-opacity='0.11' letter-spacing='2'>INTERNAL ADVISOR PREP — DO NOT FORWARD</text></g></svg>");
  }
  .compliance-prep-footer {
    page-break-inside: avoid;
    background: #F4F7FC !important;
  }
}