:root {
  --bg-dark: #04090b;
  --bg-card: rgba(8, 20, 22, 0.75);
  --bg-card-hover: rgba(12, 28, 30, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-glow: rgba(34, 211, 238, 0.4);
  
  --primary: #22d3ee;
  --primary-hover: #0891b2;
  --accent: #2dd4bf;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #f43f5e;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 35px -5px rgba(34, 211, 238, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  position: relative;
  line-height: 1.6;
}

/* Background Ambient Glows */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.4;
}

.bg-glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #22d3ee, #2dd4bf);
  top: -150px;
  left: 20%;
}

.bg-glow-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #0891b2, #0f766e);
  bottom: -100px;
  right: 10%;
}

/* Navbar */
.navbar {
  border-bottom: 1px solid var(--border-color);
  background: rgba(9, 13, 22, 0.8);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 34px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.45));
}

.logo-icon svg {
  width: 100%;
  height: 100%;
}

.logo-text span {
  color: var(--accent);
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-indicator.live {
  background-color: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.nav-link {
  color: var(--text-main);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 40px 20px 60px;
  max-width: 800px;
  margin: 0 auto;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(34, 211, 238, 0.15);
  color: #a5f3fc;
  border: 1px solid rgba(34, 211, 238, 0.3);
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 20px;
}

.pulse {
  width: 6px;
  height: 6px;
  background: #a5f3fc;
  border-radius: 50%;
  box-shadow: 0 0 8px #a5f3fc;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
  background: linear-gradient(135deg, #ffffff 40%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.125rem;
  line-height: 1.7;
  margin-bottom: 32px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.25s ease;
  font-family: var(--font-sans);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent), var(--primary-hover));
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.3);
}

.btn-danger-outline:hover {
  background: rgba(244, 63, 94, 0.1);
  border-color: var(--danger);
}

