/* ─── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:       #1a3a5c;
  --brand-light: #2a5080;
  --accent:      #f0c040;
  --success:     #2d9e6b;
  --danger:      #d94040;
  --info:        #3a7fc1;
  --bg:          #f4f6f9;
  --card-bg:     #ffffff;
  --text:        #1c2b3a;
  --muted:       #6b7c93;
  --border:      #d8e0ea;
  --radius:      10px;
  --shadow:      0 2px 8px rgba(26,58,92,.10);
  --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Topbar ───────────────────────────────────────────────────────────── */
.topbar {
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--accent);
}
.topnav { display: flex; gap: .5rem; }
.nav-link {
  color: rgba(255,255,255,.85);
  padding: .35rem .7rem;
  border-radius: 6px;
  font-size: .9rem;
  transition: background .15s;
}
.nav-link:hover, .nav-link.active {
  background: var(--brand-light);
  color: #fff;
  text-decoration: none;
}

/* ─── Main content ─────────────────────────────────────────────────────── */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

/* ─── Alerts / flash ───────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .92rem;
}
.alert-success { background: #d4f5e7; color: #1a6040; border: 1px solid #a8e5cc; }
.alert-error   { background: #fde8e8; color: #8b1f1f; border: 1px solid #f5b8b8; }
.alert-info    { background: #ddeeff; color: #1a3d6b; border: 1px solid #b3d1f5; }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .55rem 1.1rem;
  border-radius: 7px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
  line-height: 1.3;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { opacity: .75; }

.btn-primary  { background: var(--brand);   color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-outline  { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-ghost    { background: transparent; color: var(--muted); }
.btn-block    { width: 100%; }
.btn-sm       { padding: .35rem .75rem; font-size: .82rem; }
.btn-lg       { padding: .7rem 1.5rem; font-size: 1rem; }

/* ─── Forms ────────────────────────────────────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.field-group label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.field-group input,
.field-group select,
.field-group textarea {
  padding: .6rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: .95rem;
  color: var(--text);
  background: #fff;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,58,92,.15);
}
.field-group textarea { resize: vertical; min-height: 70px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .9rem 1rem;
}
.field-group--full { grid-column: 1 / -1; }

/* ─── Login ────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.login-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: .75rem;
}
.login-title {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--brand);
  margin-bottom: .25rem;
}
.login-subtitle {
  text-align: center;
  font-size: .88rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.login-form { display: flex; flex-direction: column; gap: 1rem; }

/* ─── Page header ──────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.1rem;
}
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand);
}
.back-link {
  font-size: .88rem;
  color: var(--muted);
  padding: .3rem .5rem;
  border-radius: 6px;
  transition: background .15s;
}
.back-link:hover { background: var(--border); text-decoration: none; }
.lead-id-badge {
  font-size: .8rem;
  background: var(--border);
  color: var(--muted);
  padding: .15rem .55rem;
  border-radius: 20px;
  font-weight: 600;
}

/* ─── Badge ────────────────────────────────────────────────────────────── */
.badge {
  background: var(--accent);
  color: var(--brand);
  font-size: .75rem;
  font-weight: 700;
  padding: .1rem .5rem;
  border-radius: 20px;
  vertical-align: middle;
}

/* ─── Chips ────────────────────────────────────────────────────────────── */
.chip {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.chip-buyer    { background: #ddeeff; color: #1a3d6b; }
.chip-seller   { background: #fff3cc; color: #7a5200; }
.chip-lessee   { background: #e8f5e9; color: #1a6040; }
.chip-lessor   { background: #fce4ec; color: #8b1f40; }
.chip-status   {}
.chip-active   { background: #d4f5e7; color: #1a6040; }
.chip-archived { background: #f3f3f3; color: #888; }

/* ─── Search ───────────────────────────────────────────────────────────── */
.search-form { margin-bottom: 1rem; }
.search-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 180px;
  padding: .55rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: .95rem;
  background: #fff;
}
.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,58,92,.12);
}

/* ─── Leads table ──────────────────────────────────────────────────────── */
.leads-table-wrap {
  overflow-x: auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.leads-table thead th {
  background: var(--brand);
  color: rgba(255,255,255,.9);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .65rem .85rem;
  text-align: left;
  white-space: nowrap;
}
.leads-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.leads-table tbody tr:last-child { border-bottom: none; }
.leads-table tbody tr:hover { background: #f0f5fb; }
.leads-table td { padding: .65rem .85rem; vertical-align: top; }

.col-id    { color: var(--muted); font-size: .82rem; width: 50px; }
.col-name  { min-width: 140px; }
.col-phone { white-space: nowrap; color: var(--muted); }
.col-role  { min-width: 130px; }
.col-status{ min-width: 80px; }
.col-action{ width: 60px; text-align: right; }
.muted     { color: var(--muted); font-size: .82rem; }

/* ─── Pagination ───────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 1rem 0;
}
.page-info { font-size: .88rem; color: var(--muted); }

/* ─── Empty state ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

/* ─── Lead form sections ────────────────────────────────────────────────── */
.form-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0;
}
.slot-header .section-title { margin-bottom: 0; }
.slot-toggle-icon {
  font-size: 1.2rem;
  color: var(--muted);
  font-weight: 700;
  line-height: 1;
  padding: 0 .25rem;
}
.slot-body { margin-top: 1rem; }
.slot-collapsed { display: none; }

.form-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .75rem 0 1.5rem;
}

/* ─── Danger zone ──────────────────────────────────────────────────────── */
.danger-zone {
  background: #fff5f5;
  border: 1.5px solid #f5b8b8;
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1.5rem;
}
.danger-title { color: var(--danger); }

/* ─── Mobile tweaks ────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .topbar-inner { padding: .6rem .75rem; }
  .main-content { padding: .9rem .75rem 2.5rem; }
  .leads-table th, .leads-table td { padding: .5rem .6rem; }
  /* Hide same columns in thead and tbody so headers stay aligned with cells */
  .leads-table .col-phone,
  .leads-table .col-status { display: none; }
  .login-card { padding: 2rem 1.25rem; }
  .form-grid { grid-template-columns: 1fr; }
}
