/* iTrack CRM · Estilos globales */
:root {
  --navy: #201B3A;
  --navy-light: #2d2756;
  --navy-card: #2a2548;
  --green: #3EB489;
  --green-dark: #2a9070;
  --white: #fff;
  --gray: #8b8b9a;
  --muted: #b0b0c0;
  --border: rgba(62,180,137,0.18);
  --red: #e05c5c;
  --amber: #f5a623;
  --blue: #4a90d9;
  --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Barlow', sans-serif;
  background: #181530;
  color: var(--white);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: transform .3s;
}
.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-brand img { height: 34px; object-fit: contain; }
.sidebar-brand-text { font-size: 11px; color: var(--green); font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 0; }
.nav-section { font-size: 10px; font-weight: 700; color: var(--gray); letter-spacing: .2em; text-transform: uppercase; padding: 12px 20px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 20px; color: var(--muted);
  text-decoration: none; font-size: 14px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .18s;
}
.nav-item:hover { color: var(--white); background: rgba(255,255,255,.04); }
.nav-item.active { color: var(--green); border-left-color: var(--green); background: rgba(62,180,137,.07); font-weight: 700; }
.nav-item .icon { font-size: 17px; flex-shrink: 0; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--green); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 700; line-height: 1.2; }
.user-role { font-size: 11px; color: var(--green); text-transform: uppercase; letter-spacing: .08em; }
.btn-logout-sm {
  margin-left: auto; background: transparent; border: none; color: var(--gray);
  cursor: pointer; font-size: 18px; transition: color .18s; padding: 4px;
}
.btn-logout-sm:hover { color: var(--red); }

/* ── LAYOUT ── */
.app-wrapper { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(32,27,58,.95); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px); padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-title { font-size: 18px; font-weight: 800; }
.topbar-title span { color: var(--green); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.page-content { flex: 1; padding: 28px 32px; }

/* ── CARDS ── */
.card {
  background: var(--navy-card); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
}
.card-header {
  padding: 18px 24px; border-bottom: 1px solid rgba(255,255,255,.05);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 800; }
.card-body { padding: 24px; }

/* ── STAT CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--navy-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px 24px;
  display: flex; align-items: flex-start; gap: 16px;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.green  { background: rgba(62,180,137,.15); }
.stat-icon.amber  { background: rgba(245,166,35,.15); }
.stat-icon.blue   { background: rgba(74,144,217,.15); }
.stat-icon.red    { background: rgba(224,92,92,.15); }
.stat-value { font-size: 30px; font-weight: 900; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-trend { font-size: 12px; margin-top: 6px; }
.trend-up   { color: var(--green); }
.trend-down { color: var(--red); }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
td { padding: 13px 16px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.td-empresa { font-weight: 700; }
.td-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; letter-spacing: .04em;
}
.badge-green  { background: rgba(62,180,137,.15);  color: var(--green); }
.badge-amber  { background: rgba(245,166,35,.15);  color: var(--amber); }
.badge-blue   { background: rgba(74,144,217,.15);  color: var(--blue); }
.badge-red    { background: rgba(224,92,92,.15);   color: var(--red); }
.badge-gray   { background: rgba(255,255,255,.07); color: var(--muted); }

/* ── BOTONES ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: 'Barlow', sans-serif; font-size: 13px; font-weight: 700;
  padding: 9px 18px; border-radius: 8px; border: none;
  cursor: pointer; transition: all .2s; text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--green); color: var(--navy); }
.btn-primary:hover { background: #4ecf9e; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(62,180,137,.3); }
.btn-secondary { background: rgba(255,255,255,.06); color: var(--white); border: 1px solid rgba(255,255,255,.1); }
.btn-secondary:hover { background: rgba(255,255,255,.1); }
.btn-danger    { background: rgba(224,92,92,.12); color: var(--red); border: 1px solid rgba(224,92,92,.25); }
.btn-danger:hover { background: rgba(224,92,92,.2); }
.btn-sm { padding: 6px 13px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

/* ── FORMS ── */
.form-grid { display: grid; gap: 16px; }
.form-grid.two   { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.field label .req { color: var(--green); }
.field input, .field select, .field textarea {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; color: var(--white); font-family: 'Barlow', sans-serif;
  font-size: 14px; padding: 11px 14px; outline: none; width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--green); box-shadow: 0 0 0 3px rgba(62,180,137,.12);
  background: rgba(62,180,137,.04);
}
.field input::placeholder, .field textarea::placeholder { color: var(--gray); font-weight: 300; }
.field select { cursor: pointer; }
.field select option { background: var(--navy-light); }
.field textarea { resize: vertical; min-height: 90px; }
.field-hint { font-size: 11px; color: var(--gray); }

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal-backdrop.show { opacity: 1; pointer-events: all; }
.modal {
  background: var(--navy-card); border: 1px solid var(--border);
  border-radius: 18px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(30px) scale(.97);
  transition: transform .3s cubic-bezier(.22,1,.36,1);
}
.modal-backdrop.show .modal { transform: translateY(0) scale(1); }
.modal-lg { max-width: 760px; }
.modal-header {
  padding: 22px 28px 18px; border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--navy-card); z-index: 10;
}
.modal-title { font-size: 17px; font-weight: 900; }
.modal-body { padding: 24px 28px; }
.modal-footer {
  padding: 18px 28px; border-top: 1px solid rgba(255,255,255,.06);
  display: flex; gap: 10px; justify-content: flex-end;
}
.btn-close-modal {
  background: transparent; border: none; color: var(--muted);
  font-size: 22px; cursor: pointer; transition: color .18s; line-height: 1;
}
.btn-close-modal:hover { color: var(--white); }

