:root {
  --sidebar-bg: #111a2e;
  --sidebar-bg-hover: #1c2942;
  --accent: #2563eb;
  --accent-2: #0d9488;
  --bg-app: #f4f6fb;
  --border-color: #e5e9f2;
  --text-main: #1f2937;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  margin: 0;
}

/* ---------- LAYOUT ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; flex-shrink: 0;
}
.brand-title { display:block; font-weight: 800; font-size: 17px; color: #fff; line-height:1.2; }
.brand-sub { display:block; font-size: 11px; color: #94a3b8; letter-spacing:.03em; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav .nav-link, .sidebar-footer .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 4px;
  border-radius: 10px; color: #cbd5e1 !important;
  font-size: 14.5px; font-weight: 500;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-link i, .sidebar-footer .nav-link i { font-size: 17px; width: 20px; text-align:center; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-bg-hover); color: #fff !important; }
.sidebar-nav .nav-link.active { background: var(--accent); color: #fff !important; }
.sidebar-footer { padding: 14px 12px; border-top: 1px solid rgba(255,255,255,.08); }

.main-content { margin-left: 260px; flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--border-color);
  padding: 16px 28px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 500;
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; flex: 1; }
.btn-toggle-sidebar { background:none; border:none; font-size:22px; color:var(--text-main); }
.topbar-user { display:flex; align-items:center; gap:10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:13px;
}
.user-avatar-lg {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:24px;
}
.user-name { font-weight:600; font-size:14px; }
.badge-role { font-size: 11px; padding: 4px 10px; border-radius: 20px; font-weight:600; }
.role-admin { background:#eef2ff; color:#4338ca; }
.role-agente { background:#ecfdf5; color:#047857; }

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

/* ---------- PANELES / TARJETAS ---------- */
.panel { background:#fff; border:1px solid var(--border-color); border-radius: 14px; margin-bottom: 0; overflow:hidden; }
.panel-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color); font-weight:700; font-size:15px; }
.panel-body { padding: 20px; }

.stat-card {
  background:#fff; border-radius:14px; padding: 20px; border:1px solid var(--border-color);
  position:relative; overflow:hidden;
}
.stat-icon { font-size: 22px; width:44px; height:44px; border-radius:12px; display:flex; align-items:center; justify-content:center; margin-bottom:12px; }
.stat-value { font-size: 28px; font-weight: 800; line-height:1; }
.stat-label { font-size: 13px; color:#6b7280; margin-top:6px; font-weight:500; }
.stat-blue .stat-icon { background:#eff6ff; color:#2563eb; }
.stat-green .stat-icon { background:#ecfdf5; color:#059669; }
.stat-amber .stat-icon { background:#fffbeb; color:#d97706; }
.stat-red .stat-icon { background:#fef2f2; color:#dc2626; }

.ingresos-total { font-size: 32px; font-weight: 800; color: var(--accent-2); }

/* ---------- AUTH (login/setup) ---------- */
.auth-body {
  min-height: 100vh; display:flex; align-items:center; justify-content:center;
  background: linear-gradient(135deg, #111a2e 0%, #1e3a5f 100%);
  font-family: 'Inter', sans-serif; padding: 20px;
}
.auth-card { background:#fff; border-radius:16px; padding: 36px; width:100%; max-width:420px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-logo { text-align:center; margin-bottom: 24px; }
.auth-logo h2 { font-weight:800; margin: 10px 0 2px; }
.auth-logo .brand-icon { margin: 0 auto 8px; }

/* ---------- TABLAS ---------- */
.table thead th { font-size:12px; text-transform:uppercase; letter-spacing:.03em; color:#6b7280; border-bottom-width:1px; background:#f9fafb; }
.table td, .table th { padding: 13px 16px; vertical-align:middle; }

/* ---------- LISTA SIMPLE (dashboard) ---------- */
.list-simple { list-style:none; margin:0; padding:0; }
.list-simple li { border-bottom: 1px solid var(--border-color); }
.list-simple li:last-child { border-bottom:none; }
.list-simple a { display:block; padding: 13px 20px; text-decoration:none; color: var(--text-main); }
.list-simple a:hover { background:#f9fafb; }

/* ---------- DETALLE CLIENTE ---------- */
.detail-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding: 8px 0; font-size:14px; border-bottom:1px dashed var(--border-color); }
.detail-row:last-child { border-bottom:none; }
.detail-row i { color:#94a3b8; margin-right:6px; }

/* ---------- TIMELINE ---------- */
.timeline { position:relative; padding-left: 8px; }
.timeline-item { display:flex; gap:14px; padding-bottom: 22px; position:relative; }
.timeline-item:not(:last-child)::before {
  content:''; position:absolute; left:17px; top:36px; bottom:-6px; width:2px; background: var(--border-color);
}
.timeline-icon {
  width:36px; height:36px; border-radius:50%; background:#eff6ff; color:var(--accent);
  display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:15px;
}
.timeline-content { flex:1; background:#f9fafb; border-radius:10px; padding: 10px 14px; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); box-shadow: 10px 0 40px rgba(0,0,0,.2); }
  .main-content { margin-left: 0; }
  .page-content { padding: 18px; }
  .topbar { padding: 14px 18px; }
}
