:root {
  --bg: #F1F4FA;
  --card: #FFFFFF;
  --ink: #1A2233;
  --muted: #6B7280;
  --line: #E4E8F1;

  --blue: #2F6FEF;
  --blue-dark: #1E4FC4;
  --green: #17A362;
  --red: #E5484D;
  --amber: #F5A623;
  --cyan: #17A6D8;
  --dark: #1F2430;
  --gray: #808896;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand span {
  font-weight: 500;
  color: var(--muted);
  margin-left: 6px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 11px 18px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary svg { width: 16px; height: 16px; }

/* Shell */
.shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}

/* Stat cards */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(20, 30, 60, 0.03);
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
}

.stat-blue { color: var(--blue); }
.stat-green { color: var(--green); }
.stat-red { color: var(--red); }
.stat-cyan { color: var(--cyan); }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
  flex: 1;
}

.filter-field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.filter-field input,
.filter-field select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.filter-field input:focus,
.filter-field select:focus { border-color: var(--blue); }

.btn-apply {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 10px 26px;
  border-radius: 7px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  height: 40px;
}
.btn-apply:hover { background: var(--blue-dark); }

/* Status tabs */
.tabs-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0.55;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.tab:hover { opacity: 0.8; }
.tab.active { opacity: 1; }
.tab:active { transform: scale(0.97); }

.tab-pending { background: var(--amber); }
.tab-verified { background: var(--green); }
.tab-nonverified { background: var(--red); }
.tab-notinterested { background: var(--dark); }
.tab-all { background: var(--gray); }

/* Table card */
.table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.entries-control, .search-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.entries-control select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

.search-control input {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  min-width: 240px;
  outline: none;
}
.search-control input:focus { border-color: var(--blue); }

.table-scroll {
  overflow-x: auto;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1000px;
}

.leads-table thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  padding: 12px 14px;
  border-bottom: 2px solid var(--line);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.leads-table thead th:hover { color: var(--blue); }
.leads-table thead th.no-sort { cursor: default; }
.leads-table thead th.no-sort:hover { color: var(--ink); }

.leads-table thead th::after {
  content: '↕';
  margin-left: 5px;
  font-size: 10px;
  color: var(--muted);
}
.leads-table thead th.no-sort::after { content: ''; }
.leads-table thead th.sort-asc::after { content: '↑'; color: var(--blue); }
.leads-table thead th.sort-desc::after { content: '↓'; color: var(--blue); }

.leads-table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  white-space: nowrap;
}

