:root {
  --sidebar-bg: #1e1e2d;
  --sidebar-hover: #2a2a3d;
  --sidebar-active-bg: rgba(85, 110, 230, 0.12);
  --sidebar-active-border: #556ee6;
  --sidebar-width: 250px;
  --accent: #556ee6;
  --accent-rgb: 85, 110, 230;
  --success: #34c38f;
  --warning: #f1b44c;
  --danger: #f46a6a;
  --body-bg: #f5f6fa;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --card-shadow-hover: 0 10px 24px rgba(0, 0, 0, 0.1);
  --border-color: #e9ebf0;
  --text-muted: #8b8fa3;
  --input-bg: #f8f9fb;
}

html {
  font-size: 15px;
  position: relative;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--body-bg);
  color: #495057;
  overflow-x: hidden;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 0.5rem;
}

.sidebar-brand:hover {
  color: #fff;
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-brand .brand-text small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
}

.sidebar-nav {
  flex: 1;
  padding: 0.25rem 0.75rem;
  list-style: none;
  margin: 0;
}

.sidebar-nav .nav-item {
  margin-bottom: 2px;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

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

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

.sidebar-nav .nav-link.active::before {
  content: '';
  position: absolute;
  left: -0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-nav .nav-link i {
  font-size: 1.15rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav .nav-link.logout-link {
  color: rgba(255, 255, 255, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-radius: 0;
}

.sidebar-nav .nav-link.logout-link:hover {
  color: var(--danger);
  background: transparent;
}

.sidebar-footer {
  padding: 0.75rem 1.25rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.25);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1039;
}

.sidebar-overlay.show {
  display: block;
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

.main-content .page-content {
  flex: 1;
  padding: 1.5rem 1.75rem 3rem;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.75rem;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  min-height: 60px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle {
  display: inline-flex;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #495057;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e1e2d;
  margin: 0;
}

.breadcrumb-custom {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.breadcrumb-custom a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb-custom a:hover {
  text-decoration: underline;
}

/* Mobile sidebar */
@media (max-width: 767.98px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: var(--sidebar-width);
  }

  .main-content {
    margin-left: 0;
  }

  .main-content .page-content {
    padding: 1rem 1rem 2rem;
  }

  .topbar {
    padding: 0.7rem 1rem;
  }
}

/* Desktop collapsed sidebar */
@media (min-width: 768px) {
  .sidebar {
    transition: width 0.3s ease, transform 0.3s ease;
  }

  .sidebar.collapsed {
    width: 65px;
  }

  .sidebar.collapsed .sidebar-brand {
    padding: 1.25rem 0.5rem 0.75rem;
    justify-content: center;
  }

  .sidebar.collapsed .brand-text {
    display: none;
  }

  .sidebar.collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 0.65rem;
    margin: 0 0.5rem;
  }

  .sidebar.collapsed .sidebar-nav .nav-link span {
    display: none;
  }

  .sidebar.collapsed .sidebar-nav .nav-link i {
    font-size: 1.3rem;
    width: auto;
  }

  .sidebar.collapsed .sidebar-footer {
    display: none;
  }

  .sidebar.collapsed ~ .main-content {
    margin-left: 65px;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .main-content .page-content {
    padding: 1.25rem;
  }
}

/* ========================================
   Cards
   ======================================== */
.card {
  border: none;
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--card-shadow-hover);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  border-radius: 10px 10px 0 0 !important;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  background: #fff;
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 10px 10px !important;
}

/* Stat cards */
.stat-card {
  border-radius: 12px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.stat-card:hover {
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.05);
}

a:hover .stat-card {
  transform: translateY(-4px);
}

.stat-card .stat-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
}

.stat-card .stat-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}

.stat-card .stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
}

.stat-card .stat-value small {
  font-size: 0.95rem;
  font-weight: 400;
  opacity: 0.8;
}

.stat-card .stat-percentage {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Colored accent left border for stat cards */
.stat-card-accent-primary {
  border-left: 4px solid var(--accent);
}
.stat-card-accent-primary .stat-icon {
  background: rgba(85, 110, 230, 0.1);
  color: var(--accent);
}
.stat-card-accent-primary .stat-value {
  color: var(--accent);
}

.stat-card-accent-success {
  border-left: 4px solid var(--success);
}
.stat-card-accent-success .stat-icon {
  background: rgba(52, 195, 143, 0.1);
  color: var(--success);
}
.stat-card-accent-success .stat-value {
  color: var(--success);
}

.stat-card-accent-warning {
  border-left: 4px solid var(--warning);
}
.stat-card-accent-warning .stat-icon {
  background: rgba(241, 180, 76, 0.1);
  color: var(--warning);
}
.stat-card-accent-warning .stat-value {
  color: var(--warning);
}

.stat-card-accent-danger {
  border-left: 4px solid var(--danger);
}
.stat-card-accent-danger .stat-icon {
  background: rgba(244, 106, 106, 0.1);
  color: var(--danger);
}
.stat-card-accent-danger .stat-value {
  color: var(--danger);
}

/* ========================================
   Tables
   ======================================== */
.table {
  margin-bottom: 0;
  --bs-table-hover-bg: rgba(85, 110, 230, 0.03);
}

.table thead th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  padding: 0.85rem 0.75rem;
  background: #fafbfc;
}

.table tbody tr {
  transition: background 0.15s ease;
}

.table tbody td {
  padding: 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: rgba(85, 110, 230, 0.03);
}

/* ========================================
   Badges
   ======================================== */
.badge {
  font-weight: 500;
  padding: 0.35em 0.65em;
  font-size: 0.78rem;
  border-radius: 6px;
}

.badge.bg-success {
  background: rgba(52, 195, 143, 0.15) !important;
  color: #1a8b62;
}

.badge.bg-warning {
  background: rgba(241, 180, 76, 0.15) !important;
  color: #a87d1e;
}

.badge.bg-danger {
  background: rgba(244, 106, 106, 0.15) !important;
  color: #c74040;
}

.badge.bg-secondary {
  background: rgba(139, 143, 163, 0.15) !important;
  color: #6b6f82;
}

.badge.bg-primary {
  background: rgba(85, 110, 230, 0.15) !important;
  color: #3d52c9;
}

/* Dot indicator badges */
.badge-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-dot.bg-success::before {
  background: var(--success);
}

.badge-dot.bg-warning::before {
  background: var(--warning);
}

.badge-dot.bg-danger::before {
  background: var(--danger);
}

.badge-dot.bg-secondary::before {
  background: var(--text-muted);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0.45rem 1rem;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

.btn i {
  font-size: 1.25em;
  line-height: 1;
  color: inherit;
}

.btn-sm {
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #4a5fd5;
  border-color: #4a5fd5;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(85, 110, 230, 0.3);
}

.btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-outline-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #2db87f;
  border-color: #2db87f;
  color: #fff;
  box-shadow: 0 4px 12px rgba(52, 195, 143, 0.3);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #e55050;
  border-color: #e55050;
  color: #fff;
  box-shadow: 0 4px 12px rgba(244, 106, 106, 0.3);
}

/* ========================================
   Forms
   ======================================== */
.form-control, .form-select {
  border: 1px solid #d6d8e3;
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  background: var(--input-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(85, 110, 230, 0.1);
  background: #fff;
}

.form-control-sm,
.form-select-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  border-radius: 6px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: #495057;
  margin-bottom: 0.3rem;
}

.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.form-check-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(85, 110, 230, 0.1);
}