/* Section */
.section {
  margin-bottom: 60px;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

.stats-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stat-pill {
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* Accounts Grid */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.account-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-glow);
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.platform-badge.matterport {
  background: rgba(45, 212, 191, 0.15);
  color: var(--accent);
  border: 1px solid rgba(45, 212, 191, 0.3);
}

.platform-badge.flexmls {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.status-badge.active {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.status-badge.invalid {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.status-badge.pending,
.status-badge.testing {
  background: rgba(234, 179, 8, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.account-name {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.account-email {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.cred-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
  margin-bottom: 20px;
}

.card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

/* Playground Card */
.playground-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
}

.playground-tabs {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: rgba(34, 211, 238, 0.15);
  color: #a5f3fc;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.form-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.flex-1 {
  flex: 1;
}

.btn-align {
  height: 48px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  background: rgba(9, 13, 22, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
}

.password-wrapper {
  position: relative;
  display: flex;
}

.btn-toggle-pwd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

/* Response Viewer */
.response-viewer {
  background: #060911;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 14px;
}

.response-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 12px;
}

.response-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.response-time {
  font-size: 0.75rem;
  color: var(--accent);
  font-family: var(--font-mono);
}

.response-viewer pre {
  max-height: 350px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #2dd4bf;
  line-height: 1.5;
}

/* Security Banner */
.security-banner {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.08), rgba(45, 212, 191, 0.04));
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.security-icon {
  color: var(--accent);
}

.security-content h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.security-content p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: #0f1523;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .hero-title {
    font-size: 2.2rem;
  }
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-align {
    margin-top: 0;
  }

  .container {
    padding: 24px 16px 60px;
  }
  .nav-container {
    padding: 12px 16px;
  }
  .hero {
    padding: 24px 4px 40px;
  }

  /* Stack each section header rather than squeezing the title against the
     pills, and let the buttons fill the width instead of shrinking to fit. */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions .btn {
    width: 100%;
  }

  .section-title {
    font-size: 1.3rem;
  }
  .data-table th,
  .data-table td {
    padding: 12px 14px;
  }

  /* A long tenant name must not push the navbar wider than the screen. */
  .admin-tenant-select select {
    max-width: 100%;
  }

  /* The playground tab row (Matterport/Zillow/Redfin/Unified Report/
     Marketing Graphic) has no wrap or scroll, so on narrow viewports it
     was forcing the whole page to ~640px wide, which made mobile browsers
     zoom the entire page out to fit. Let it scroll horizontally instead,
     same pattern already used for .dashboard-table-container. */
  .playground-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab-btn {
    flex-shrink: 0;
  }

  /* .nav-right (live-sync indicator + super-admin tenant switcher + view
     toggle + user profile pill, all shown at once for a super-admin) is a
     non-wrapping flex row, so its combined min-content width also forced
     the page wide on narrow viewports even after the tab-bar fix above.
     .nav-container already wraps; let .nav-right's own items wrap too. */
  .nav-right {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  /* The super-admin scraper-credentials grid uses minmax(360px, 1fr)
     columns, which never shrinks below 360px regardless of viewport --
     also forcing the page wide on any phone screen. Stack to one column.
     Targeted by id: the unconditional .scraper-creds-grid rule further
     down the file has equal class specificity and comes later in source
     order, so it would otherwise win over a plain class selector here. */
  #scraper-creds-grid {
    grid-template-columns: 1fr;
  }
  #scraper-creds-grid > * {
    min-width: 0;
  }

  /* Even at one column, the card header (icon + title/desc on the left,
     state/token badges on the right) is a non-wrapping flex row, so its
     children's default min-width:auto still forced the card -- and via
     the grid item's own default min-width:auto, the grid track -- wider
     than the viewport. Let the header wrap so it can shrink to fit. */
  .scraper-cred-header {
    flex-wrap: wrap;
  }
  .scraper-cred-badges {
    flex-direction: row;
    align-items: center;
  }
}

/* Google Workspace Auth Styles */
.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 4px 12px 4px 6px;
  border-radius: var(--radius-pill);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: white;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.user-domain {
  font-size: 0.72rem;
  color: var(--accent);
  font-family: var(--font-mono);
}

.btn-signout {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.btn-signout:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
}

/* Auth Banner Card */
.auth-banner {
  margin: 28px auto 0;
  max-width: 680px;
}

.auth-card {
  background: rgba(24, 24, 37, 0.85);
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(34, 211, 238, 0.15);
  text-align: center;
  backdrop-filter: blur(12px);
}

.auth-icon {
  color: var(--primary);
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
}

.auth-text h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}

.auth-text p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.domain-badges {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.domain-badge {
  background: rgba(45, 212, 191, 0.12);
  color: var(--accent);
  border: 1px solid rgba(45, 212, 191, 0.3);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* "Sign in with Google" button, per
   https://developers.google.com/identity/branding-guidelines (light theme
   spec: #FFFFFF fill, #747775 1px inset stroke, #1F1F1F text, Google Sans /
   Roboto Medium 14/20). Do not recolor, restyle, or swap the "G" logo. */
.btn-google {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  height: 40px;
  padding: 0 12px 0 12px;
  background: #ffffff;
  border: 1px solid #747775;
  border-radius: 20px;
  color: #1f1f1f;
  font-family: 'Google Sans', 'Roboto', arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.25px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.218s, box-shadow 0.218s;
}

.btn-google-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin-right: 10px;
}

.btn-google-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.btn-google:hover {
  background: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

.btn-google:active {
  background: #f2f2f2;
}

.oauth-login-row {
  display: flex;
  justify-content: center;
}

.dev-login-row {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dev-login-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-outline-dev {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-mono);
}

.btn-outline-dev:hover {
  background: rgba(34, 211, 238, 0.15);
  color: #a5f3fc;
  border-color: var(--primary);
}

/* 1:1 Mappings Table & Pick List Styles */
.dashboard-table-container,
.mappings-table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
  backdrop-filter: blur(16px);
  margin-top: 16px;
}

.data-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.text-center {
  text-align: center;
  color: var(--text-muted);
}

.picklist-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--accent);
  font-family: var(--font-mono);
}

.mono-tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 4px;
  color: #94a3b8;
  display: inline-block;
}

/* Super-Admin View Switcher */
.admin-tenant-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}

.superadmin-badge {
  font-size: 0.68rem;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 0.05em;
  font-family: var(--font-heading);
}

#superadmin-domain-select {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  cursor: pointer;
  outline: none;
}

#superadmin-domain-select option {
  background: #181825;
  color: var(--text-main);
}