.leads-table tbody tr:hover { background: #FAFBFE; }

.lead-id-cell { font-weight: 700; color: var(--blue-dark); }
.name-cell { font-weight: 600; }
.muted-cell { color: var(--muted); }

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.badge-status-pending { background: var(--amber); }
.badge-status-verified { background: var(--green); }
.badge-status-non-verified { background: var(--red); }
.badge-status-not-interested { background: var(--dark); }

.badge-stage-assigned { background: var(--green); }
.badge-stage-unassigned { background: var(--amber); }

.badge-source-instagram { background: var(--cyan); }
.badge-source-facebook { background: var(--blue); }
.badge-source-holidify { background: #7C4FE0; }
.badge-source-default { background: var(--gray); }

/* Action buttons */
.actions-cell { display: flex; gap: 8px; }

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
}
.action-btn svg { width: 15px; height: 15px; }
.action-edit { background: var(--amber); }
.action-edit:hover { background: #d9910f; }
.action-whatsapp { background: var(--green); }
.action-whatsapp:hover { background: #128a52; }

/* Empty / loading */
.empty-state, .loading-state {
  padding: 50px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-title { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0 0 4px; }
.empty-sub { margin: 0; font-size: 13px; }
.loading-state { display: none; font-size: 13px; }
.loading-state.visible { display: block; }

/* Pagination */
.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.pagination-info { font-size: 13px; color: var(--muted); }

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-btn {
  border: 1px solid var(--line);
  background: #fff;
  padding: 7px 14px;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}
.page-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.page-indicator { font-size: 13px; color: var(--muted); }

/* Mobile card list (hidden on desktop) */
.leads-cards { display: none; }

.lead-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}

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

.lead-card-name { font-weight: 700; font-size: 15px; }
.lead-card-id { font-size: 12px; color: var(--blue-dark); font-weight: 700; }

.lead-card-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  border-top: 1px dashed var(--line);
}
.lead-card-row:first-of-type { border-top: none; }
.lead-card-row .k { color: var(--muted); }
.lead-card-row .v { font-weight: 500; text-align: right; }

.lead-card-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.lead-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.lead-card-actions .action-btn { flex: 1; width: auto; }

/* Detail panel (reused view) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 43, 0.45);
  z-index: 10;
}

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 92vw);
  background: var(--bg);
  z-index: 11;
  overflow-y: auto;
  box-shadow: -12px 0 40px rgba(20, 32, 43, 0.18);
}

.close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.close-btn:hover { color: var(--ink); border-color: var(--ink); }

.ticket {
  margin: 60px 20px 40px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
}

.ticket-head {
  background: var(--dark);
  color: #fff;
  padding: 20px 22px;
}
.ticket-eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cyan); margin: 0 0 6px; font-weight: 700;}
.ticket-name { font-size: 21px; font-weight: 800; margin: 0; }

.ticket-route {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px dashed var(--line);
}
.ticket-route .stop { flex: 1; }
.ticket-route .city { font-size: 15px; font-weight: 700; }
.ticket-route .label { font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.06em; margin-bottom: 3px; }
.ticket-route .plane { color: var(--amber); font-size: 16px; }

.ticket-section { padding: 16px 22px; border-bottom: 1px solid var(--line); }
.ticket-section:last-child { border-bottom: none; }
.ticket-section h4 { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; font-weight: 700; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.field { font-size: 13.5px; }
.field .k { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.field .v { color: var(--ink); word-break: break-word; font-weight: 500; }
.field.full { grid-column: 1 / -1; }

/* Panel mode tabs (View / Edit / Follow Up) */
.panel-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 22px;
  background: #F6F8FC;
  border-bottom: 1px solid var(--line);
}

.panel-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.panel-tab:hover { background: #fff; color: var(--ink); }
.panel-tab.active { background: var(--blue); color: #fff; }

/* Edit / Follow-up form fields */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

.form-field { font-size: 13px; }
.form-field.full { grid-column: 1 / -1; }

.form-field label {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 5px;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: var(--blue); }
.form-field textarea { resize: vertical; }

.panel-footer {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-save {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 7px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-save:hover { background: var(--blue-dark); }

.save-status { font-size: 13px; color: var(--muted); }

/* Follow-up history */
.followup-history {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.followup-entry {
  background: #F6F8FC;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.followup-entry-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.followup-entry-by { font-weight: 700; font-size: 13px; }
.followup-entry-date { font-size: 12px; color: var(--muted); }
.followup-entry-note { font-size: 13.5px; color: var(--ink); }
.followup-entry-next { font-size: 12px; color: var(--blue-dark); margin-top: 6px; font-weight: 600; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: #fff;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

/* ---------------- Mobile ---------------- */
@media (max-width: 760px) {
  .topbar { padding: 16px 18px; }
  .brand { font-size: 18px; }
  .brand span { display: block; font-size: 12px; margin-left: 0; }
  .btn-primary { padding: 9px 14px; font-size: 13px; }

  .shell { padding: 16px 16px 50px; }

  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-field { min-width: 0; }
  .btn-apply { width: 100%; }

  .table-toolbar { flex-direction: column; align-items: stretch; }
  .search-control input { min-width: 0; width: 100%; }

  /* Hide the wide table, show stacked cards instead */
  .table-scroll { display: none; }
  .leads-cards { display: block; }

  .pagination-row { justify-content: center; text-align: center; }

  .field-grid, .form-grid { grid-template-columns: 1fr; }
  .lead-card-actions { flex-wrap: wrap; }
  .lead-card-actions .action-btn { flex: 1 1 40%; }
}