/* Input group */
.input-group .btn {
  border-radius: 0 8px 8px 0;
}

.input-group .form-control {
  border-radius: 8px 0 0 8px;
}

/* ========================================
   Pagination
   ======================================== */
.pagination {
  gap: 3px;
}

.page-link {
  border: none;
  border-radius: 6px !important;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  color: #495057;
  background: transparent;
}

.page-item.active .page-link {
  background: var(--accent);
  color: #fff;
}

.page-item.disabled .page-link {
  color: var(--text-muted);
  background: transparent;
}

.page-link:hover {
  background: rgba(85, 110, 230, 0.08);
  color: var(--accent);
}

/* ========================================
   Filter / Button groups
   ======================================== */
.filter-group .btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
}

.filter-group .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-group .btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
}

.filter-group .btn-outline-success {
  color: var(--success);
  border-color: var(--success);
}

.filter-group .btn-outline-success:hover,
.filter-group .btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.filter-group .btn-outline-warning {
  color: #a87d1e;
  border-color: var(--warning);
}

.filter-group .btn-outline-warning:hover,
.filter-group .btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
}

.filter-group .btn-outline-danger {
  color: #c74040;
  border-color: var(--danger);
}

.filter-group .btn-outline-danger:hover,
.filter-group .btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* ========================================
   Toast
   ======================================== */
