:root {
  --primary: #059669;
  --primary-hover: #047857;
  --primary-light: #ecfdf5;
  --primary-border: #a7f3d0;
  --secondary: #0284c7;
  --secondary-light: #e0f2fe;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --sidebar-w: 240px;
  --sidebar-w-mobile: 60px;
  --topbar-h: 70px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --transition: all 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

body {
  display: flex;
}

/* ==========================================================================
   1. SIDEBAR (Desktop & Mobile)
   ========================================================================== */
.sidebar {
  width: var(--sidebar-w);
  background-color: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  user-select: none;
  transition: width var(--transition);
}

.sidebar-header {
  height: var(--topbar-h);
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.logo-badge {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 19px;
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.25);
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.nav-menu {
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-item i {
  font-size: 17px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item:hover {
  background-color: var(--bg-main);
  color: var(--primary);
}

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-promo-card {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.promo-banner-box {
  background: linear-gradient(145deg, #f0fdf4, #e0f2fe);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  padding: 8px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
}

.promo-banner-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.18);
  border-color: var(--primary);
}

.promo-banner-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 180px;
  object-fit: cover;
  object-position: top center;
  border-radius: var(--radius-sm);
  display: block;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.promo-banner-caption {
  font-size: 10.5px;
  color: var(--primary);
  font-weight: 600;
  margin-top: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.promo-banner-caption i {
  font-size: 11px;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   2. MAIN WRAPPER & TOPBAR
   ========================================================================== */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: calc(100% - var(--sidebar-w));
  transition: margin-left var(--transition), width var(--transition);
}

.topbar {
  height: var(--topbar-h);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 10px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.page-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.7);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

/* ==========================================================================
   3. BUTTONS & BADGES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--bg-main);
  border-color: var(--primary-border);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.badge-primary { background-color: var(--primary-light); color: var(--primary); }
.badge-success { background-color: #dcfce7; color: #15803d; }
.badge-danger { background-color: var(--danger-light); color: var(--danger); }
.badge-neutral { background-color: #f1f5f9; color: #64748b; }

/* ==========================================================================
   4. CONTENT & CHARTS
   ========================================================================== */
.content-container {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1400px;
  width: 100%;
  min-width: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  width: 100%;
  min-width: 0;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.stat-info {
  min-width: 0;
  overflow: hidden;
}

.stat-info h3 {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.stat-icon.green { background-color: var(--primary-light); color: var(--primary); }
.stat-icon.blue { background-color: var(--secondary-light); color: var(--secondary); }
.stat-icon.amber { background-color: #fef3c7; color: var(--warning); }
.stat-icon.purple { background-color: #f3e8ff; color: #9333ea; }

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  width: 100%;
  min-width: 0;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.card-title {
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.chart-container {
  position: relative;
  width: 100% !important;
  max-width: 100% !important;
  height: 250px;
  min-width: 0;
}

.donut-container {
  height: 270px;
}

.chart-container canvas {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  min-width: 500px;
}

th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

tr:hover td {
  background-color: #fcfcfd;
}

/* ==========================================================================
   5. PAGINATION (Elegant & Responsive)
   ========================================================================== */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px 4px 4px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-info {
  font-size: 12.5px;
  color: var(--text-muted);
}

.pagination-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  color: var(--text-main);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: var(--transition);
}

.page-btn:hover {
  background-color: var(--bg-main);
  border-color: var(--primary-border);
  color: var(--primary);
}

.page-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

.page-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}

.page-dots {
  color: var(--text-muted);
  padding: 0 4px;
  font-size: 13px;
}

/* ==========================================================================
   6. FORMS & UPLOAD
   ========================================================================== */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background-color: var(--bg-card);
  color: var(--text-main);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.upload-dropzone {
  border: 2px dashed var(--primary-border);
  background-color: #f0fdf4;
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
}

.upload-icon {
  font-size: 32px;
  color: var(--primary);
  margin-bottom: 8px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.show { display: flex; }

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 580px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  text-align: right;
  background: #f8fafc;
}

/* ==========================================================================
   7. RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-w-mobile);
  }
  .sidebar .brand-title,
  .sidebar .brand-subtitle,
  .sidebar .nav-item span,
  .sidebar-promo-card,
  .sidebar-footer {
    display: none;
  }
  .sidebar .sidebar-header {
    padding: 0;
    justify-content: center;
  }
  .sidebar .nav-item {
    justify-content: center;
    padding: 12px 0;
  }
  .main-wrapper {
    margin-left: var(--sidebar-w-mobile);
    width: calc(100% - var(--sidebar-w-mobile));
  }
  .topbar { 
    padding: 0 14px; 
  }
  .status-pill { 
    display: none; 
  }
  .page-title {
    font-size: 14px;
  }
  .content-container { 
    padding: 14px; 
    gap: 14px; 
  }
  .stats-grid { 
    grid-template-columns: 1fr; 
  }
  .charts-grid { 
    grid-template-columns: 1fr; 
  }
  .chart-container {
    height: 220px;
  }
  .donut-container {
    height: 250px;
  }
  .pagination-wrapper {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .topbar-right .btn span,
  .topbar-right .badge {
    display: none;
  }
  .btn { 
    padding: 6px 10px; 
    font-size: 11.5px; 
  }
  .page-btn {
    min-width: 30px;
    height: 30px;
    font-size: 11.5px;
    padding: 0 8px;
  }
}
