/* ==========================================
   Design System & Variable Definitions
   ========================================== */
:root {
  --font-primary: 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;

  /* Colors */
  --bg-dark: #0a051b;
  --card-bg: rgba(18, 12, 43, 0.65);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-active: rgba(129, 140, 248, 0.4);
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.4);
  
  --accent: #d946ef;
  --accent-hover: #c084fc;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #6b7280;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px var(--primary-glow);
}

/* ==========================================
   Reset & Base Layout
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-primary);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-dark);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding-bottom: 2rem;
}

/* Background Animated Glows */
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.35;
  pointer-events: none;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--primary) 0%, rgba(0,0,0,0) 70%);
  top: -100px;
  left: -100px;
}

.blob-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent) 0%, rgba(0,0,0,0) 70%);
  bottom: -150px;
  right: -100px;
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #3b82f6 0%, rgba(0,0,0,0) 70%);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: 2rem;
}

/* ==========================================
   Typography & Headers
   ========================================== */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
}

span.required {
  color: var(--error);
  margin-left: 2px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 1.5rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.logo-icon i {
  width: 24px;
  height: 24px;
  stroke: #fff;
}

.logo-icon .logo-mark {
  width: 26px;
  height: 26px;
}

.logo-text h1 {
  font-size: 1.8rem;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.logo-text h1 span {
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-stats {
  display: flex;
  gap: 1rem;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.stat-pill i {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.stat-pill strong {
  color: #fff;
  font-weight: 700;
}

/* ==========================================
   Main Grid & Glass Cards
   ========================================== */
.app-main {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr);
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 1rem;
}

.header-icon i {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.card-header h2 {
  font-size: 1.4rem;
  letter-spacing: -0.2px;
}

/* ==========================================
   Forms & Inputs
   ========================================== */
.form-group {
  margin-bottom: 1.5rem;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.tooltip {
  cursor: help;
  display: inline-flex;
}

.tooltip i {
  width: 14px;
  height: 14px;
  color: var(--text-dark);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1rem;
  width: 18px;
  height: 18px;
  color: var(--text-dark);
  pointer-events: none;
  transition: color 0.3s;
}

.textarea-icon {
  top: 1rem;
}

input[type="text"],
input[type="url"],
input[type="email"],
textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s ease;
}

textarea {
  resize: vertical;
  padding-left: 2.75rem;
  padding-top: 0.75rem;
}

input:focus,
textarea:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

input:focus + .input-icon,
textarea:focus + .input-icon {
  color: var(--primary);
}

.clear-btn {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.clear-btn i {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.clear-btn:hover i {
  color: #fff;
}

/* Dynamic Hidden Sections styling */
.section-hidden {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  margin-bottom: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-visible {
  opacity: 1;
  max-height: 1000px;
  margin-bottom: 1.5rem;
  pointer-events: auto;
}

/* ==========================================
   Search Loader State
   ========================================== */
.search-loader {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem;
  border-radius: 12px;
  border: 1px dashed var(--card-border);
  font-size: 0.9rem;
  color: var(--text-muted);
  animation: pulse 1.5s infinite;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ==========================================
   Options Grid (Search Results Selection)
   ========================================== */
.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.option-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
}

.option-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--primary-glow);
  transform: translateY(-2px);
}

.option-card.selected {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}

.option-icon {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.4rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
}

.option-card.selected .option-icon {
  background: var(--primary);
}

.option-icon i {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.option-card.selected .option-icon i {
  color: #fff;
}

.option-details {
  flex: 1;
}

.option-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.option-desc {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}

.option-url {
  font-size: 0.9rem;
  color: var(--accent-hover);
  font-weight: 600;
  word-break: break-all;
}

.manual-trigger-btn {
  background: none;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  color: var(--text-muted);
  transition: all 0.2s;
}

.manual-trigger-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-color: var(--text-dark);
}

.manual-field-wrapper {
  margin-top: 0.75rem;
}

/* Selected Summary Box */
.summary-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 12px;
  padding: 1rem;
  gap: 1rem;
}

.summary-content {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex: 1;
}

.summary-success-icon {
  width: 20px;
  height: 20px;
  color: var(--success);
  margin-top: 0.1rem;
}

.summary-details {
  display: flex;
  flex-direction: column;
}

.summary-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#selected-address-text,
#selected-website-summary a {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}

#selected-website-summary a {
  color: var(--accent-hover);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-hover);
}

#selected-website-summary a:hover {
  color: var(--accent);
  border-bottom-style: solid;
}

.change-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.change-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-muted);
}