/* ── ALERTS ── */
.alert {
  padding: 12px 18px; border-radius: 8px; font-size: 14px;
  font-weight: 600; margin-bottom: 16px; display: flex; gap: 10px; align-items: center;
}
.alert-success { background: rgba(62,180,137,.1); border: 1px solid rgba(62,180,137,.3); color: var(--green); }
.alert-error   { background: rgba(224,92,92,.1);  border: 1px solid rgba(224,92,92,.3);  color: var(--red); }
.alert-info    { background: rgba(74,144,217,.1); border: 1px solid rgba(74,144,217,.3); color: var(--blue); }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 20px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 10px; min-width: 260px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  transform: translateX(110%); opacity: 0;
  transition: all .35s cubic-bezier(.22,1,.36,1);
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.ok  { border-color: rgba(62,180,137,.5); }
.toast.err { border-color: rgba(224,92,92,.5); }

/* ── SEGUIMIENTO TIMELINE ── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 16px; padding-bottom: 20px; position: relative; }
.timeline-item:not(:last-child)::before {
  content: ''; position: absolute; left: 18px; top: 40px; bottom: 0;
  width: 1px; background: rgba(255,255,255,.08);
}
.timeline-dot {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; border: 2px solid rgba(255,255,255,.1);
  background: var(--navy);
}
.timeline-content { flex: 1; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06); border-radius: 10px; padding: 14px 18px; }
.timeline-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; flex-wrap: wrap; gap: 6px; }
.timeline-titulo { font-size: 14px; font-weight: 700; }
.timeline-fecha { font-size: 11px; color: var(--muted); }
.timeline-desc { font-size: 13px; color: var(--muted); line-height: 1.5; }
.timeline-proxima { font-size: 12px; color: var(--amber); margin-top: 8px; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 52px; opacity: .35; margin-bottom: 16px; }
.empty-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--white); }
.empty-desc { font-size: 14px; color: var(--muted); margin-bottom: 20px; }

/* ── SEARCH ── */
.search-bar { position: relative; }
.search-bar input { padding-left: 38px !important; }
.search-bar::before { content: '🔍'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; pointer-events: none; }

/* ── AVATAR COLORS ── */
.av-a { background: #3EB489; } .av-b { background: #4a90d9; }
.av-c { background: #e05c5c; } .av-d { background: #f5a623; }
.av-e { background: #9b59b6; } .av-f { background: #1abc9c; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .app-wrapper { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .topbar { padding: 12px 18px; }
  .page-content { padding: 18px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(62,180,137,.3); border-radius: 3px; }
