:root {
  --gold: #B8863E;
  --gold-light: #D6A768;
  --bg: #FFFFFF;
  --surface: #F7F5F1;
  --border: rgba(184,134,62,.28);
  --text: #1E1812;
  --muted: #766B5C;
}
[data-theme="dark"] {
  --gold: #D6A768;
  --gold-light: #E2C49C;
  --bg: #15110D;
  --surface: #1E1812;
  --border: rgba(214,167,104,.25);
  --text: #F7F2EA;
  --muted: #A89A87;
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 24px;
  transition: background .2s ease, color .2s ease;
}

.leads-auth-wrap, .leads-dash-wrap, .leads-detail-wrap { max-width: 720px; margin: 0 auto; }

.form-error {
  background: rgba(200,60,60,.08);
  border: 1px solid rgba(200,60,60,.3);
  color: #A13B3B;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .85rem;
  margin-bottom: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-label { font-size: .8rem; color: var(--muted); font-weight: 500; letter-spacing: .3px; }
.form-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
}
.form-input:focus { border-color: var(--gold); outline: none; background: var(--bg); }

.btn-gold {
  background: var(--gold);
  color: #fff;
  border: none;
  padding: 14px 28px;
  border-radius: 8px;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.btn-gold:hover { background: var(--gold-light); transform: translateY(-2px); }
.form-submit { width: 100%; margin-top: 6px; }
.btn-sm { padding: 9px 16px; font-size: .82rem; }
.btn-sm:hover { transform: none; }

/* ── Logo ── */
.leads-logo { display: block; height: 36px; width: auto; max-width: 100%; margin: 0 auto 20px; }
.leads-logo-sm { display: block; height: 22px; width: auto; max-width: 100%; margin-bottom: 12px; }
.leads-dash-title .leads-logo-sm, .leads-detail-topbar .leads-logo-sm { margin-bottom: 0; }

/* ── Login ── */
.leads-auth-wrap { max-width: 360px; padding-top: 60px; }
.leads-auth-wrap h1 { font-size: 1.3rem; margin-bottom: 20px; text-align: center; }

/* ── Dashboard ── */
.leads-dash-wrap { max-width: 1100px; }
.leads-dash-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.leads-dash-title { display: flex; align-items: center; gap: 12px; }
.leads-dash-header h1 { font-size: 1.4rem; }
.leads-header-actions { display: flex; align-items: center; gap: 14px; }

.leads-detail-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.leads-logout { color: var(--muted); font-size: .85rem; text-decoration: none; }
.leads-logout:hover { color: var(--gold); }

.theme-toggle {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: .78rem; font-family: inherit;
  cursor: pointer; transition: color .2s ease, border-color .2s ease;
}
.theme-toggle:hover { color: var(--gold); border-color: var(--gold); }
.leads-theme-toggle-center { display: block; margin: 20px auto 0; }

.leads-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.leads-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.leads-table th, table.leads-table td {
  padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.leads-table th { color: var(--gold); font-weight: 600; background: var(--surface); }
table.leads-table td.wrap { white-space: normal; max-width: 260px; }
table.leads-table tr:last-child td { border-bottom: none; }
table.leads-table tbody tr:hover { background: var(--surface); }
.lead-row { cursor: pointer; }
.lead-name-link { color: var(--text); font-weight: 600; text-decoration: none; }
.lead-name-link:hover { color: var(--gold); text-decoration: underline; }

.leads-empty { color: var(--muted); padding: 40px; text-align: center; }

/* ── Filter bar ── */
.leads-filter-bar {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px; padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
}
.leads-filter-search { flex: 1; min-width: 180px; }
.leads-filter-bar .btn-gold { padding: 11px 20px; font-size: .85rem; }
.leads-clear-filters { color: var(--muted); font-size: .85rem; text-decoration: underline; align-self: center; }
.leads-clear-filters:hover { color: var(--gold); }

/* ── Status badges ──
   Plain <span> (dashboard list, read-only) and <select> (lead file, editable)
   share the same classes: the select rules add the border/background the
   span already has inline via its own declaration below. */
.status-badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; border: 1px solid transparent; background: var(--surface);
}
.status-badge.status-new { border-color: rgba(59,130,246,.4); background: rgba(59,130,246,.08); color: #1D4ED8; }
.status-badge.status-no_pickup { border-color: rgba(217,119,6,.4); background: rgba(217,119,6,.08); color: #B45309; }
.status-badge.status-contacted { border-color: rgba(124,58,237,.4); background: rgba(124,58,237,.08); color: #6D28D9; }
.status-badge.status-interested { border-color: rgba(22,163,74,.4); background: rgba(22,163,74,.08); color: #15803D; }
.status-badge.status-not_interested { border-color: rgba(220,38,38,.4); background: rgba(220,38,38,.08); color: #B91C1C; }

select.status-badge { cursor: pointer; font-family: inherit; }

/* ── WhatsApp ── */
.whatsapp-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #25D366; color: #fff; border: none; border-radius: 999px;
  padding: 10px 18px; font-size: .85rem; font-weight: 700; text-decoration: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: background .2s ease, transform .2s ease;
}
.whatsapp-btn:hover { background: #20BD5A; transform: translateY(-1px); }
.whatsapp-icon { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }

/* ── Activity log ── */
.activity-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.activity-list li { font-size: .8rem; white-space: normal; }
.activity-meta { display: block; color: var(--muted); font-size: .72rem; margin-bottom: 2px; }
.activity-note { color: var(--text); }
.activity-form { display: flex; gap: 6px; flex-wrap: wrap; }
.activity-form .form-input { padding: 8px 10px; font-size: .8rem; }
.activity-form select.form-input { flex: 0 0 auto; }
.activity-form input[type="text"] { flex: 1; min-width: 140px; }

.file-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.file-row a { color: var(--text); font-weight: 600; text-decoration: none; }
.file-row a:hover { color: var(--gold); text-decoration: underline; }
.file-delete-btn {
  background: none; border: none; color: #B91C1C; font-size: .72rem;
  cursor: pointer; text-decoration: underline; padding: 0;
}

/* ── Upload dropzone ── */
.upload-dropzone {
  position: relative; isolation: isolate;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 132px; padding: 24px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.upload-dropzone:hover, .upload-dropzone:focus-within {
  border-color: var(--gold);
  outline: none;
}
.upload-dropzone.drag-over {
  border-color: var(--gold);
  background: rgba(184,134,62,.08);
}
.upload-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.upload-icon { width: 28px; height: 28px; color: var(--gold); pointer-events: none; }
.upload-text { font-size: .9rem; color: var(--text); max-width: 280px; pointer-events: none; }
.upload-text strong { color: var(--gold); }
.upload-hint { font-size: .74rem; color: var(--muted); pointer-events: none; }

/* Files picked/dropped/pasted, queued for the next Upload click */
.upload-file-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.upload-file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.upload-file-icon { width: 22px; height: 22px; color: var(--gold); flex-shrink: 0; }
.upload-file-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.upload-file-name {
  font-size: .86rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.upload-file-size { font-size: .72rem; color: var(--muted); }
.upload-file-remove {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  font-size: 1rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s ease, border-color .15s ease;
}
.upload-file-remove:hover { color: #B91C1C; border-color: #B91C1C; }

.form-submit-file { margin-top: 12px; }
.form-submit-file:disabled, .form-submit-file:disabled:hover {
  opacity: .5; cursor: not-allowed; transform: none; background: var(--gold);
}

/* ── Lead file (detail page) ── */
.leads-back-link { display: inline-block; color: var(--muted); font-size: .85rem; text-decoration: none; margin-bottom: 16px; }
.leads-back-link:hover { color: var(--gold); }

.lead-file-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 14px; margin-bottom: 20px;
}
.lead-file-header h1 { font-size: 1.5rem; margin-bottom: 4px; }
.leads-page-title { font-size: 1.5rem; margin-bottom: 20px; }
.lead-file-sub { color: var(--muted); font-size: .9rem; }
.lead-file-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.lead-info-row { display: flex; align-items: stretch; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }

.lead-file-grid {
  flex: 1; min-width: 220px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px; padding: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px;
}
.lead-field { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; min-width: 0; }
.lead-field span:last-child { overflow-wrap: anywhere; }

.lead-qr {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}

.lead-section { margin-bottom: 28px; }
.lead-section h2 { font-size: 1rem; margin-bottom: 12px; color: var(--gold); }
.lead-message { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-size: .9rem; line-height: 1.6; }
.lead-empty-inline { color: var(--muted); font-size: .85rem; margin-bottom: 10px; }
