:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1c1f26;
  --text-muted: #6b7280;
  --border: #e3e5e9;
  --primary: #1f3a5f;
  --primary-hover: #16294a;
  --accent: #2b8a3e;
  --danger: #c0392b;
  --radius: 10px;
  font-family: "DM Sans", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
}

/* ── Login ─────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 320px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  text-align: center;
}
.login-logo { font-size: 36px; margin-bottom: 8px; }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.login-input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.login-btn {
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.login-btn:hover { background: var(--primary-hover); }
.login-err { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ── Topbar ────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.conteo { font-size: 13px; color: var(--text-muted); margin-right: 6px; }

.btn-secondary, .btn-primary {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-block;
}
.btn-secondary { background: #eef0f3; color: var(--text); }
.btn-secondary:hover { background: #e2e5ea; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary[disabled], .btn-secondary[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ── Layout ────────────────────────────────────────── */
.layout { display: flex; align-items: flex-start; }

.filtros {
  width: 220px;
  flex-shrink: 0;
  padding: 20px 16px;
  position: sticky;
  top: 0;
}
.filtro-grupo { margin-bottom: 22px; }
.filtro-titulo { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.03em; }
.filtro-check { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 3px 0; cursor: pointer; }
.filtro-check input { cursor: pointer; }
#filtro-estado {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 13px;
}

.cards-container {
  flex: 1;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  align-content: start;
}

.cargando { color: var(--text-muted); padding: 40px; grid-column: 1 / -1; text-align: center; }

/* ── Card ──────────────────────────────────────────── */
.lead-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lead-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.lead-empresa { font-weight: 700; font-size: 15px; }
.lead-estrellas { font-size: 12px; color: #d4a017; white-space: nowrap; }
.lead-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
  color: #fff;
}
.badge-fuente-elconciso { background: #2b6cb0; }
.badge-fuente-andaluciatrade { background: #2f855a; }
.badge-fuente-aesanrgseaa { background: #b7791f; }
.badge-fuente-aesanue { background: #b83280; }
.badge-fuente-landaluz { background: #6b46c1; }
.badge-provincia { background: #4a5568; }
.badge-fecha { background: #a0aec0; }
.lead-resumen { font-size: 13px; color: var(--text); line-height: 1.4; }
.lead-estado-select {
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-family: inherit;
}
.lead-footer { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; border-top: 1px dashed var(--border); padding-top: 10px; }
.lead-email-row { display: flex; gap: 6px; }
.lead-email-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
}
.lead-acciones { display: flex; gap: 6px; }
.lead-acciones button { flex: 1; }

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  width: 520px;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.modal-close { border: none; background: none; font-size: 16px; cursor: pointer; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.modal-body label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-top: 8px; }
.draft-input, .draft-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .filtros { width: 100%; position: static; }
}
