@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --success: #10B981;
  --warning: #F59E0B;
  --danger:  #EF4444;
  --info:    #3B82F6;

  --bg:       #F8FAFC;
  --white:    #FFFFFF;
  --gray-50:  #F1F5F9;
  --gray-100: #E2E8F0;
  --gray-200: #CBD5E1;
  --gray-500: #64748B;
  --gray-900: #0F172A;

  --sidebar-w: 240px;
  --topbar-h:  56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--gray-900);
}
a { color: var(--primary); text-decoration: none; }

/* ─── TOPBAR ──────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
  z-index: 100; box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.topbar-burger {
  background: none; border: none; cursor: pointer;
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500); font-size: 1.2rem;
}
.topbar-burger:hover { background: var(--gray-50); }
.topbar-brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 0.9rem; color: var(--gray-900);
}
.topbar-brand .brand-dot {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, #6366F1, #818CF8);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 0.75rem;
}
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--gray-100); cursor: pointer;
  text-decoration: none; transition: background 0.15s;
  margin-left: auto;
}
.topbar-user:hover { background: var(--gray-50); }
.topbar-user .avatar {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, #6366F1, #818CF8);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 0.72rem; font-weight: 700;
}
.topbar-user .uname { font-size: 0.8rem; font-weight: 500; color: var(--gray-900); }
.topbar-user .company { font-size: 0.7rem; color: var(--gray-500); }

/* ─── SIDEBAR ─────────────────────────────────── */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--white); border-right: 1px solid var(--gray-100);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  transition: width 0.25s, transform 0.25s;
  z-index: 90;
}
.sidebar-section { padding: 8px 8px 0; }
.sidebar-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--gray-200);
  padding: 10px 8px 4px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; margin-bottom: 2px;
  color: var(--gray-500); font-size: 0.825rem; font-weight: 500;
  transition: all 0.15s; text-decoration: none; white-space: nowrap;
}
.sidebar-link:hover  { background: var(--gray-50); color: var(--gray-900); }
.sidebar-link.active { background: rgba(99,102,241,0.08); color: var(--primary); font-weight: 600; }
.sidebar-link i { font-size: 1rem; flex-shrink: 0; }
.sidebar-footer { margin-top: auto; padding: 8px; border-top: 1px solid var(--gray-100); }

body.sidebar-collapsed .sidebar { width: 52px; }
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-link span { display: none; }
body.sidebar-collapsed .sidebar-link { justify-content: center; padding: 8px; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 89; }
.sidebar-overlay.open { display: block; }

/* ─── MAIN ────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 24px) 24px 32px;
  min-height: 100vh;
  transition: margin-left 0.25s;
}
body.sidebar-collapsed .main { margin-left: 52px; }

/* ─── CARDS ───────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 0.875rem;
}
.card-body { padding: 20px; }

/* ─── STATS ───────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white); border: 1px solid var(--gray-100);
  border-radius: 14px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }
.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin-bottom: 14px;
}
.icon-purple { background: rgba(99,102,241,0.1); color: var(--primary); }
.icon-green  { background: rgba(16,185,129,0.1);  color: var(--success); }
.icon-amber  { background: rgba(245,158,11,0.1);  color: var(--warning); }
.icon-red    { background: rgba(239,68,68,0.1);   color: var(--danger); }
.icon-blue   { background: rgba(59,130,246,0.1);  color: var(--info); }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 0.75rem; font-weight: 500; color: var(--gray-500); margin-top: 4px; }

/* ─── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: none;
  font-size: 0.825rem; font-weight: 600; cursor: pointer;
  font-family: 'Inter', sans-serif; transition: all 0.15s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, #6366F1, #818CF8); color: white; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.35); color: white; }
.btn-secondary { background: var(--gray-50); color: var(--gray-900); border: 1px solid var(--gray-100); }
.btn-secondary:hover { background: var(--gray-100); }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: none; border: none; color: var(--gray-500); font-size: 0.8rem; font-weight: 500; }
.btn-ghost:hover { background: var(--gray-50); color: var(--gray-900); }
.btn-sm { padding: 5px 10px; font-size: 0.775rem; }
.btn-lg { padding: 10px 22px; font-size: 0.9rem; }
.btn-icon { padding: 6px; border-radius: 6px; min-width: 30px; justify-content: center; }

/* ─── TABLE ───────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse; font-size: 0.825rem;
}
.table thead th {
  padding: 10px 16px; font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--gray-500); background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100); text-align: left; white-space: nowrap;
}
.table thead th.text-right { text-align: right; }
.table tbody td {
  padding: 11px 16px; border-bottom: 1px solid var(--gray-100);
  color: var(--gray-900); vertical-align: middle;
}
.table tbody td.text-right { text-align: right; }
.table tbody td.muted { color: var(--gray-500); font-size: 0.775rem; }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: none; }
.table tfoot td { padding: 11px 16px; font-weight: 700; border-top: 2px solid var(--gray-100); background: var(--gray-50); }

/* ─── FORMS ───────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-label { font-size: 0.775rem; font-weight: 600; color: var(--gray-500); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
input[type="text"], input[type="number"], input[type="date"],
input[type="email"], input[type="password"], select, textarea {
  width: 100%; padding: 8px 12px;
  border: 1.5px solid var(--gray-100); border-radius: 8px;
  font-size: 0.825rem; font-family: 'Inter', sans-serif;
  background: var(--gray-50); color: var(--gray-900);
  outline: none; transition: all 0.15s; appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); background: white;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%2364748B' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer;
}
textarea { resize: vertical; min-height: 70px; }

/* ─── AUTOCOMPLETE ────────────────────────────── */
.ac-wrapper { position: relative; }
.ac-field {
  width: 100%; padding: 8px 32px 8px 12px;
  border: 1.5px solid var(--gray-100); border-radius: 8px;
  font-size: 0.825rem; font-family: 'Inter', sans-serif;
  background: var(--gray-50); color: var(--gray-900);
  outline: none; transition: all 0.15s;
}
.ac-field:focus {
  border-color: var(--primary); background: white;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.ac-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--gray-200); font-size: 0.8rem; pointer-events: none; opacity: 0;
}
.ac-clear-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--gray-500);
  cursor: pointer; font-size: 0.875rem; display: none; line-height: 1; padding: 2px;
}
.ac-clear-btn.visible { display: block; }
.ac-clear-btn:hover { color: var(--gray-900); }
.ac-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: white; border: 1px solid var(--gray-200);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 999; max-height: 240px; overflow-y: auto; display: none;
}
.ac-results.open { display: block; }
.ac-results::-webkit-scrollbar { width: 4px; }
.ac-results::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }
.ac-result-item {
  padding: 9px 14px; cursor: pointer;
  border-bottom: 1px solid var(--gray-100); transition: background 0.1s;
}
.ac-result-item:last-child { border-bottom: none; }
.ac-result-item:hover, .ac-result-item.selected { background: rgba(99,102,241,0.07); }
.ac-result-main { font-size: 0.825rem; font-weight: 500; color: var(--gray-900); }
.ac-result-sub  { font-size: 0.72rem; color: var(--gray-500); margin-top: 1px; }
.ac-result-main mark {
  background: rgba(99,102,241,0.15); color: var(--primary);
  font-weight: 600; border-radius: 2px; padding: 0 1px; font-style: normal;
}
.ac-no-results { padding: 16px; text-align: center; color: var(--gray-500); font-size: 0.8rem; }