/* ==========================================
   Key Contacts Section
   ========================================== */
.badge {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  font-weight: 500;
}

.contacts-builder {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contact-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .contact-inputs {
    grid-template-columns: 1fr;
  }
}

.mini-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.2) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: 8px !important;
  padding: 0.6rem 0.8rem !important;
  font-size: 0.85rem !important;
  color: #fff !important;
}

.mini-input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2) !important;
}

.attached-contacts-container {
  margin-top: 1rem;
}

.attached-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
  letter-spacing: 0.5px;
}

.contacts-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.contact-chip {
  background: rgba(217, 70, 239, 0.08);
  border: 1px solid rgba(217, 70, 239, 0.2);
  padding: 0.4rem 0.8rem;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  animation: slide-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.contact-chip-details {
  display: flex;
  flex-direction: column;
}

.contact-chip-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
}

.contact-chip-title-email {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.contact-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
}

.contact-chip-remove i {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.contact-chip-remove:hover i {
  color: var(--error);
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.8rem 1.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
}

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

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, #c084fc 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(217, 70, 239, 0.2);
}

.btn-accent:hover {
  box-shadow: 0 6px 20px rgba(217, 70, 239, 0.4);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  border-color: var(--card-border);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.btn-block + .btn-block {
  margin-top: 0.5rem;
}

/* ==========================================
   Database Explorer Panel
   ========================================== */
.explorer-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 980px;
}

.explorer-header {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.table-search-bar {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-bar-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dark);
}

.table-search-bar input {
  padding-left: 2.5rem;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.9rem;
  border-radius: 10px;
}

.table-wrapper {
  overflow: auto;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.15);
  flex: 1;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
}

.data-table th {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table tbody tr {
  transition: background-color 0.2s;
}

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

.school-name-td {
  font-weight: 600;
  color: #fff;
}

.address-td {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.website-td a {
  color: var(--accent-hover);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.website-td a:hover {
  color: var(--accent);
}

.website-td a i {
  width: 12px;
  height: 12px;
}

.text-center {
  text-align: center;
}

.table-empty-state {
  text-align: center;
  padding: 4rem 2rem !important;
  color: var(--text-muted);
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-dark);
  margin-bottom: 1rem;
}

/* Clickable school name button */
.school-load-btn {
  background: none;
  border: none;
  font-weight: 600;
  color: #fff;
  text-align: left;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
  font-size: 0.95rem;
}

.school-load-btn:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Contacts count pill */
.contacts-count-btn {
  background: rgba(217, 70, 239, 0.1);
  border: 1px solid rgba(217, 70, 239, 0.3);
  padding: 0.3rem 0.6rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-hover);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s;
}

.contacts-count-btn:hover {
  background: rgba(217, 70, 239, 0.2);
  border-color: rgba(217, 70, 239, 0.6);
  transform: scale(1.05);
}

.contacts-count-btn.disabled {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--card-border);
  color: var(--text-dark);
  cursor: not-allowed;
}

.contacts-count-btn.disabled:hover {
  transform: none;
}

