:root {
  --sidebar-width: 260px;
  --header-height: 56px;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --surface: #f8fafc;
  --border: #e2e8f0;
}

[data-bs-theme="dark"] {
  --surface: #1e293b;
  --border: #334155;
}

* { font-family: 'Inter', system-ui, -apple-system, sans-serif; }
body { margin: 0; background: var(--surface); min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: #1e293b;
  color: #cbd5e1;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1040;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

[data-bs-theme="dark"] .sidebar { background: #0f172a; }

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
}
.sidebar-header h6 { color: #f1f5f9; }
.sidebar-nav { padding: 0.5rem 0; }

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 1rem 1.25rem 0.4rem;
}
.nav-link-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.nav-link-item:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.04);
}
.nav-link-item.active {
  color: #fff;
  background: rgba(79,70,229,0.15);
  border-left-color: var(--primary);
}
.nav-link-item i { font-size: 1.1rem; width: 20px; text-align: center; }

/* Main */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.main-header {
  height: var(--header-height);
  background: var(--bs-body-bg, #fff);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.main-content {
  padding: 1.5rem;
  flex: 1;
}

/* Cards */
.stat-card {
  border: none;
  border-radius: 12px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 0.8rem; color: #64748b; font-weight: 500; }

/* Status badges */
.badge-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35em 0.75em;
  border-radius: 6px;
}
.badge-OPEN { background: #dbeafe; color: #1e40af; }
.badge-VALIDATED { background: #fef3c7; color: #92400e; }
.badge-GENERATED { background: #d1fae5; color: #065f46; }
.badge-REJECTED { background: #fee2e2; color: #991b1b; }
.badge-CANCELLED { background: #f1f5f9; color: #475569; }
.badge-ACTIVE { background: #d1fae5; color: #065f46; }
.badge-CLOSED { background: #f1f5f9; color: #475569; }

/* Tables */
.table-container {
  background: var(--bs-body-bg, #fff);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.table-container .table { margin-bottom: 0; }
.table-container .table thead th {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}
[data-bs-theme="dark"] .table-container .table thead th { background: #1e293b; }
.table-container .table tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  vertical-align: middle;
}
.table-container .table tbody tr { transition: background 0.1s; }
.table-container .table tbody tr:hover { background: rgba(79,70,229,0.03); }

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h4 { margin: 0; font-weight: 700; }

/* Filter bar */
.filter-bar {
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.filter-bar .form-control,
.filter-bar .form-select {
  font-size: 0.875rem;
}

/* Key display */
.license-key-display {
  font-family: 'Courier New', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--primary);
  background: #eef2ff;
  border: 2px dashed var(--primary);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  word-break: break-all;
  user-select: all;
}
[data-bs-theme="dark"] .license-key-display {
  background: rgba(79,70,229,0.15);
}

/* JSON viewer */
.json-viewer {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
}

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1035;
}
.sidebar-overlay.show { display: block; }

/* Clickable row */
.clickable-row { cursor: pointer; }

/* Detail view */
.detail-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 0.25rem;
}
.detail-value {
  font-size: 0.95rem;
  font-weight: 500;
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; }

/* Pagination */
.pagination-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

/* Progress bar for quantities */
.qty-progress {
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
}
.qty-progress-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width 0.3s;
}
.qty-progress-bar.warning { background: #f59e0b; }
.qty-progress-bar.danger { background: #ef4444; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.2s ease-out; }
