/* ============================================================
   Reusable components: buttons, inputs, cards, status pills,
   toolbar, table shell — adapted from the prospecting-crm.html
   prototype so the whole app reads as one polished system.
   ============================================================ */

.card{
  background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.field-label{
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 6px; letter-spacing: .2px;
}
.field-input, select, textarea.field-input{
  width: 100%; font-family: var(--font); font-size: 14px; padding: 10px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--input-bg); color: var(--text-primary); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field-input:focus, select:focus, textarea.field-input:focus{
  border-color: var(--brand-green-soft); box-shadow: 0 0 0 3px rgba(74,81,71,.14);
}

.btn{
  font-family: var(--font); font-size: 13px; padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--surface-alt); color: var(--text-primary);
  cursor: pointer; outline: none; transition: border-color .15s ease, background .15s ease, transform .1s ease;
  font-weight: 600;
}
.btn:hover{ border-color: var(--brand-green-soft); }
.btn:active{ transform: scale(.97); }
.btn:disabled{ opacity: .55; cursor: not-allowed; }
.btn.primary{
  background: var(--brand-green); color: #fbfaf6; border: none;
  width: 100%;
}
.btn.primary:hover{ background: var(--brand-green-deep); }
.btn.block{ width: 100%; }

.error-banner{
  background: var(--st-notint-bg); color: var(--st-notint-fg); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px; font-weight: 600; margin-bottom: 16px;
}
.success-banner{
  background: var(--st-closed-bg); color: var(--st-closed-fg); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px; font-weight: 600; margin-bottom: 16px;
}

