:root {
  --bg: #0b1120;
  --surface: #131c2e;
  --surface-2: #1e293b;
  --border: #2a3a52;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --text: #e2e8f0;
  --muted: #94a3b8;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}
.loading { color: var(--muted); padding: 2rem; }
.avatar {
  width: 40px; height: 40px; border-radius: 10px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}

/* ---------- LOGIN ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1e1b4b 0%, #0b1120 60%);
  padding: 1rem;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 2.5rem; width: 100%; max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.brand { display: flex; align-items: center; gap: .7rem; justify-content: center; margin-bottom: .5rem; }
.brand i { font-size: 1.8rem; color: var(--primary-hover); }
.brand h1 { font-size: 1.6rem; font-weight: 800; }
.brand h1 span {
  background: linear-gradient(90deg,#818cf8,#c084fc);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.login-hint { color: var(--muted); text-align: center; margin-bottom: 1.6rem; font-size: .9rem; }
.user-grid { display: flex; flex-direction: column; gap: .7rem; }
.user-btn {
  display: flex; align-items: center; gap: .9rem; width: 100%;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: .8rem 1rem; cursor: pointer;
  color: var(--text); transition: all .15s; text-align: left;
}
.user-btn:hover { border-color: var(--primary); transform: translateY(-2px); background: #20304a; }
.user-info { flex: 1; display: flex; flex-direction: column; }
.user-info small { color: var(--muted); }
.user-btn > i { color: var(--muted); }

/* ---------- LAYOUT ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1.2rem; position: sticky; top: 0; height: 100vh;
}
.logo { font-size: 1.3rem; font-weight: 800; color: var(--primary-hover); margin-bottom: 1.8rem; }
.logo i { margin-right: .4rem; }
.sidebar nav { display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem;
  border-radius: 10px; color: var(--muted); cursor: pointer; transition: all .15s;
}
.nav-link i { width: 18px; text-align: center; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--primary); color: #fff; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 1rem; }
.me { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.me span:last-child { display: flex; flex-direction: column; font-size: .85rem; }
.me small { color: var(--muted); }
#logout-btn {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); padding: .6rem; border-radius: 10px; cursor: pointer; transition: all .15s;
}
#logout-btn:hover { color: #ef4444; border-color: #ef4444; }

.content { flex: 1; padding: 2rem; overflow-x: auto; }
.page-title { font-size: 1.5rem; margin-bottom: 1.4rem; }

/* ---------- CARDS ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.2rem; display: flex; align-items: center; gap: 1rem;
}
.stat-card .ic { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.stat-card .val { font-size: 1.5rem; font-weight: 700; display: block; }
.stat-card .lbl { color: var(--muted); font-size: .82rem; }

/* ---------- PANEL / TABLE ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.4rem; margin-bottom: 1.2rem; }
.panel h3 { margin-bottom: 1rem; font-size: 1.05rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: .7rem .6rem; border-bottom: 1px solid var(--border); font-size: .8rem; text-transform: uppercase; }
.tbl td { padding: .8rem .6rem; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: none; }
.tbl small { color: var(--muted); }

.badge { padding: .25rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.st-Cliente { background: #22c55e22; color: #22c55e; }
.st-Cualificado { background: #0ea5e922; color: #38bdf8; }
.st-Lead { background: #f59e0b22; color: #fbbf24; }
.st-Inactivo { background: #64748b22; color: #94a3b8; }
.stage-Ganado { background: #22c55e22; color: #22c55e; }
.stage-Perdido { background: #ef444422; color: #f87171; }
.stage-Negociación { background: #f59e0b22; color: #fbbf24; }
.stage-Propuesta { background: #0ea5e922; color: #38bdf8; }
.stage-Prospecto { background: #6366f122; color: #818cf8; }

.score { width: 70px; height: 6px; background: var(--surface-2); border-radius: 999px; display: inline-block; overflow: hidden; vertical-align: middle; margin-right: .4rem; }
.score-bar { height: 100%; background: linear-gradient(90deg,#6366f1,#22c55e); }

/* ---------- AI ---------- */
.ai-panel { border-left: 3px solid var(--primary); }
.ai-list { list-style: none; display: flex; flex-direction: column; gap: .8rem; }
.ai-list li { background: var(--surface-2); padding: .9rem 1rem; border-radius: 10px; }
.lead-row { display: flex; justify-content: space-between; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.lead-row:last-child { border-bottom: none; }
.lead-row small { color: var(--muted); }

/* ---------- TIMELINE ---------- */
.timeline { list-style: none; display: flex; flex-direction: column; gap: 1rem; }
.timeline li { display: flex; gap: 1rem; align-items: flex-start; }
.t-ic { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--primary-hover); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.timeline small { color: var(--muted); }

@media (max-width: 800px) {
  .sidebar { width: 70px; padding: 1rem .5rem; }
  .nav-link span, .logo, .me span:last-child, #logout-btn span { display: none; }
  .nav-link { justify-content: center; }
  .cols { grid-template-columns: 1fr; }
}