/* Freshness Badges & Relative Timers */
.freshness-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.freshness-badge.fresh {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.freshness-badge.stale {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.freshness-badge.updating {
  background: rgba(45, 212, 191, 0.12);
  color: #2dd4bf;
  border: 1px solid rgba(45, 212, 191, 0.3);
  animation: pulse-border 1.5s infinite;
}

.indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* This Week (Weekly Review Queue) */
.new-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(45, 212, 191, 0.15);
  color: var(--accent);
  border: 1px solid rgba(45, 212, 191, 0.35);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-left: 8px;
  vertical-align: middle;
}

.not-available {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
}

.weekly-confirmed-note {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Weekly packet freshness badges: green/amber/red mirror the dashboard's
   freshness-badge idiom but carry weekly-specific states (fresh/partial/stale
   sourced from PacketFreshness.State), so they are their own class rather
   than overloading .freshness-badge's existing amber "stale" meaning. */
.weekly-freshness-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
  max-width: 260px;
}

.weekly-freshness-badge.fresh {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.weekly-freshness-badge.partial {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.weekly-freshness-badge.stale {
  background: rgba(244, 63, 94, 0.12);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

/* Modal Large & Time Series Chart */
.modal-lg {
  max-width: 800px;
  width: 92%;
}

.timeseries-body {
  margin-top: 16px;
}

.chart-container {
  min-height: 280px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.svg-chart {
  width: 100%;
  height: 240px;
}

/* Live Row Update Animation */
@keyframes rowUpdatePulse {
  0% {
    background-color: rgba(34, 211, 238, 0.35);
  }
  100% {
    background-color: transparent;
  }
}

.row-updated {
  animation: rowUpdatePulse 2.5s ease-out;
}

/* Immutable FlexMLS Anchor Badge */
.anchor-locked {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(34, 211, 238, 0.15);
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: #a5f3fc;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.03em;
  user-select: none;
}

/* In-Place Table Editing Inputs */
/* Mapping table ID cells: an editable value, or a lookup button when the ID
   is not known yet. */
.id-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-lookup-id {
  white-space: nowrap;
}

.id-lookup-note {
  width: 100%;
  margin-top: 4px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-muted);
}

.table-input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 4px;
  width: 100%;
  max-width: 140px;
  transition: all 0.2s ease;
}

.table-input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.2);
}

.table-select {
  background: #181825;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #2dd4bf;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 6px 8px;
  border-radius: 4px;
  width: 100%;
  max-width: 220px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.table-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.2);
}

.save-indicator {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.75rem;
  color: #34d399;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.save-indicator.active {
  opacity: 1;
}

/* Credentials Hierarchy Notice */
.hierarchy-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.3);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #c7d2fe;
  font-size: 0.82rem;
  margin-bottom: 16px;
}

/* Flagstaff Marketing Graphic Modal Preview */
.card-preview-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}

.card-preview-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.card-iframe-container {
  width: 100%;
  height: 580px;
  background: #051422;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}





/* Super-admin scrape source panel. */
.scraper-panel {
  margin: 20px 0;
  padding: 18px 20px;
  border: 1px solid var(--border, #2a2a3a);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.scraper-panel-header h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.scraper-panel-header p {
  margin: 0 0 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.scraper-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.scraper-card {
  flex: 1 1 260px;
  padding: 12px 14px;
  border: 1px solid var(--border, #2a2a3a);
  border-radius: 6px;
}

.scraper-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.scraper-state {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.scraper-state.enabled {
  color: #052e16;
  background: #4ade80;
}

.scraper-state.disabled {
  color: #1f1300;
  background: #fbbf24;
}

.scraper-state.unconfigured {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.08);
}

.scraper-platforms,
.scraper-counts {
  margin: 2px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.scraper-error {
  margin: 6px 0;
  font-size: 0.72rem;
  color: var(--danger, #f87171);
  word-break: break-word;
}

.scraper-empty {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Scraper Service Credentials Section */
.scraper-creds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
  margin-top: 12px;
}

.scraper-cred-card {
  background: var(--surface, #1e1e2d);
  border: 1px solid var(--border, #2a2a3a);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.scraper-cred-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}

.scraper-cred-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scraper-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.scraper-cred-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 2px 0;
  color: var(--text, #fff);
}

.scraper-cred-desc {
  font-size: 0.78rem;
  color: var(--text-muted, #9ca3af);
  margin: 0;
  line-height: 1.35;
}

.scraper-cred-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.scraper-cred-form .form-group {
  margin-bottom: 12px;
}

.scraper-cred-form label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted, #d1d5db);
  margin-bottom: 5px;
}

.scraper-cred-form input[type="text"],
.scraper-cred-form input[type="password"] {
  width: 100%;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border, #3b3b4f);
  border-radius: 6px;
  color: var(--text, #fff);
  font-size: 0.88rem;
}

.scraper-cred-form input[type="text"]:focus,
.scraper-cred-form input[type="password"]:focus {
  outline: none;
  border-color: var(--primary, #22d3ee);
}

.scraper-cred-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  border: 1px solid #b91c1c;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* === SHELL: role views + shared components === */

/* --- Agent view: single-column, mobile-first --- */
#agent-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 4px 60px;
}

#agent-header {
  padding: 20px 4px 4px;
}

.agent-greeting {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 6px;
}

.agent-greeting-sub {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
}

#agent-onboarding-mount,
#agent-weekly-mount {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 768px) {
  #agent-view {
    max-width: 720px;
    gap: 32px;
    padding: 0 0 80px;
  }

  #agent-header {
    padding: 32px 0 8px;
  }

  .agent-greeting {
    font-size: 2.1rem;
  }
}

/* --- Shared agent-view components (used by onboarding.js / weekly-agent.js) --- */

/* Card: the basic content block for agent-facing lists (queue items,
   weekly listing cards, etc). */
.a-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* Field: a labeled input row inside an .a-card form. */
.a-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.a-field:last-child {
  margin-bottom: 0;
}

.a-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.a-field input,
.a-field select,
.a-field textarea {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 10px 12px;
  /* >=16px so mobile Safari doesn't focus-zoom the page on tap. */
  font-size: max(1rem, 16px);
  font-family: var(--font-sans);
}

.a-field input:focus,
.a-field select:focus,
.a-field textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Badge: small status/state pill (freshness, state, etc). */
.a-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.a-badge.ok {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}

.a-badge.warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.3);
}

.a-badge.error {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.3);
}

/* --- View toggle (super-admin preview: technical vs agent) --- */
#view-toggle-container {
  align-items: center;
}

.view-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}

.view-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-toggle-btn.active {
  background: var(--primary);
  color: white;
}

.view-toggle-btn:not(.active):hover {
  color: var(--text-main);
}

/* --- Toasts --- */
.shell-toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  width: 100%;
  max-width: 420px;
  padding: 0 16px;
  pointer-events: none;
}