.toast {
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ========================================
   Page transitions
   ======================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-content {
  animation: fadeInUp 0.25s ease-out;
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ========================================
   Alert overrides
   ======================================== */
.alert {
  border: none;
  border-radius: 10px;
}

.alert-success {
  background: rgba(52, 195, 143, 0.1);
  color: #1a8b62;
}

.alert-danger {
  background: rgba(244, 106, 106, 0.1);
  color: #c74040;
}

.alert-heading {
  font-weight: 600;
}

/* ========================================
   Auth pages (login)
   ======================================== */
.auth-body {
  background: linear-gradient(135deg, #1e1e2d 0%, #2a2a4a 50%, #1e1e2d 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.auth-card .card-header {
  background: var(--sidebar-bg);
  color: #fff;
  text-align: center;
  padding: 2rem 1.5rem 1.5rem;
  border-bottom: none;
  border-radius: 0 !important;
}

.auth-card .card-header .auth-icon {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
}

.auth-card .card-header h3 {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.auth-card .card-header p {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
}

.auth-card .card-body {
  padding: 2rem;
}

/* ========================================
   Empty states
   ======================================== */
.empty-state {
  padding: 2rem 1rem;
  text-align: center;
}

.empty-state > i {
  font-size: 2.25rem;
  color: var(--text-muted);
  opacity: 0.35;
  margin-bottom: 0.75rem;
  display: inline-block;
}

.empty-state h5 {
  color: #495057;
  font-weight: 600;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 300px;
  margin: 0 auto;
}

/* ========================================
   Timeline
   ======================================== */
.timeline {
  position: relative;
  padding-left: 1.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  padding-bottom: 1.25rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -1.5rem;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--border-color);
}

.timeline-dot.dot-primary {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(85, 110, 230, 0.3);
}

.timeline-dot.dot-success {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(52, 195, 143, 0.3);
}

.timeline-dot.dot-warning {
  background: var(--warning);
  box-shadow: 0 0 0 2px rgba(241, 180, 76, 0.3);
}

.timeline-dot.dot-danger {
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(244, 106, 106, 0.3);
}

.timeline-content {
  padding-left: 0.5rem;
}

.timeline-content .timeline-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: #343a40;
}

.timeline-content .timeline-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ========================================
   Copy button for license keys
   ======================================== */
.copy-btn {
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s ease;
  background: none;
  border: none;
  color: inherit;
  padding: 0 0.25rem;
}

.copy-btn:hover {
  opacity: 1;
  color: var(--accent);
}

/* ========================================
   Responsive helpers
   ======================================== */
@media (max-width: 575.98px) {
  .stat-card .stat-value {
    font-size: 1.4rem;
  }

  .table thead {
    display: none;
  }

  .table tbody td {
    display: block;
    padding: 0.5rem 0.75rem;
    border-bottom: none;
    font-size: 0.85rem;
  }

  .table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.15rem;
  }

  .table tbody td[data-label=""]::before {
    display: none;
  }

  .table tbody tr {
    display: block;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--card-shadow);
  }

  .table tbody td .btn-sm {
    padding: 0.45rem 0.75rem;
    min-height: 38px;
  }
}

/* Print */
@media print {
  .sidebar, .topbar, .sidebar-overlay {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
  }
}
