:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-light: #eef2ff;
  --sidebar-bg: #111827;
  --sidebar-hover: #1f2937;
  --sidebar-text: #9ca3af;
  --sidebar-text-active: #ffffff;
  --radius: 0.75rem;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 6px rgba(15, 23, 42, 0.05), 0 2px 4px rgba(15, 23, 42, 0.04);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f6f7fb;
  color: #1f2937;
}

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
.text-brand { color: var(--brand) !important; }

/* ---------- Sidebar ---------- */
.app-sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  flex-shrink: 0;
}

.app-sidebar .sidebar-brand {
  padding: 1.35rem 1.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: .6rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.app-sidebar .sidebar-brand i { color: var(--brand); font-size: 1.3rem; }

.app-sidebar .nav-section-title {
  color: #6b7280;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 600;
  padding: 1rem 1.5rem .35rem;
}

.app-sidebar .nav-link {
  color: var(--sidebar-text);
  padding: .6rem 1rem;
  border-radius: .5rem;
  margin: .1rem .75rem;
  display: flex;
  align-items: center;
  gap: .7rem;
  font-size: .89rem;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}

.app-sidebar .nav-link i { font-size: 1.05rem; width: 1.1rem; text-align: center; }

.app-sidebar .nav-link:hover { background: var(--sidebar-hover); color: #fff; }

.app-sidebar .nav-link.active {
  background: var(--brand);
  color: #fff;
}

.app-sidebar .sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.app-sidebar .sidebar-user {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: #e5e7eb;
  font-size: .85rem;
}

.app-sidebar .avatar-circle {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: .8rem;
  flex-shrink: 0;
}

/* ---------- Topbar ---------- */
.app-topbar {
  background: #fff;
  border-bottom: 1px solid #e9eaee;
  padding: .9rem 1.5rem;
}

.app-topbar h2, .app-topbar .h4 { margin-bottom: 0; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid #edeef2;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-body { padding: 1.35rem; }

/* ---------- Stat cards ---------- */
.stat-card {
  border: 1px solid #edeef2;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: #fff;
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  height: 100%;
}

.stat-card .icon-circle {
  width: 2.85rem;
  height: 2.85rem;
  border-radius: .7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-card .stat-label {
  font-size: .76rem;
  color: #6b7280;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.2;
}

.icon-circle.bg-brand-soft { background: var(--brand-light); color: var(--brand); }
.icon-circle.bg-success-soft { background: #dcfce7; color: #16a34a; }
.icon-circle.bg-warning-soft { background: #fef3c7; color: #b45309; }
.icon-circle.bg-danger-soft { background: #fee2e2; color: #dc2626; }
.icon-circle.bg-info-soft { background: #e0f2fe; color: #0284c7; }
.icon-circle.bg-secondary-soft { background: #f1f5f9; color: #475569; }

/* ---------- Buttons ---------- */
.btn { border-radius: .55rem; font-weight: 500; }

.btn-dark, .btn-primary {
  background-color: var(--brand);
  border-color: var(--brand);
}

.btn-dark:hover, .btn-primary:hover {
  background-color: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-outline-secondary { border-color: #d1d5db; color: #374151; }

/* ---------- Tables ---------- */
.table thead th {
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .05em;
  color: #6b7280;
  font-weight: 600;
  background: #f9fafb;
  border-bottom: 1px solid #edeef2;
  white-space: nowrap;
}

.table td, .table th { vertical-align: middle; padding: .85rem 1rem; }
.table tbody tr:hover { background-color: #f9fafb; }

/* ---------- Badges ---------- */
.badge { font-weight: 500; padding: .4em .7em; border-radius: .5rem; font-size: .74rem; }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; font-size: .85rem; color: #374151; margin-bottom: .35rem; }

.form-control, .form-select {
  border-color: #d1d5db;
  border-radius: .55rem;
  padding: .5rem .75rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .12);
}

.form-control-sm, .form-select-sm { border-radius: .5rem; }

/* ---------- Filter bar ---------- */
.filter-bar { background: #fff; }

/* ---------- Select2 ---------- */
.select2-container--bootstrap-5 .select2-selection {
  border-color: #d1d5db;
  border-radius: .55rem;
  min-height: calc(1.5em + 1rem + 2px);
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .12);
}

.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
  background-color: var(--brand) !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
  padding-left: .1rem;
}

.form-select-sm + .select2-container--bootstrap-5 .select2-selection {
  min-height: calc(1.5em + .5rem + 2px);
  font-size: .875rem;
}

/* ---------- Empty state ---------- */
.empty-state { padding: 3rem 1rem; text-align: center; color: #9ca3af; }
.empty-state i { font-size: 2.25rem; display: block; margin-bottom: .5rem; color: #d1d5db; }

/* ---------- Auth pages ---------- */
.auth-shell {
  min-height: 100vh;
  background: linear-gradient(160deg, #111827 0%, #1e1b4b 45%, #312e81 100%);
}

.auth-card {
  border: none;
  border-radius: 1rem;
  box-shadow: var(--shadow-md);
}

.auth-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.auth-brand i { color: #818cf8; }

/* ---------- Misc ---------- */
.page-title-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: .6rem;
  background: var(--brand-light);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-right: .6rem;
}