.shell-toast {
  pointer-events: auto;
  background: #0f1523;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  color: var(--text-main);
  padding: 12px 16px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(8px);
  animation: shell-toast-in 0.2s ease forwards;
}

.shell-toast.shell-toast-hide {
  animation: shell-toast-out 0.3s ease forwards;
}

.shell-toast.ok {
  border-color: rgba(16, 185, 129, 0.4);
}

.shell-toast.error {
  border-color: rgba(244, 63, 94, 0.4);
}

.shell-toast.info {
  border-color: rgba(34, 211, 238, 0.4);
}

@keyframes shell-toast-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shell-toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* --- Confirm modal (Shell.confirm) --- */
.shell-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2100;
  padding: 20px;
}

.shell-modal-overlay.active {
  display: flex;
}

.shell-modal {
  background: #0f1523;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.shell-modal-message {
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

.shell-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* --- Portal Badges & Linkages Styling --- */
.portal-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.portal-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
  line-height: 1.4;
}

.portal-pill .portal-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.portal-pill .ext-icon {
  font-size: 0.7rem;
  opacity: 0.7;
}

.portal-pill .plus-icon {
  font-size: 0.75rem;
  opacity: 0.6;
}

.portal-pill.portal-flexmls.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.35);
  color: #93c5fd;
}
.portal-pill.portal-flexmls.active:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #60a5fa;
}

.portal-pill.portal-zillow.active {
  background: rgba(14, 165, 233, 0.15);
  border-color: rgba(14, 165, 233, 0.35);
  color: #7dd3fc;
}
.portal-pill.portal-zillow.active:hover {
  background: rgba(14, 165, 233, 0.25);
  border-color: #2dd4bf;
}

.portal-pill.portal-redfin.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
.portal-pill.portal-redfin.active:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #f87171;
}

.portal-pill.portal-realtor.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fde047;
}
.portal-pill.portal-realtor.active:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: #fbbf24;
}

.portal-pill.portal-homes.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}
.portal-pill.portal-homes.active:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: #34d399;
}

.portal-pill.portal-matterport.active {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.35);
  color: #d8b4fe;
}
.portal-pill.portal-matterport.active:hover {
  background: rgba(168, 85, 247, 0.25);
  border-color: #c084fc;
}

.portal-pill.unlinked {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  opacity: 0.75;
}
.portal-pill.unlinked:hover {
  opacity: 1;
  border-color: var(--primary);
  color: var(--text-main);
  background: rgba(34, 211, 238, 0.1);
}

.flexmls-anchor-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(34, 211, 238, 0.15);
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: #a5f3fc;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-decoration: none;
  transition: all 0.15s ease;
}
.flexmls-anchor-link:hover {
  background: rgba(34, 211, 238, 0.25);
  border-color: #818cf8;
  color: #ffffff;
}

@media (max-width: 768px) {
  .portal-pill-group {
    gap: 4px;
  }
  .portal-pill {
    font-size: 0.72rem;
    padding: 2px 6px;
  }
  .data-table th,
  .data-table td {
    padding: 10px 12px;
  }
}

/* Connected Vault Accounts Grid & Cards */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.2s ease;
  backdrop-filter: blur(12px);
}

.account-card:hover {
  border-color: rgba(34, 211, 238, 0.4);
  box-shadow: var(--shadow-md);
}

.account-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.account-platform-badge {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
}

.account-platform-badge.flexmls {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.account-platform-badge.matterport {
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.account-info .account-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  word-break: break-all;
}

.account-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}



