:root {
  --azul: #1f3b57;
  --azul-claro: #2f5d82;
  --verde: #2e7d5b;
  --rojo: #b5432c;
  --fondo: #f6f7f5;
  --texto: #232323;
  --borde: #d8dad4;
  --naranja: #c07c2c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--fondo);
  color: var(--texto);
}

.topbar {
  background: var(--azul);
  color: white;
  display: flex;
  align-items: center;
  padding: 0.8rem 1.5rem;
  gap: 2rem;
}
.topbar .brand { color: white; font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.topbar nav { display: flex; gap: 1.2rem; flex: 1; }
.topbar nav a { color: #d6e2ec; text-decoration: none; font-size: 0.95rem; }
.topbar nav a:hover { color: white; }
.logout-form button {
  background: none; border: 1px solid #ffffff55; color: white;
  padding: 0.3rem 0.8rem; border-radius: 4px; cursor: pointer;
}

.content { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

h1 { color: var(--azul); }
.muted { color: #777; font-size: 0.9rem; }
.error { color: var(--rojo); }

.cards { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1.5rem 0; }
.card {
  background: white; border: 1px solid var(--borde); border-radius: 6px;
  padding: 1rem 1.4rem; min-width: 160px;
}
.card-highlight { border-color: var(--azul); }
.card-num { display: block; font-size: 1.8rem; font-weight: 700; color: var(--azul); }
.card-label { font-size: 0.85rem; color: #666; text-transform: capitalize; }

.btn {
  display: inline-block; background: var(--azul); color: white;
  padding: 0.5rem 1rem; border-radius: 5px; text-decoration: none;
}

.tabla { width: 100%; border-collapse: collapse; margin-top: 1rem; background: white; }
.tabla th, .tabla td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--borde); font-size: 0.9rem; }
.tabla th { background: #eef1ee; }

.filtros { display: flex; gap: 0.6rem; margin-top: 1rem; }
.filtros input, .filtros select { padding: 0.5rem; border: 1px solid var(--borde); border-radius: 4px; }
.filtros button { padding: 0.5rem 1rem; border: none; background: var(--azul); color: white; border-radius: 4px; cursor: pointer; }

.badge {
  padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.78rem;
  background: #e3e7e1; text-transform: capitalize;
}
.badge-interesado, .badge-cerrado_ganado { background: #dcf0e4; color: var(--verde); }
.badge-no_interesa, .badge-opt_out, .badge-cerrado_perdido { background: #fbe3dd; color: var(--rojo); }
.badge-llamar_mas_tarde, .badge-en_conversacion { background: #fdf0dc; color: var(--naranja); }

.detalle-grid { display: grid; grid-template-columns: 320px 1fr; gap: 1.5rem; margin-top: 1rem; }
.ficha { background: white; border: 1px solid var(--borde); border-radius: 6px; padding: 1.2rem; }
.estado-form { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }
.estado-form label { font-size: 0.85rem; display: flex; flex-direction: column; gap: 0.2rem; }
.estado-form input, .estado-form select, .estado-form textarea { padding: 0.5rem; border: 1px solid var(--borde); border-radius: 4px; font-family: inherit; }
.estado-form button { background: var(--azul); color: white; border: none; padding: 0.5rem; border-radius: 4px; cursor: pointer; }

.conversacion { background: white; border: 1px solid var(--borde); border-radius: 6px; padding: 1.2rem; display: flex; flex-direction: column; }
.chat { display: flex; flex-direction: column; gap: 0.6rem; max-height: 55vh; overflow-y: auto; padding: 0.5rem; }
.burbuja { max-width: 75%; padding: 0.5rem 0.8rem; border-radius: 10px; font-size: 0.92rem; }
.burbuja p { margin: 0; }
.burbuja .hora { display: block; font-size: 0.7rem; color: #888; margin-top: 0.2rem; }
.burbuja-in { background: #eef1ee; align-self: flex-start; }
.burbuja-out { background: #dbe9f5; align-self: flex-end; }
.chat-form { display: flex; gap: 0.6rem; margin-top: 1rem; }
.chat-form textarea { flex: 1; padding: 0.5rem; border: 1px solid var(--borde); border-radius: 4px; font-family: inherit; }
.chat-form button { background: var(--azul); color: white; border: none; padding: 0 1.2rem; border-radius: 4px; cursor: pointer; }

.bloques { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.bloque-form { background: white; border: 1px solid var(--borde); border-radius: 6px; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.bloque-header { display: flex; justify-content: space-between; align-items: center; }
.clave-input { border: none; background: none; font-weight: 700; color: var(--azul); }
.bloque-form input, .bloque-form textarea { padding: 0.5rem; border: 1px solid var(--borde); border-radius: 4px; font-family: inherit; }
.bloque-acciones { display: flex; gap: 0.6rem; }
.bloque-acciones button { padding: 0.4rem 0.9rem; border-radius: 4px; border: none; cursor: pointer; background: var(--azul); color: white; }
.btn-danger { background: var(--rojo) !important; }

.regla-form { background: white; border: 1px solid var(--borde); border-radius: 6px; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.8rem; }
.regla-header { display: flex; justify-content: space-between; }
.regla-form input, .regla-form select, .regla-form textarea { padding: 0.5rem; border: 1px solid var(--borde); border-radius: 4px; font-family: inherit; }
.regla-form button { align-self: flex-start; background: var(--azul); color: white; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; }

.inline-form { display: flex; gap: 0.6rem; margin-top: 0.8rem; }
.inline-form input { padding: 0.5rem; border: 1px solid var(--borde); border-radius: 4px; }
.inline-form button { background: var(--azul); color: white; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; }

.switch { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }

.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--azul); }
.login-card { background: white; padding: 2rem; border-radius: 8px; width: 320px; display: flex; flex-direction: column; gap: 0.8rem; }
.login-card h1 { margin: 0; color: var(--azul); }
.login-card label { font-size: 0.85rem; display: flex; flex-direction: column; gap: 0.3rem; }
.login-card input { padding: 0.6rem; border: 1px solid var(--borde); border-radius: 4px; }
.login-card button { background: var(--azul); color: white; border: none; padding: 0.6rem; border-radius: 4px; cursor: pointer; font-size: 1rem; }