/* ---------- Status pills (8 required lead statuses) ---------- */
.status-pill{
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 5px 12px 5px 10px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.status-pill .dot{ width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-pill.st-new{ background: var(--st-new-bg); color: var(--st-new-fg); }
.status-pill.st-new .dot{ background: var(--st-new-dot); }
.status-pill.st-no-answer{ background: var(--st-no-answer-bg); color: var(--st-no-answer-fg); }
.status-pill.st-no-answer .dot{ background: var(--st-no-answer-dot); }
.status-pill.st-appt{ background: var(--st-appt-bg); color: var(--st-appt-fg); }
.status-pill.st-appt .dot{ background: var(--st-appt-dot); }
.status-pill.st-followup{ background: var(--st-followup-bg); color: var(--st-followup-fg); }
.status-pill.st-followup .dot{ background: var(--st-followup-dot); }
.status-pill.st-closed{ background: var(--st-closed-bg); color: var(--st-closed-fg); }
.status-pill.st-closed .dot{ background: var(--st-closed-dot); }
.status-pill.st-notint{ background: var(--st-notint-bg); color: var(--st-notint-fg); }
.status-pill.st-notint .dot{ background: var(--st-notint-dot); }
.status-pill.st-gate{ background: var(--st-gate-bg); color: var(--st-gate-fg); }
.status-pill.st-gate .dot{ background: var(--st-gate-dot); }
.status-pill.st-disconnected{ background: var(--st-disconnected-bg); color: var(--st-disconnected-fg); }
.status-pill.st-disconnected .dot{ background: var(--st-disconnected-dot); }

/* ---------- Stat cards (dashboards) ---------- */
.stat-grid{ display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card{
  background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover{ transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-label{
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-secondary); margin-bottom: 8px;
}
.stat-card .stat-value{ font-size: 28px; font-weight: 750; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px){ .stat-grid{ grid-template-columns: repeat(2, 1fr); } }

/* ---------- Toolbar (search/filter bar) ---------- */
.toolbar{
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.search-box{ flex: 1 1 240px; position: relative; min-width: 220px; }
.search-box input{
  width: 100%; padding: 10px 14px 10px 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--surface-alt); color: var(--text-primary);
  font-size: 13.5px; outline: none;
}
.search-box::before{
  content: "\2315"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 16px; color: var(--text-secondary); pointer-events: none;
}
.results-count{ font-size: 12.5px; color: var(--text-secondary); margin-left: auto; white-space: nowrap; padding-left: 8px; }

/* ---------- Table ---------- */
.table-wrap{ background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-scroll{ overflow-x: auto; }
table{ width: 100%; border-collapse: collapse; min-width: 1350px; }
thead th{
  position: sticky; top: 0; background: var(--surface-alt); z-index: 5;
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-secondary); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--border-color);
  white-space: nowrap; cursor: pointer; user-select: none;
}
thead th:hover{ color: var(--text-primary); }
tbody tr{ border-bottom: 1px solid var(--border-color); transition: background .12s ease; }
tbody tr:last-child{ border-bottom: none; }
tbody tr:hover{ background: var(--row-hover); }
tbody td{ padding: 10px 14px; font-size: 13.5px; vertical-align: middle; color: var(--text-primary); }
td.company-cell{ font-weight: 600; min-width: 210px; }
td.phone-cell a, td.website-cell a{ color: var(--accent-2); text-decoration: none; font-weight: 500; }
td.phone-cell a:hover, td.website-cell a:hover{ text-decoration: underline; }
td.website-cell .no-site{ color: var(--text-secondary); font-style: italic; font-size: 12.5px; }

.empty-state{ text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state .big{ font-size: 38px; margin-bottom: 10px; }

.table-scroll::-webkit-scrollbar{ height: 10px; }
.table-scroll::-webkit-scrollbar-thumb{ background: var(--border-color); border-radius: 6px; }
.table-scroll::-webkit-scrollbar-track{ background: transparent; }

/* ---------- Status select (inline status change in the table) ---------- */
.status-select{
  appearance: none; -webkit-appearance: none; border: none; border-radius: 999px;
  padding: 6px 26px 6px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer;
  background-repeat: no-repeat; background-position: right 9px center; background-size: 9px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path fill='%23555' d='M0 0l5 6 5-6z'/></svg>");
  min-width: 168px;
}
.status-select.st-new{ background-color: var(--st-new-bg); color: var(--st-new-fg); }
.status-select.st-no-answer{ background-color: var(--st-no-answer-bg); color: var(--st-no-answer-fg); }
.status-select.st-appt{ background-color: var(--st-appt-bg); color: var(--st-appt-fg); }
.status-select.st-followup{ background-color: var(--st-followup-bg); color: var(--st-followup-fg); }
.status-select.st-closed{ background-color: var(--st-closed-bg); color: var(--st-closed-fg); }
.status-select.st-notint{ background-color: var(--st-notint-bg); color: var(--st-notint-fg); }
.status-select.st-gate{ background-color: var(--st-gate-bg); color: var(--st-gate-fg); }
.status-select.st-disconnected{ background-color: var(--st-disconnected-bg); color: var(--st-disconnected-fg); }

/* ---------- Notes preview cell ---------- */
td.notes-cell{ max-width: 220px; color: var(--text-secondary); font-size: 12.5px; }
td.notes-cell .notes-preview{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 220px; }
.link-btn{ background: none; border: none; padding: 0; font: inherit; color: var(--accent-2); cursor: pointer; font-weight: 600; }
.link-btn:hover{ text-decoration: underline; }

/* ---------- Modal / drawer ---------- */
.modal-overlay{
  position: fixed; inset: 0; background: rgba(20,22,18,.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: flex-end;
}
.modal-overlay[hidden]{ display: none; }
.modal-panel{
  width: 100%; max-width: 480px; height: 100%; background: var(--surface);
  box-shadow: var(--shadow-lg); overflow-y: auto; padding: 28px 28px 40px;
  animation: slideIn .2s ease;
}
@keyframes slideIn{ from{ transform: translateX(24px); opacity: 0; } to{ transform: translateX(0); opacity: 1; } }
.modal-header{ display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.modal-title{ font-size: 17px; font-weight: 700; margin: 0; }
.modal-close{ background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-secondary); line-height: 1; padding: 4px; }
.modal-close:hover{ color: var(--text-primary); }
.modal-section{ margin-bottom: 24px; }
.modal-section-title{ font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); margin-bottom: 10px; }
.modal-actions{ display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn{ width: auto; flex: 1; }

.timeline-item{ display: flex; gap: 10px; padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--border-color); }
.timeline-item:last-child{ border-bottom: none; }
.timeline-item .timeline-dot{ width: 7px; height: 7px; border-radius: 50%; background: var(--brand-green-soft); margin-top: 6px; flex-shrink: 0; }
.timeline-item .timeline-meta{ color: var(--text-secondary); font-size: 11.5px; margin-top: 2px; }

.note-item{ background: var(--surface-alt); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.note-item .note-meta{ color: var(--text-secondary); font-size: 11.5px; margin-bottom: 4px; }

.toolbar-title{ display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar-title h1{ font-size: 18px; margin: 0; }

/* ---------- Simple active/inactive pill (Users module) ---------- */
.pill{ display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.pill.active{ background: var(--st-closed-bg); color: var(--st-closed-fg); }
.pill.inactive{ background: var(--st-gate-bg); color: var(--st-gate-fg); }
.pill.role-admin{ background: var(--brand-beige); color: var(--brand-green-deep); }
.pill.role-setter{ background: var(--surface-alt); color: var(--text-secondary); border: 1px solid var(--border-color); }

td.actions-cell{ white-space: nowrap; }
td.actions-cell .btn{ width: auto; padding: 6px 10px; font-size: 12px; margin-right: 6px; }

.checkbox-cell{ width: 32px; }

/* ---------- Filter panel + pagination (Leads module) ---------- */
.filter-panel{
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.filter-panel[hidden]{ display: none; }
.filter-field{ display: flex; flex-direction: column; gap: 4px; }
.filter-field label{ font-size: 11.5px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .3px; }
.filter-actions{ grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 900px){ .filter-panel{ grid-template-columns: repeat(2, 1fr); } }

.pagination{
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; font-size: 13px; color: var(--text-secondary);
}
.pagination .btn{ width: auto; padding: 6px 14px; }
