/* ================================================
   CONTACTS PAGE — PREP
   ================================================ */
:root {
  --color-primary: #5a189a;
  --color-secondary: #ffc300;
  --color-background: #f4f7f9;
  --color-text: #333333;
  --color-soft-gray: #6b7280;
  --color-error: #dc3545;
  --bg-body: var(--color-background);
  --bg-glass-panel: rgba(255, 255, 255, 0.55);
  --bg-glass-card: rgba(255, 255, 255, 0.6);
  --bg-input: rgba(255, 255, 255, 0.8);
  --border-color: rgba(192, 192, 192, 0.5);
  --border-glass: rgba(255, 255, 255, 0.7);
  --shadow-glass: 0 8px 32px rgba(90, 24, 154, 0.12), 0 2px 8px rgba(0,0,0,0.06);
  --glass-blur: blur(18px) saturate(180%);
  --font-family-sans: 'Poppins', system-ui, -apple-system, sans-serif;
  --border-radius-lg: 16px;
}

body.dark {
  --bg-body: #050505;
  --bg-glass-panel: rgba(15, 10, 25, 0.65);
  --bg-glass-card: rgba(20, 15, 35, 0.6);
  --bg-input: rgba(30, 25, 45, 0.75);
  --color-text: #ffffff;
  --color-soft-gray: #a3a3a3;
  --border-color: rgba(90, 24, 154, 0.3);
  --border-glass: rgba(90, 24, 154, 0.35);
  --color-secondary: #ffd60a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-family-sans);
  background: var(--bg-body);
  color: var(--color-text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(90,24,154,0.28) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 80%, rgba(255,195,0,0.22) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 30%, rgba(79,172,254,0.15) 0%, transparent 45%),
    radial-gradient(ellipse at 30% 70%, rgba(90,24,154,0.12) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* ── Page container ── */
.contacts-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px 16px 110px;
}

/* ── Header ── */
.contacts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-top: 6px;
}

.contacts-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
}

body.dark .contacts-header h1 { color: var(--color-text); }

.add-contact-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--color-secondary);
  color: #3E1F47;
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: filter 0.2s, transform 0.2s;
  box-shadow: 0 4px 14px rgba(90, 24, 154, 0.15);
  font-family: var(--font-family-sans);
}

.add-contact-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

/* ── Search + filter bar ── */
.contacts-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.contacts-search-wrap {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 50px;
  padding: 0 14px;
  height: 44px;
  gap: 10px;
  transition: border-color 0.2s;
}

.contacts-search-wrap:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(90, 24, 154, 0.08);
}

.contacts-search-wrap i { color: var(--color-soft-gray); font-size: 0.9rem; }

.contacts-search-wrap input {
  border: none;
  background: transparent;
  flex: 1;
  font-size: 0.9rem;
  color: var(--color-text);
  outline: none;
  font-family: var(--font-family-sans);
}

.contacts-search-wrap input::placeholder { color: var(--color-soft-gray); }

.dept-filter {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-color);
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  color: var(--color-text);
  font-family: var(--font-family-sans);
  font-size: 0.88rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.dept-filter:focus { border-color: var(--color-primary); }

/* ── Stats bar ── */
.contacts-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.stat-chip {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(90, 24, 154, 0.08);
  color: var(--color-primary);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.stat-chip:hover, .stat-chip.active {
  background: var(--color-primary);
  color: white;
}

body.dark .stat-chip {
  background: rgba(255, 214, 10, 0.08);
  color: var(--color-secondary);
}

body.dark .stat-chip:hover, body.dark .stat-chip.active {
  background: var(--color-secondary);
  color: #3E1F47;
}

/* ── Contact list ── */
.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Contact card ── */
.contact-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
}

.contact-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(90, 24, 154, 0.08);
  border-color: rgba(90, 24, 154, 0.25);
}

body.dark .contact-card {
  background: rgba(20, 10, 40, 0.45);
  border-color: rgba(90, 24, 154, 0.3);
}

