/* Sellinc CRM — estilos (mobile-first) */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --primary: #0f172a;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 4px 16px rgba(15,23,42,.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 60%, #334155 100%);
}
.login-card {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow);
  padding: 32px 28px; width: 100%; max-width: 380px;
}
.brand { text-align: center; margin-bottom: 24px; }
.brand h1 { font-size: 22px; margin-top: 10px; }
.brand p { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px; margin: 0 auto;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark.small { width: 30px; height: 30px; font-size: 16px; border-radius: 9px; margin: 0; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 14px; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { resize: vertical; min-height: 70px; }

.btn {
  border: none; border-radius: 10px; padding: 11px 16px; font-size: 15px;
  font-weight: 600; cursor: pointer; font-family: inherit;
  transition: opacity .15s;
}
.btn:active { opacity: .7; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.error { color: var(--red); font-size: 13px; margin-top: 10px; text-align: center; }

/* ---------- Layout app ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.topbar-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.topbar-actions { display: flex; gap: 8px; }

main {
  padding: 16px;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  max-width: 1100px; margin: 0 auto;
}

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav button {
  flex: 1; background: none; border: none; padding: 8px 0 10px;
  font-size: 11px; font-weight: 600; color: var(--ink-3); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bottomnav button .ico { font-size: 20px; }
.bottomnav button.active { color: var(--accent); }

/* ---------- Tarjetas / secciones ---------- */
.section { margin-bottom: 22px; }
.section h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin-bottom: 10px; }
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
}
.card:hover { outline: 1px solid var(--line); }
.card .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .nombre { font-weight: 700; }
.card .meta { color: var(--ink-2); font-size: 13px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px 14px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; text-align: center;
}
.stat .num { font-size: 26px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.pill {
  display: inline-block; padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent);
}
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.dim { background: var(--line); color: var(--ink-2); }

.empty { color: var(--ink-3); font-size: 14px; padding: 18px; text-align: center; }

/* ---------- Pipeline (kanban) ---------- */
.kanban {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
.kcol {
  min-width: 250px; max-width: 280px; flex: 0 0 auto; scroll-snap-align: start;
  background: #e9eef5; border-radius: var(--radius); padding: 10px;
}
.kcol h4 {
  font-size: 13px; display: flex; justify-content: space-between; align-items: center;
  padding: 4px 6px 10px; color: var(--ink-2);
}
.kcol .card { padding: 10px 12px; margin-bottom: 8px; }
.kcol .card .nombre { font-size: 14px; }
.kcol .card .meta { font-size: 12px; }

/* ---------- Filtros ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; flex: 1; min-width: 130px; margin-top: 0; }

/* ---------- Ficha de lead ---------- */
.lead-head { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.lead-head .nombre { font-size: 20px; font-weight: 800; }
.lead-head .contacto { margin: 8px 0; display: flex; gap: 10px; flex-wrap: wrap; }
.lead-head .contacto a {
  text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 10px; background: var(--green-soft); color: var(--green);
}
.lead-head .contacto a.tel { background: var(--accent-soft); color: var(--accent); }
.datos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 10px; font-size: 14px; }
.datos .d label { font-size: 11px; color: var(--ink-3); font-weight: 700; text-transform: uppercase; margin: 0; }
.datos .d div { color: var(--ink); }

.accion-box {
  border: 1.5px dashed var(--amber); background: var(--amber-soft);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 14px;
}
.accion-box b { display: block; font-size: 12px; text-transform: uppercase; color: var(--amber); margin-bottom: 4px; }

/* Caja de conexión personal (intereses del lead) */
.conexion-box {
  border: 1.5px solid var(--purple); background: var(--purple-soft);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 14px;
}
.conexion-box b { display: block; font-size: 12px; text-transform: uppercase; color: var(--purple); margin-bottom: 4px; }
.conexion-box .hint { font-size: 12px; color: var(--ink-2); margin-top: 6px; font-style: italic; }
.conexion-box .btn { margin-top: 8px; }

.timeline { list-style: none; }
.timeline li {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
  padding: 12px 14px; margin-bottom: 8px;
}
.timeline .t-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.timeline .t-body { font-size: 14px; white-space: pre-wrap; }
.timeline li.wa-in { border-left: 3px solid var(--green); }
.timeline li.wa-out { border-left: 3px solid var(--accent); }
.timeline li.llamada { border-left: 3px solid var(--amber); }
.timeline li.visita { border-left: 3px solid #7c3aed; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }

.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0; padding: 20px;
  max-height: 88dvh; overflow-y: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h2 { font-size: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px;
  font-size: 14px; font-weight: 600; z-index: 100; box-shadow: var(--shadow);
  max-width: 90vw; text-align: center;
}

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  body { font-size: 15px; }
  .stats { grid-template-columns: repeat(3, 220px); }
  .bottomnav {
    top: 9px; bottom: auto; left: 50%; right: auto; transform: translateX(-50%);
    background: none; border: none;
    flex-direction: row; gap: 4px; width: auto;
    position: fixed; z-index: 30; padding: 0;
  }
  .bottomnav button { flex-direction: row; gap: 6px; font-size: 13px; padding: 8px 14px; border-radius: 8px; }
  .bottomnav button.active { background: var(--accent-soft); }
  .bottomnav button .ico { font-size: 15px; }
}