/* ==========================================
   Modals (Contacts Detail Viewer)
   ========================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.25s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-dark);
  border: 1px solid var(--card-border-active);
  border-radius: 20px;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: scale-up 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

@keyframes scale-up {
  from { transform: scale(0.9) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.2rem;
  letter-spacing: -0.2px;
}

.modal-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.modal-close-btn i {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.modal-close-btn:hover i {
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
}

.modal-table-wrapper {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.modal-table th,
.modal-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--card-border);
}

.modal-table th {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
}

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

.modal-table td strong {
  color: #fff;
}

/* ==========================================
   Toast Notifications
   ========================================== */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 380px;
  width: 100%;
}

.toast {
  padding: 1rem 1.25rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: slide-toast 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  backdrop-filter: blur(10px);
}

@keyframes slide-toast {
  from { transform: translateX(100%) translateY(20px); opacity: 0; }
  to { transform: translateX(0) translateY(0); opacity: 1; }
}

.toast.toast-success {
  background: rgba(16, 185, 129, 0.95);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.toast.toast-error {
  background: rgba(239, 68, 68, 0.95);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.toast.toast-info {
  background: rgba(59, 130, 246, 0.95);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.toast i {
  width: 20px;
  height: 20px;
  stroke: #fff;
  flex-shrink: 0;
}

.toast-message {
  font-size: 0.9rem;
  font-weight: 550;
  color: #fff;
}

/* ==========================================
   Footer
   ========================================== */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--card-border);
  padding-top: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dark);
}

/* ==========================================
   Pipeline (progress by Likelihood of Purchasing)
   ========================================== */
.pipeline-card {
  padding: 1.5rem 2rem;
}

.pipeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.pipeline-header h2 {
  font-size: 1.2rem;
}

.pipeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pipeline-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.pipeline-hint {
  font-size: 0.8rem;
  color: var(--text-dark);
  margin: 0.5rem 0 1rem;
}

.pipeline-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pipeline-row {
  display: grid;
  grid-template-columns: 72px 1fr 110px 80px;
  align-items: center;
  gap: 1rem;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
  transition: background-color 0.2s, border-color 0.2s;
}

.pipeline-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.pipeline-row.active {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--card-border-active);
}

.pipeline-track {
  height: 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 7px;
  overflow: hidden;
}

.pipeline-bar {
  display: flex;
  height: 100%;
  min-width: 4px;
  border-radius: 7px;
  overflow: hidden;
  gap: 2px;
}

.pipeline-seg {
  height: 100%;
  display: block;
}

.pipeline-count {
  font-size: 0.85rem;
  color: var(--text-main);
  text-align: right;
}

.pipeline-done {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}

@media (max-width: 640px) {
  .pipeline-card {
    padding: 1.25rem 1rem;
  }

  .pipeline-row {
    grid-template-columns: 60px 1fr 70px;
    gap: 0.5rem;
  }

  .pipeline-done {
    display: none;
  }
}

/* Status colours (pipeline segments, legend, pills) */
.status-complete { --status-color: var(--success); }
.status-in_progress { --status-color: var(--warning); }
.status-new { --status-color: #818cf8; }
.status-skipped { --status-color: #6b7280; }

.legend-swatch,
.pipeline-seg {
  background: var(--status-color);
}

.pipeline-seg.status-new,
.legend-swatch.status-new {
  background: rgba(99, 102, 241, 0.45);
}

.status-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  white-space: nowrap;
  color: var(--status-color);
  border: 1px solid color-mix(in srgb, var(--status-color) 45%, transparent);
  background: color-mix(in srgb, var(--status-color) 12%, transparent);
}

/* Likelihood badges: hotter = more likely to purchase */
.likelihood-badge {
  display: inline-block;
  min-width: 48px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  border: 1px solid transparent;
}

.likelihood-badge.lk-hot {
  background: linear-gradient(135deg, var(--accent) 0%, #f472b6 100%);
  color: #fff;
}

.likelihood-badge.lk-warm {
  background: rgba(99, 102, 241, 0.3);
  border-color: rgba(129, 140, 248, 0.5);
  color: #e0e7ff;
}

.likelihood-badge.lk-mild {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(129, 140, 248, 0.25);
  color: #a5b4fc;
}

.likelihood-badge.lk-cool,
.likelihood-badge.lk-none {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--card-border);
  color: var(--text-muted);
}

/* ==========================================
   Research Queue & Loaded School
   ========================================== */
.queue-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
  transition: all 0.2s;
}

