:root {
  --black: #000000;
  --dark: #050505;
  --gray-900: #1f1f1f;
  --gray-700: #333333;
  --gray-500: #6b6b6b;
  --gray-300: #d0d0d0;
  --gray-200: #e6e6e6;
  --gray-100: #f5f5f5;
  --white: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--white);
  color: var(--black);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; }

a { color: inherit; }

/* ---------- Login ---------- */
.login-body { background: var(--white); }

.login-screen {
  display: flex;
  min-height: 100vh;
}

.login-hero {
  flex: 1 1 50%;
  background: var(--dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
}

.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.login-hero-copy h1 {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  max-width: 480px;
  margin: 0 0 16px;
}

.login-hero-copy p {
  font-size: 17px;
  color: #d0d0d0;
  max-width: 420px;
  margin: 0;
}

.login-form-wrap {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.login-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-form h2 { margin: 0 0 6px; font-size: 24px; font-weight: 700; }

.muted { color: var(--gray-500); font-size: 14px; margin: 0; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field label { font-size: 13px; font-weight: 500; color: var(--gray-700); }

input[type="email"], input[type="password"], input[type="text"], input[type="tel"], input[type="date"], textarea, select {
  height: 46px;
  box-sizing: border-box;
  padding: 0 14px;
  background: var(--gray-100);
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  color: var(--black);
  font-size: 15px;
}

textarea { height: auto; padding: 12px 14px; resize: vertical; }

input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
}

.error-text { color: #c0392b; font-size: 13px; min-height: 18px; margin: 0; }

.btn-primary {
  height: 48px;
  padding: 0 20px;
  background: var(--black);
  border: 0;
  border-radius: 10px;
  color: var(--white);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-block { width: 100%; }

.btn-secondary {
  height: 44px;
  padding: 0 16px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 10px;
  color: var(--black);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

@media (max-width: 860px) {
  .login-screen { flex-direction: column; }
  .login-hero { padding: 32px 24px; }
  .login-hero-copy h1 { font-size: 30px; }
}

/* ---------- Panel layout ---------- */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  height: 100%;
  background: var(--dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 24px 16px 20px;
  overflow-y: auto;
}

.sidebar .brand { padding: 0 12px 28px; }

.sidebar-label {
  padding: 0 12px 8px;
  font-size: 12px;
  font-weight: 500;
  color: #9a9a9a;
}

.client-list { display: flex; flex-direction: column; gap: 4px; }

.client-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #b5b5b5;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.client-item .count { font-size: 12px; color: #9a9a9a; }
.client-item.active { background: var(--gray-900); color: var(--white); font-weight: 600; }
.client-item:hover:not(.active) { background: #141414; }

.account-box { padding: 0 12px; }
.account-box .name { font-size: 16px; font-weight: 600; }

.sidebar-spacer { flex-grow: 1; }

.sidebar-link {
  display: flex;
  align-items: center;
  height: 42px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  border-radius: 10px;
}
.sidebar-link:hover { background: #141414; }

main.content {
  flex-grow: 1;
  min-width: 0;
  height: 100%;
  padding: 28px 28px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 20px;
}

.content-header h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.content-header .subtitle { margin: 4px 0 0; font-size: 14px; color: var(--gray-500); }

.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 190px;
  height: 44px;
  padding: 0 14px;
  background: var(--gray-100);
  border: 1px solid #e0e0e0;
  border-radius: 10px;
}
.search-box input { flex-grow: 1; min-width: 0; background: transparent; border: 0; outline: 0; font-size: 14px; height: auto; padding: 0; }
.search-box svg { flex-shrink: 0; }

.view-toggle {
  display: flex;
  height: 44px;
  border: 1px solid var(--gray-300);
  border-radius: 10px;
  overflow: hidden;
}
.view-toggle button {
  width: 44px;
  border: 0;
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.view-toggle button.active { background: var(--black); color: var(--white); }

.filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 16px;
}

.status-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.status-tab {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.status-tab .n { margin-left: 6px; opacity: 0.7; }
.status-tab.active { background: var(--black); color: var(--white); }

#range-select {
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.custom-range { display: none; align-items: center; gap: 10px; padding-bottom: 16px; font-size: 13px; color: var(--gray-500); }
.custom-range.visible { display: flex; }
.custom-range input { height: 38px; }

.list-scroll { flex-grow: 1; min-height: 0; overflow-y: auto; padding-bottom: 24px; }

.day-header { padding: 16px 4px 6px; font-size: 13px; font-weight: 600; }
.day-header:first-child { padding-top: 0; }

.lead-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr) minmax(0, 1.6fr) 64px 118px;
  gap: 16px;
  align-items: center;
  width: 100%;
  height: 62px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--black);
}
.lead-row.no-client-col { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1.8fr) 64px 118px; }
.lead-row:hover { background: var(--gray-100); }
.lead-row.selected { background: #f2f2f2; box-shadow: inset 0 0 0 1px var(--black); }
.lead-row .name { font-size: 14px; font-weight: 600; }
.lead-row .phone { font-size: 13px; color: var(--gray-500); }
.lead-row .cell { font-size: 14px; color: var(--gray-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-row .time { font-size: 13px; color: var(--gray-500); }

.list-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr) minmax(0, 1.6fr) 64px 118px;
  gap: 16px;
  padding: 0 14px 10px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
}
.list-head.no-client-col { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1.8fr) 64px 118px; }

.cards-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .cards-grid { grid-template-columns: 1fr; } }

.lead-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid #ececec;
  border-radius: 14px;
  background: var(--white);
  text-align: left;
  cursor: pointer;
}
.lead-card:hover { background: #f7f7f7; }
.lead-card.selected { box-shadow: inset 0 0 0 2px var(--black); border-color: transparent; }
.lead-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.lead-card .name { font-size: 15px; font-weight: 600; }
.lead-card .phone { font-size: 13px; color: var(--gray-500); }
.lead-card-body { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid #ececec; }
.lead-card-body .q { font-size: 12px; color: var(--gray-500); }
.lead-card-body .a { font-size: 14px; }
.lead-card-foot { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--gray-500); }

.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-nuevo { background: var(--black); color: var(--white); }
.pill-contactado { background: var(--white); color: var(--black); box-shadow: inset 0 0 0 1px var(--black); }
.pill-cita { background: #cfcfcf; color: var(--black); }
.pill-descartado { background: #f0f0f0; color: var(--gray-500); }

.empty-state { padding: 64px 16px; text-align: center; }
.empty-state p.title { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.empty-state p.hint { margin: 0 0 20px; font-size: 14px; color: var(--gray-500); }

/* ---------- Detail panel ---------- */
aside.detail {
  width: 340px;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  background: var(--white);
  border-left: 1px solid var(--gray-200);
  padding: 28px;
}

.detail-empty { padding: 48px 0; text-align: center; }
.detail-empty p.title { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.detail-empty p.hint { margin: 0; font-size: 14px; color: var(--gray-500); }

.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.avatar { flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%; background: var(--black); color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; }
.detail-head h2 { margin: 0; font-size: 19px; font-weight: 600; }
.detail-head .meta { margin: 2px 0 0; font-size: 13px; color: var(--gray-500); }

.detail-section { margin-bottom: 24px; }
.detail-section h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--gray-500); }

.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.status-opt { height: 42px; border: 0; border-radius: 10px; font-size: 14px; cursor: pointer; background: var(--white); color: var(--black); box-shadow: inset 0 0 0 1px var(--gray-300); font-weight: 500; }
.status-opt.active { background: var(--black); color: var(--white); font-weight: 600; box-shadow: none; }

.contact-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.contact-actions a { display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border-radius: 10px; font-size: 14px; font-weight: 600; text-decoration: none; }
.contact-actions a.call { background: var(--black); color: var(--white); }
.contact-actions a.mail { border: 1px solid var(--gray-300); color: var(--black); font-weight: 500; }
.contact-lines { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.contact-lines .sub { color: var(--gray-500); }

.answer-item { padding: 10px 0; border-top: 1px solid var(--gray-200); }
.answer-item .q { font-size: 12px; color: var(--gray-500); }
.answer-item .a { margin-top: 2px; font-size: 15px; }

/* ---------- Modal (nuevo lead de prueba) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center; z-index: 20; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
  background: var(--white); border-radius: 16px; padding: 28px;
  display: flex; flex-direction: column; gap: 18px;
}
.modal-box h2 { margin: 0; font-size: 20px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }

/* ---------- Responsive: mobile ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 15; left: -260px; transition: left 0.2s; width: 232px; }
  .sidebar.open { left: 0; }
  main.content { padding: 20px 16px 0; }
  aside.detail {
    position: fixed; inset: 0; z-index: 18; width: 100%; padding: 20px;
    display: none;
  }
  aside.detail.open { display: block; }
  #menu-btn, #close-detail-btn { display: inline-flex !important; align-items: center; }
  main.content { padding-top: 64px; }
  .lead-row { grid-template-columns: minmax(0, 1.6fr) 90px; }
  .lead-row .cell:nth-child(2), .lead-row .cell:nth-child(3), .lead-row .time { display: none; }
  .list-head { display: none; }
}