/* ─── BADGES ──────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; white-space: nowrap;
}
.badge-green  { background: #ECFDF5; color: #065F46; }
.badge-red    { background: #FEF2F2; color: #991B1B; }
.badge-amber  { background: #FFFBEB; color: #92400E; }
.badge-blue   { background: #EFF6FF; color: #1E40AF; }
.badge-purple { background: rgba(99,102,241,0.1); color: #4338CA; }
.badge-gray   { background: var(--gray-50); color: var(--gray-500); border: 1px solid var(--gray-100); }

/* ─── PILLS (filtros) ─────────────────────────── */
.pills { display: flex; gap: 4px; flex-wrap: wrap; }
.pill {
  padding: 4px 12px; border-radius: 20px; font-size: 0.775rem; font-weight: 500;
  border: 1.5px solid var(--gray-100); background: white; color: var(--gray-500);
  cursor: pointer; text-decoration: none; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.pill:hover  { border-color: var(--primary); color: var(--primary); }
.pill.active { background: rgba(99,102,241,0.08); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* ─── FLASH ───────────────────────────────────── */
.flash-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.flash-msg {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 10px;
  font-size: 0.825rem; font-weight: 500; max-width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  animation: slideIn 0.25s ease;
}
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }
.flash-success { background: #ECFDF5; color: #065F46; border-left: 3px solid var(--success); }
.flash-danger  { background: #FEF2F2; color: #991B1B; border-left: 3px solid var(--danger); }
.flash-warning { background: #FFFBEB; color: #92400E; border-left: 3px solid var(--warning); }
.flash-info    { background: #EFF6FF; color: #1E40AF; border-left: 3px solid var(--info); }

/* ─── PROGRESS ────────────────────────────────── */
.progress { height: 5px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width 0.4s; }
.bar-green { background: var(--success); }
.bar-amber { background: var(--warning); }
.bar-red   { background: var(--danger); }

/* ─── PAGINATION ──────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 16px; }
.page-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--gray-100); background: white;
  color: var(--gray-500); font-size: 0.8rem; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: all 0.12s;
}
.page-btn:hover { background: var(--gray-50); color: var(--gray-900); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ─── UTILS ───────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.mt-12 { margin-top: 12px; }   .mt-16 { margin-top: 16px; }   .mt-20 { margin-top: 20px; }
.flex  { display: flex; } .flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.text-right  { text-align: right; } .text-center { text-align: center; }
.text-muted  { color: var(--gray-500); } .text-danger { color: var(--danger); }
.text-success{ color: var(--success); } .text-primary { color: var(--primary); }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.text-sm { font-size: 0.775rem; } .w-full { width: 100%; }
.divider { height: 1px; background: var(--gray-100); margin: 14px 0; }
.empty-state { text-align: center; padding: 40px; color: var(--gray-500); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: 8px; }
.page-title { margin-bottom: 20px; }
.page-title h2 { font-size: 1.15rem; font-weight: 800; }
.page-title p  { font-size: 0.8rem; color: var(--gray-500); margin-top: 3px; }
.filter-bar {
  background: white; border: 1px solid var(--gray-100); border-radius: 14px;
  padding: 14px 18px; margin-bottom: 16px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.filter-bar .form-group { margin-bottom: 0; min-width: 130px; }

/* ─── LOGIN ───────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #4F46E5, #818CF8); }
.login-card { background: white; border-radius: 18px; padding: 40px 36px; width: 380px; max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.login-logo  { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { width: 52px; height: 52px; background: linear-gradient(135deg, #6366F1, #818CF8); border-radius: 14px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; font-size: 1.4rem; color: white; box-shadow: 0 6px 20px rgba(99,102,241,0.4); }
.login-logo h1 { font-size: 1.2rem; font-weight: 800; }
.login-logo p  { font-size: 0.78rem; color: var(--gray-500); margin-top: 4px; }

/* ─── RESPONSIVE ──────────────────────────────── */
@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0 !important; padding: calc(var(--topbar-h) + 16px) 14px 24px; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}