.queue-item:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--card-border-active);
}

.queue-item > svg {
  width: 16px;
  height: 16px;
  color: var(--text-dark);
  margin-left: auto;
  flex-shrink: 0;
}

.queue-item-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.queue-item-name {
  font-weight: 600;
  color: #fff;
  font-size: 0.92rem;
}

.queue-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.queue-more {
  font-size: 0.8rem;
  color: var(--text-dark);
  text-align: center;
}

.queue-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.queue-empty svg {
  width: 36px;
  height: 36px;
  color: var(--success);
  margin-bottom: 0.5rem;
}

#queue-panel .manual-trigger-btn {
  margin-top: 1rem;
}

.loaded-banner {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid var(--card-border-active);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.loaded-banner-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.loaded-banner-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}

.loaded-banner-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.loaded-banner-badges {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.secondary-actions + .btn-block {
  margin-top: 0.5rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================
   Explorer Filters, Sorting & Paging
   ========================================== */
.result-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 0.15rem 0.6rem;
}

.filter-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.filter-bar .table-search-bar {
  margin-bottom: 0;
}

.filter-selects {
  display: flex;
  gap: 0.5rem;
}

.filter-bar select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-main);
  font-family: var(--font-primary);
  outline: none;
  cursor: pointer;
}

.filter-bar select option {
  background: var(--bg-dark);
}

.filter-bar select:focus {
  border-color: var(--primary);
}

.likelihood-chips {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dark);
  margin-right: 0.25rem;
}

.filter-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-chip:hover {
  border-color: var(--text-muted);
  color: #fff;
}

.filter-chip.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--primary);
  color: #fff;
}

@media (max-width: 640px) {
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .filter-bar select {
    flex: 1;
    padding: 0.6rem 0.75rem;
  }
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th.sortable:hover,
.data-table th.sorted {
  color: #fff;
}

.data-table th.sortable::after {
  content: '\2195';
  margin-left: 0.3rem;
  opacity: 0.3;
}

.data-table th.sorted[data-dir="asc"]::after {
  content: '\2191';
  opacity: 1;
}

.data-table th.sorted[data-dir="desc"]::after {
  content: '\2193';
  opacity: 1;
}

.data-table th,
.data-table td {
  padding: 0.75rem 0.7rem;
}

.data-table .website-td a {
  display: inline-block;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.data-table .website-td a svg {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
  margin-right: 0.2rem;
}

.data-table tbody tr.row-editing {
  background: rgba(99, 102, 241, 0.12);
}

.school-load-btn {
  overflow-wrap: anywhere;
}

.school-meta {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.district-tag {
  display: inline-block;
  margin-left: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 0.05rem 0.4rem;
}

.table-empty-state .spinner {
  margin: 0 auto 1rem;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination:empty {
  display: none;
}

.pagination .btn svg {
  width: 14px;
  height: 14px;
}

/* ==========================================
   Sign-in Screen & Signed-in User
   ========================================== */
/* Nothing behind the sign-in screen is shown until access is confirmed */
body.auth-pending .app-container {
  display: none;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  text-align: center;
}

.auth-logo {
  margin: 0 auto 1rem;
}

.auth-title {
  font-size: 2rem;
  letter-spacing: -0.5px;
}

.auth-title span {
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.25rem 0 1.75rem;
}

.auth-loading {
  justify-content: center;
}

.google-mark {
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  padding: 2px;
}

.auth-message {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #fca5a5;
  background: var(--error-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}

.header-stats {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-pill span {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign-out-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0;
  margin-left: 0.25rem;
}

.sign-out-btn svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.sign-out-btn:hover svg {
  color: #fff;
}