body.dark .contact-card:hover {
  border-color: rgba(255, 214, 10, 0.2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Avatar */
.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* Avatar colours by department */
.avatar-director   { background: linear-gradient(135deg, #5a189a, #7b2fbe); }
.avatar-producer   { background: linear-gradient(135deg, #0891b2, #06b6d4); }
.avatar-cast       { background: linear-gradient(135deg, #d97706, #f59e0b); }
.avatar-crew       { background: linear-gradient(135deg, #059669, #10b981); }
.avatar-vendor     { background: linear-gradient(135deg, #dc2626, #ef4444); }
.avatar-writer     { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.avatar-other      { background: linear-gradient(135deg, #6b7280, #9ca3af); }

/* Info */
.contact-info { flex: 1; min-width: 0; }

.contact-name {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-role {
  font-size: 0.78rem;
  color: var(--color-primary);
  font-weight: 600;
  background: rgba(90, 24, 154, 0.08);
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
}

body.dark .contact-role {
  color: var(--color-secondary);
  background: rgba(255, 214, 10, 0.08);
}

.contact-detail {
  font-size: 0.78rem;
  color: var(--color-soft-gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quick actions */
.contact-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.contact-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-body);
  color: var(--color-soft-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
}

.contact-action-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

body.dark .contact-action-btn:hover {
  background: var(--color-secondary);
  color: #3E1F47;
  border-color: var(--color-secondary);
}

/* ── Empty state ── */
.contacts-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-soft-gray);
}

.contacts-empty i {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: 16px;
  display: block;
}

.contacts-empty p {
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.contacts-empty button {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 11px 22px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-family-sans);
  font-size: 0.9rem;
  transition: background 0.2s;
}

.contacts-empty button:hover { background: #4a148c; }

body.dark .contacts-empty button {
  background: var(--color-secondary);
  color: #3E1F47;
}

/* ── Loading ── */
.contacts-loading {
  text-align: center;
  padding: 40px;
  color: var(--color-soft-gray);
  font-size: 0.9rem;
}

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open { display: flex; }

.contact-modal {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modal-in 0.22s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.contact-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border-color);
}

.contact-modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
}

body.dark .contact-modal-header h2 { color: var(--color-secondary); }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-soft-gray);
  font-size: 1rem;
  transition: background 0.15s;
}

.modal-close:hover { background: rgba(0,0,0,0.06); }

.contact-modal-body { padding: 20px 22px; }

/* Form fields */
.field-group {
  margin-bottom: 14px;
}

.field-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--color-text);
  font-family: var(--font-family-sans);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(90, 24, 154, 0.1);
}

.field-group textarea { resize: vertical; min-height: 72px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-error {
  font-size: 0.78rem;
  color: var(--color-error);
  margin-top: 4px;
  display: none;
}

.field-error.show { display: block; }

/* Modal footer */
.contact-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-color);
  align-items: center;
}

/* Delete sits on the left, rest fill the right */
.contact-modal-footer .btn-delete {
  margin-right: auto;
}

.btn-save {
  flex: 1;
  padding: 12px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  transition: background 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-save:hover { background: #4a148c; transform: translateY(-1px); }
.btn-save:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

body.dark .btn-save { background: var(--color-secondary); color: #3E1F47; }
body.dark .btn-save:hover { background: #ffdb4d; }

.btn-cancel {
  padding: 12px 18px;
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  transition: background 0.15s;
}

.btn-cancel:hover { background: rgba(0,0,0,0.04); }

/* Delete button in edit mode */
.btn-delete {
  padding: 12px 14px;
  background: transparent;
  color: var(--color-error);
  border: 1px solid rgba(220, 53, 69, 0.3);
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-delete:hover { background: rgba(220, 53, 69, 0.08); }

/* ── View modal ── */

/* Wider view modal */
.contact-modal--view {
  max-width: 580px;
}

/* Hero section: avatar + name side by side */
.view-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.view-hero-info {
  flex: 1;
  min-width: 0;
}

.view-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.view-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
  word-break: break-word;
}

.view-role-badge {
  margin-bottom: 0;
}

.view-role-badge span {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 20px;
  background: rgba(90, 24, 154, 0.1);
  color: var(--color-primary);
  display: inline-block;
}

body.dark .view-role-badge span {
  background: rgba(255, 214, 10, 0.1);
  color: var(--color-secondary);
}

/* Details: two columns on wider screens */
.view-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

@media (max-width: 480px) {
  .view-details { grid-template-columns: 1fr; }
  .view-hero { flex-direction: column; text-align: center; }
  .view-hero-info { text-align: center; }
}

.view-detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-body);
  border-radius: 10px;
  font-size: 0.85rem;
  min-width: 0;
}

.view-detail-row i {
  width: 16px;
  color: var(--color-primary);
  flex-shrink: 0;
  font-size: 0.85rem;
}

body.dark .view-detail-row i { color: var(--color-secondary); }

.view-detail-row a,
.view-detail-row span {
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-detail-row a:hover { text-decoration: underline; }

/* Footer: delete on left, actions on right */
.view-modal-footer {
  justify-content: space-between;
  flex-wrap: nowrap;
}

.view-footer-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 480px) {
  .view-modal-footer { flex-wrap: wrap; }
  .view-footer-right { width: 100%; justify-content: stretch; }
  .view-footer-right button { flex: 1; }
}

.view-notes {
  padding: 12px 14px;
  background: var(--bg-body);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--color-soft-gray);
  line-height: 1.6;
  margin-bottom: 20px;
}

.view-actions {
  display: flex;
  gap: 10px;
}

.view-action-btn {
  flex: 1;
  padding: 11px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: opacity 0.15s, transform 0.15s;
  text-decoration: none;
}

.view-action-btn:hover { opacity: 0.88; transform: translateY(-1px); }

.btn-call { background: #22c55e; color: white; }
.btn-email { background: var(--color-primary); color: white; }
body.dark .btn-email { background: var(--color-secondary); color: #3E1F47; }

/* ── Toast ── */
.contacts-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: #333;
  color: white;
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 0.88rem;
  opacity: 0;
  transition: 0.35s;
  z-index: 3000;
  pointer-events: none;
  white-space: nowrap;
}

.contacts-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── Bottom nav — matches project_folder.css exactly ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.bottom-nav .nav-item {
    font-size: 1em;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: color 0.3s ease;
    padding: 4px 0;
    color: #8a8a8a;
    flex: 1;
    justify-content: center;
    min-width: 0;
}

.bottom-nav .nav-item span {
    font-size: 0.65em;
    margin-top: 2px;
    font-weight: 500;
}

.bottom-nav .nav-item i {
    font-size: 18px;
    margin-bottom: 2px;
}

.bottom-nav .nav-item.active {
    color: var(--color-primary);
}

body.dark .bottom-nav {
    background: rgba(10, 5, 20, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
}

body.dark .bottom-nav .nav-item {
    color: var(--color-soft-gray);
}

body.dark .bottom-nav .nav-item.active {
    color: var(--color-secondary);
}

@media (min-width: 1024px) {
  .bottom-nav {
    top: 0;
    left: 0;
    bottom: auto;
    width: 250px;
    height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 120px;
    gap: 25px;
    border-top: none;
    border-right: 1px solid var(--border-color);
    box-shadow: none;
  }

  .bottom-nav .nav-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 15px 30px;
    font-size: 1em;
    gap: 12px;
    flex: none;
    min-width: auto;
  }

  .bottom-nav .nav-item span {
    margin-top: 0;
    font-size: 1rem;
    font-weight: 600;
  }

  .bottom-nav .nav-item i {
    margin-bottom: 0;
    font-size: 1.2em;
    width: 24px;
    text-align: center;
  }

  .bottom-nav .nav-item:hover {
    background: rgba(0,0,0,0.05);
    border-right: 3px solid var(--color-secondary);
  }

  body.dark .bottom-nav .nav-item:hover {
    background: rgba(255,255,255,0.05);
  }

  .contacts-page {
    margin-left: 290px;
    padding: 40px;
    padding-bottom: 40px;
  }
}

/* ================================================
   EMAIL LOOKUP FLOW
   ================================================ */

/* Email input with icon */
.email-lookup-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0 14px;
  height: 46px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.email-lookup-wrap:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(90, 24, 154, 0.1);
}

.email-lookup-wrap i { color: var(--color-soft-gray); font-size: 0.9rem; flex-shrink: 0; }

.email-lookup-wrap input {
  border: none;
  background: transparent;
  flex: 1;
  font-size: 0.9rem;
  color: var(--color-text);
  outline: none;
  font-family: var(--font-family-sans);
  padding: 0;
  margin: 0;
}

/* Lookup status line */
.lookup-status {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 7px;
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
}

.lookup-status.looking { color: var(--color-soft-gray); }
.lookup-status.success { color: #16a34a; }
.lookup-status.manual  { color: #d97706; }
.lookup-status.error   { color: var(--color-error); }

body.dark .lookup-status.success { color: #4ade80; }
body.dark .lookup-status.manual  { color: #fbbf24; }

/* Profile preview card */
.profile-preview {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: linear-gradient(135deg, rgba(90,24,154,0.05), rgba(255,195,0,0.04));
  border: 1px solid rgba(90, 24, 154, 0.2);
  border-radius: 14px;
  padding: 16px;
  margin: 14px 0 4px;
  animation: preview-in 0.2s ease;
}

@keyframes preview-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

body.dark .profile-preview {
  background: linear-gradient(135deg, rgba(90,24,154,0.1), rgba(255,214,10,0.05));
  border-color: rgba(255, 214, 10, 0.2);
}

/* Preview avatar */
.preview-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.preview-avatar--img { background: var(--border-color); }
.preview-avatar--img img { width: 100%; height: 100%; object-fit: cover; }

/* Preview info */
.preview-info { flex: 1; min-width: 0; }

.preview-name {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 3px;
  color: var(--color-text);
}

.preview-job {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-primary);
  background: rgba(90, 24, 154, 0.1);
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  margin-bottom: 6px;
}

body.dark .preview-job {
  color: var(--color-secondary);
  background: rgba(255, 214, 10, 0.1);
}

.preview-detail {
  font-size: 0.78rem;
  color: var(--color-soft-gray);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}

.preview-detail i { color: var(--color-primary); font-size: 0.7rem; }
body.dark .preview-detail i { color: var(--color-secondary); }

.preview-bio {
  font-size: 0.78rem;
  color: var(--color-soft-gray);
  margin-top: 6px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* PREP user badge on contact cards */
.prep-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: #16a34a;
  margin-top: 3px;
}

.prep-user-badge i { font-size: 0.7rem; }
body.dark .prep-user-badge { color: #4ade80; }

/* Contact avatar with image */
.contact-avatar--img {
  background: var(--border-color);
  overflow: hidden;
}

.contact-avatar--img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.view-avatar--img {
  background: var(--border-color);
  overflow: hidden;
}

/* ================================================
   NEW ELEMENTS — COUNT, EXPORT, SORT, INVITE
   ================================================ */

/* Contact count badge in header */
.contacts-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  background: rgba(90, 24, 154, 0.1);
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 11px;
  padding: 0 7px;
  margin-left: 8px;
  vertical-align: middle;
}

body.dark .contacts-count {
  background: rgba(255, 214, 10, 0.1);
  color: var(--color-secondary);
}

/* Export / icon tool button */
.icon-tool-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-glass-card);
  color: var(--color-soft-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.icon-tool-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

body.dark .icon-tool-btn:hover {
  background: var(--color-secondary);
  color: #3E1F47;
  border-color: var(--color-secondary);
}

/* Invite to project button in view modal */
.btn-invite-project {
  padding: 11px 14px;
  background: rgba(90, 24, 154, 0.08);
  color: var(--color-primary);
  border: 1px solid rgba(90, 24, 154, 0.2);
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-invite-project:hover {
  background: rgba(90, 24, 154, 0.15);
}

body.dark .btn-invite-project {
  background: rgba(255, 214, 10, 0.08);
  color: var(--color-secondary);
  border-color: rgba(255, 214, 10, 0.2);
}

/* Invite project list */
.invite-project-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.invite-project-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-family-sans);
  font-size: 0.88rem;
  color: var(--color-text);
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  text-align: left;
}

.invite-project-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  background: rgba(90, 24, 154, 0.04);
}

.invite-project-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.invite-project-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.invite-already {
  font-size: 0.75rem;
  color: #16a34a;
  font-weight: 600;
}

.invite-add-btn {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

body.dark .invite-add-btn { color: var(--color-secondary); }

/* ================================================
   INVITE TO PREP FEATURE
   ================================================ */

/* "Not on PREP" badge on contact cards */
.not-prep-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-soft-gray);
  margin-top: 3px;
  opacity: 0.75;
}

.not-prep-badge i { font-size: 0.65rem; }

/* Invite-to-PREP card action button — distinct colour */
.invite-prep-card-btn {
  background: rgba(90, 24, 154, 0.08) !important;
  color: var(--color-primary) !important;
  border-color: rgba(90, 24, 154, 0.2) !important;
}

.invite-prep-card-btn:hover {
  background: var(--color-primary) !important;
  color: white !important;
  border-color: var(--color-primary) !important;
}

body.dark .invite-prep-card-btn {
  background: rgba(255, 214, 10, 0.08) !important;
  color: var(--color-secondary) !important;
  border-color: rgba(255, 214, 10, 0.2) !important;
}

body.dark .invite-prep-card-btn:hover {
  background: var(--color-secondary) !important;
  color: #3E1F47 !important;
  border-color: var(--color-secondary) !important;
}

/* "Invite to PREP" button in view modal footer */
.btn-invite-prep {
  padding: 11px 14px;
  background: linear-gradient(135deg, rgba(90, 24, 154, 0.1), rgba(255, 195, 0, 0.08));
  color: var(--color-primary);
  border: 1px solid rgba(90, 24, 154, 0.25);
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, transform 0.15s;
  white-space: nowrap;
}

.btn-invite-prep:hover {
  background: rgba(90, 24, 154, 0.18);
  transform: translateY(-1px);
}

body.dark .btn-invite-prep {
  background: rgba(255, 214, 10, 0.08);
  color: var(--color-secondary);
  border-color: rgba(255, 214, 10, 0.25);
}

body.dark .btn-invite-prep:hover {
  background: rgba(255, 214, 10, 0.16);
}

/* ── Invite to PREP modal ── */

/* Hero row: avatar + name */
.invite-prep-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
}

.invite-prep-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.invite-prep-avatar--img { background: var(--border-color); }
.invite-prep-avatar--img img { width: 100%; height: 100%; object-fit: cover; }

.invite-prep-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.invite-prep-sub {
  font-size: 0.75rem;
  color: var(--color-soft-gray);
  margin-top: 2px;
}

/* Description text */
.invite-prep-desc {
  font-size: 0.88rem;
  color: var(--color-soft-gray);
  margin-bottom: 18px;
  line-height: 1.55;
}

/* Option rows */
.invite-prep-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}

.invite-prep-option:hover {
  border-color: rgba(90, 24, 154, 0.25);
}

body.dark .invite-prep-option:hover {
  border-color: rgba(255, 214, 10, 0.2);
}

.invite-prep-option-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(90, 24, 154, 0.1);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

body.dark .invite-prep-option-icon {
  background: rgba(255, 214, 10, 0.1);
  color: var(--color-secondary);
}

.invite-prep-option-body {
  flex: 1;
  min-width: 0;
}

.invite-prep-option-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.invite-prep-option-sub {
  font-size: 0.75rem;
  color: var(--color-soft-gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.invite-prep-option-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-family-sans);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}

.invite-prep-option-btn:hover:not(:disabled) {
  background: #4a148c;
  transform: translateY(-1px);
}

.invite-prep-option-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

body.dark .invite-prep-option-btn {
  background: var(--color-secondary);
  color: #3E1F47;
}

body.dark .invite-prep-option-btn:hover:not(:disabled) {
  background: #ffdb4d;
}

/* Status message */
.invite-prep-status {
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 12px;
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.invite-prep-status.success { color: #16a34a; }
.invite-prep-status.info    { color: var(--color-soft-gray); }
.invite-prep-status.error   { color: var(--color-error); }

body.dark .invite-prep-status.success { color: #4ade80; }
