:root {
  --primary: #0066FF;
  --primary-dark: #0052CC;
  --primary-light: #E6F0FF;
  --accent: #00C853;
  --accent-gradient: linear-gradient(135deg, #0066FF 0%, #00C853 100%);
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --bg: #F5F7FA;
  --card-bg: #FFFFFF;
  --text: #1A1A2E;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

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

/* Loading */
.loading-screen {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s;
}
.loading-logo {
  height: 60px;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Auth */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0a1a 0%, #001a33 50%, #003366 100%);
  padding: 20px;
}
.auth-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  height: 48px;
}
.btn-primary {
  background: var(--accent-gradient);
  border: none;
  font-weight: 600;
  padding: 12px;
  border-radius: 10px;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0052CC 0%, #00A844 100%);
  transform: translateY(-1px);
}
.form-control, .form-select {
  border-radius: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,255,0.15);
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #0B1220;
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo {
  height: 36px;
}
.sidebar-brand {
  font-weight: 700;
  font-size: 1.4rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}
.sidebar-nav .nav-link {
  color: rgba(255,255,255,0.7);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  transition: all 0.2s;
}
.sidebar-nav .nav-link i {
  font-size: 1.2rem;
  width: 24px;
}
.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}
.sidebar-nav .nav-link.active {
  background: var(--accent-gradient);
  color: white;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin 0.3s;
}
.topbar {
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}
.topbar-search i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.topbar-search input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.9rem;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: none;
  color: var(--text);
}
.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.65rem;
  padding: 2px 5px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}
.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

/* Notifications Panel */
.notifications-panel {
  position: absolute;
  top: var(--topbar-height);
  right: 24px;
  width: 360px;
  max-height: 480px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.notif-list {
  max-height: 400px;
  overflow-y: auto;
}
.notif-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.notif-item:hover {
  background: var(--bg);
}
.notif-item.unread {
  background: var(--primary-light);
}
.notif-item .notif-title {
  font-weight: 600;
  font-size: 0.9rem;
}
.notif-item .notif-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Page Content */
.page-content {
  padding: 24px;
}

/* Cards */
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  height: 100%;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}
.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 8px 0 4px;
}
.stat-card .stat-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}
.stat-card.sales .stat-icon { background: #E6F0FF; color: var(--primary); }
.stat-card.income .stat-icon { background: #D1FAE5; color: var(--success); }
.stat-card.expense .stat-icon { background: #FEE2E2; color: var(--danger); }
.stat-card.profit .stat-icon { background: #FEF3C7; color: var(--warning); }

.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 600;
}

/* Tables */
.table {
  margin-bottom: 0;
}
.table th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom-width: 1px;
  white-space: nowrap;
}
.table td {
  vertical-align: middle;
  font-size: 0.9rem;
}
.badge-stock {
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
}
.badge-instock { background: #D1FAE5; color: #065F46; }
.badge-low { background: #FEF3C7; color: #92400E; }
.badge-out { background: #FEE2E2; color: #991B1B; }

/* Charts */
.chart-container {
  position: relative;
  height: 280px;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h4 {
  margin: 0;
  font-weight: 700;
}
.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Filters */
.filters-bar {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.filters-bar .form-control,
.filters-bar .form-select {
  max-width: 200px;
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.product-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.product-card .product-img {
  height: 160px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 2.5rem;
  position: relative;
  overflow: hidden;
}
.product-card .product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-card .product-body {
  padding: 16px;
}
.product-card .product-name {
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-card .product-price {
  color: var(--primary);
  font-weight: 700;
  font-size: 1.1rem;
}
.product-card .product-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

/* Invoice Preview */
.invoice-preview {
  background: white;
  padding: 40px;
  border-radius: var(--radius);
  max-width: 800px;
  margin: 0 auto;
}
.invoice-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 40px;
}
.invoice-logo {
  height: 50px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }
}

@media (max-width: 575.98px) {
  .page-content {
    padding: 16px;
  }
  .stat-card .stat-value {
    font-size: 1.3rem;
  }
  .auth-card {
    padding: 28px 20px;
  }
}

/* Print */
@media print {
  .sidebar, .topbar, .page-actions, .btn, .modal {
    display: none !important;
  }
  .main-content {
    margin: 0 !important;
  }
  .invoice-preview {
    box-shadow: none;
  }
}

/* Utilities */
.text-gradient {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.cursor-pointer {
  cursor: pointer;
}
