/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg:        #080f1a;
  --surface:   #0d1a2b;
  --surface-2: #132236;
  --border:    #1e3450;
  --text:      #daeeff;
  --muted:     #6a8aaa;
  --accent:    #0ea5e9;
  --accent-dk: #0369a1;
  --high:      #f43f5e;
  --mid:       #f59e0b;
  --low:       #22c55e;
  --wa:        #25d366;
  --radius:    10px;
  --radius-sm: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar layout ─────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
}

.sidebar__brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 40px; height: 40px;
  background: #ffffff;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 3px;
}

.brand-name { font-size: .95rem; font-weight: 800; color: #fff; }
.brand-sub  { font-size: .65rem; color: var(--muted); }

.sidebar__nav { padding: 12px 8px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(14,165,233,.15); color: var(--accent); }
.nav-item__icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar__footer {
  padding: 14px 10px;
  border-top: 1px solid var(--border);
}

/* ── Main content ───────────────────────────────────────────── */
.content {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar__title { font-size: 1rem; font-weight: 700; flex: 1; }

.page-body { padding: 28px; flex: 1; }

/* ── Alerts (flash) ─────────────────────────────────────────── */
.alerts { padding: 0 28px; }

.alert {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert--success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #86efac; }
.alert--error   { background: rgba(244,63,94,.12);  border: 1px solid rgba(244,63,94,.3);  color: #fca5a5; }

/* ── Stats grid ─────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat--total::before   { background: var(--accent); }
.stat--alta::before    { background: var(--high); }
.stat--media::before   { background: var(--mid); }
.stat--baja::before    { background: var(--low); }
.stat--pendiente::before   { background: #94a3b8; }
.stat--contactado::before  { background: var(--accent); }
.stat--interesado::before  { background: #a78bfa; }
.stat--cliente::before     { background: var(--low); }

.stat__value { font-size: 1.8rem; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat__label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.stat--total .stat__value      { color: var(--accent); }
.stat--alta .stat__value       { color: var(--high); }
.stat--media .stat__value      { color: var(--mid); }
.stat--baja .stat__value       { color: var(--low); }
.stat--pendiente .stat__value  { color: #94a3b8; }
.stat--contactado .stat__value { color: var(--accent); }
.stat--interesado .stat__value { color: #a78bfa; }
.stat--cliente .stat__value    { color: var(--low); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none !important;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }
.btn:hover  { opacity: .88; }

.btn--primary  { background: var(--accent);    color: #fff; }
.btn--danger   { background: var(--high);      color: #fff; }
.btn--wa       { background: var(--wa);        color: #fff; }
.btn--ghost    { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn--sm       { padding: 6px 12px; font-size: .78rem; }

/* ── Filter bar ─────────────────────────────────────────────── */
.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.filterbar input,
.filterbar select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: .84rem;
  outline: none;
  transition: border-color .15s;
}

.filterbar input:focus,
.filterbar select:focus { border-color: var(--accent); }

.filterbar input::placeholder { color: var(--muted); }

.filterbar input[type="text"] { flex: 1; min-width: 180px; }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--surface-2);
  padding: 11px 14px;
  text-align: left;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

tbody td { padding: 11px 14px; font-size: .85rem; vertical-align: middle; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}

.badge--high    { background: rgba(244,63,94,.15);  color: var(--high); }
.badge--mid     { background: rgba(245,158,11,.15); color: var(--mid); }
.badge--low     { background: rgba(34,197,94,.15);  color: var(--low); }

.badge--pendiente     { background: rgba(148,163,184,.12); color: #94a3b8; }
.badge--contactado    { background: rgba(14,165,233,.15);  color: var(--accent); }
.badge--interesado    { background: rgba(167,139,250,.15); color: #a78bfa; }
.badge--sin_respuesta { background: rgba(245,158,11,.12);  color: var(--mid); }
.badge--no_interesado { background: rgba(244,63,94,.12);   color: #fca5a5; }
.badge--reagendar     { background: rgba(251,146,60,.12);  color: #fb923c; }
.badge--cliente       { background: rgba(34,197,94,.15);   color: var(--low); }

.badge--riesgo-alto   { background: rgba(244,63,94,.1);  color: #fca5a5; }
.badge--riesgo-medio  { background: rgba(245,158,11,.1); color: #fcd34d; }
.badge--tipo          { background: var(--surface-2); color: var(--muted); }

/* ── Score bar (inline) ─────────────────────────────────────── */
.score-cell { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.score-bar  { flex: 1; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 2px; }
.score-fill--high { background: var(--high); }
.score-fill--mid  { background: var(--mid); }
.score-fill--low  { background: var(--low); }
.score-num  { font-size: .8rem; font-weight: 700; width: 26px; text-align: right; }
.score-num--high { color: var(--high); }
.score-num--mid  { color: var(--mid); }
.score-num--low  { color: var(--low); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.page-btn {
  padding: 7px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .82rem;
  cursor: pointer;
  text-decoration: none !important;
  transition: all .15s;
}

.page-btn:hover { border-color: var(--accent); color: var(--text); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* ── Detail layout ──────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.card__title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 16px;
  font-weight: 600;
}

.info-row {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}

.info-row:last-child { border-bottom: none; }
.info-row__label { color: var(--muted); width: 130px; flex-shrink: 0; }

/* ── Form ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-control {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: .875rem;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}

.form-control:focus { border-color: var(--accent); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Message box ────────────────────────────────────────────── */
.msg-box {
  background: var(--surface-2);
  border-left: 3px solid var(--wa);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
  font-size: .82rem;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Razones score ──────────────────────────────────────────── */
.razones {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.8;
}

/* ── History timeline ───────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 10px; }

.timeline-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: .82rem;
}

.timeline-item__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.timeline-item__date   { font-size: .72rem; color: var(--muted); }

/* ── Funnel bars (reportes) ─────────────────────────────────── */
.funnel-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.funnel-bar__label { width: 120px; font-size: .82rem; color: var(--muted); }
.funnel-bar__track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.funnel-bar__fill  { height: 100%; border-radius: 4px; background: var(--accent); }
.funnel-bar__count { width: 36px; text-align: right; font-size: .82rem; font-weight: 700; }

/* ── Activity feed ──────────────────────────────────────────── */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .83rem;
}

.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.activity-meta { color: var(--muted); font-size: .74rem; margin-top: 2px; }

/* ── Stars ──────────────────────────────────────────────────── */
.stars { color: #fbbf24; }

/* ── Misc ───────────────────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-high   { color: var(--high); }
.text-mid    { color: var(--mid); }
.text-low    { color: var(--low); }
.text-accent { color: var(--accent); }

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state__icon { font-size: 2.5rem; margin-bottom: 10px; }

@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar .brand-name, .sidebar .brand-sub, .nav-item span { display: none; }
  .content { margin-left: 60px; }
  .detail-grid { grid-template-columns: 1fr; }
}
