:root {
  --font-primary: 'Outfit', sans-serif;
  --font-secondary: 'Plus Jakarta Sans', sans-serif;
  
  /* Modern Sleek Dark Theme Color Palette */
  --bg-app: #090b11;
  --bg-sidebar: #0f1322;
  --bg-card: rgba(22, 28, 45, 0.6);
  --bg-card-hover: rgba(26, 34, 55, 0.8);
  --border-glass: rgba(255, 255, 255, 0.05);
  --border-focus: #5f5dec;
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --color-primary: #5f5dec;
  --color-primary-hover: #4e4bc9;
  --color-success: #10b981;
  --color-success-hover: #0d9488;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  
  --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

/* ==========================================================================
   LIGHT THEME VARIABLES
   ========================================================================== */
body.light-theme {
  --bg-app: #f4f6fa;
  --bg-sidebar: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --border-glass: rgba(0, 0, 0, 0.06);
  --border-focus: #5f5dec;
  
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  --shadow-premium: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
  
  background-image: radial-gradient(circle at 10% 20%, rgba(95, 93, 236, 0.05) 0%, transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.03) 0%, transparent 40%);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: radial-gradient(circle at 10% 20%, rgba(95, 93, 236, 0.1) 0%, transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
}

.hidden {
  display: none !important;
}

.tab-content {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ==========================================================================
   BUTTONS & INPUTS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-primary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
}

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

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--border-glass);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

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

.btn-success:hover {
  background-color: var(--color-success-hover);
  transform: translateY(-1px);
}

.btn-block {
  width: 100%;
}

.btn-pagination {
  padding: 6px 12px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-pagination:hover:not(:disabled) {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-pagination:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ==========================================================================
   LOGIN OVERLAY
   ========================================================================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(15, 19, 34, 0.9) 0%, #090b11 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-premium);
  animation: scaleUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.logo-wrapper {
  width: 60px;
  height: 60px;
  background: rgba(95, 93, 236, 0.1);
  color: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 16px;
  border: 1px solid rgba(95, 93, 236, 0.25);
}

.login-header h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.input-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.input-wrapper input,
.input-wrapper select,
.search-box input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-secondary);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.input-wrapper input:focus,
.input-wrapper select:focus,
.search-box input:focus {
  border-color: var(--border-focus);
  background-color: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(95, 93, 236, 0.15);
}

.error-msg {
  color: var(--color-danger);
  font-size: 0.85rem;
  margin-bottom: 16px;
  text-align: center;
  min-height: 18px;
}

/* ==========================================================================
   DASHBOARD LAYOUT
   ========================================================================== */
.dashboard-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  padding: 24px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  margin-bottom: 40px;
}

.sidebar-brand i {
  color: var(--color-primary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-item:hover, .nav-item.active {
  color: #fff;
  background-color: rgba(95, 93, 236, 0.1);
}

.nav-item.active {
  border: 1px solid rgba(95, 93, 236, 0.2);
  color: var(--color-primary);
}

.sidebar-footer {
  border-top: 1px solid var(--border-glass);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info .avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.user-info .details .name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-info .details .role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-logout:hover {
  color: var(--color-danger);
  background-color: rgba(239, 68, 68, 0.05);
}

/* Main Content Area */
.main-content {
  padding: 40px;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.header-title h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.header-title p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  gap: 16px;
  align-items: center;
}

.date-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  padding: 6px 14px;
  border-radius: var(--radius-md);
}

.input-group-row {
  display: flex;
  gap: 14px;
}

.input-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-inline label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
}

.input-inline input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-secondary);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
}

/* ==========================================================================
   STATS CARD GRID
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.stat-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.1);
}

.stat-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.icon-blue {
  background: rgba(95, 93, 236, 0.1);
  color: var(--color-primary);
}

.icon-purple {
  background: rgba(162, 28, 175, 0.1);
  color: #c084fc;
}

.icon-orange {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.icon-red {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
}

.stat-info h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* ==========================================================================
   CHARTS GRID
   ========================================================================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
}

.chart-card {
  grid-column: span 6;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chart-card.large {
  grid-column: span 12;
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.card-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chart-body {
  position: relative;
  flex-grow: 1;
  min-height: 250px;
  max-height: 380px;
}

/* ==========================================================================
   DATA TABLE PAGE
   ========================================================================== */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
}

.table-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.search-box {
  position: relative;
  width: 100%;
  max-width: 380px;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
}

.search-box input {
  padding-left: 42px;
}

.table-filters {
  display: flex;
  gap: 12px;
}

.table-filters select {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-family: var(--font-secondary);
  font-size: 0.9rem;
}

.data-table th, .data-table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-glass);
}

.data-table th {
  font-family: var(--font-primary);
  font-weight: 600;
  color: var(--text-secondary);
  background-color: rgba(255, 255, 255, 0.01);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tbody tr {
  transition: background-color 0.2s;
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.badge-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.text-center {
  text-align: center;
}

.table-footer {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  border-top: 1px solid var(--border-glass);
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

#pagination-pages {
  font-size: 0.9rem;
  font-weight: 500;
}

/* ==========================================================================
   THEME TOGGLE BUTTONS
   ========================================================================== */
.btn-theme-toggle-desktop, .btn-theme-toggle-mobile {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-theme-toggle-desktop:hover, .btn-theme-toggle-mobile:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

.light-theme .btn-theme-toggle-desktop:hover, 
.light-theme .btn-theme-toggle-mobile:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.btn-theme-toggle-desktop {
  margin-left: auto;
}

/* ==========================================================================
   MOBILE HEADER, OVERLAY & TOGGLES
   ========================================================================== */
.mobile-top-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  box-sizing: border-box;
}

.mobile-brand {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
}

.btn-menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
}

.btn-menu-close {
  display: none;
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 1200;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(9, 11, 17, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1050;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES
   ========================================================================== */
@media (max-width: 1024px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    overflow: hidden;
  }

  .mobile-top-bar {
    display: flex;
  }

  .main-content {
    padding: 20px;
    height: 100%;
    overflow-y: auto;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }

  /* Sidebar Drawer behaviour on mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 1100;
    transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background-color: var(--bg-sidebar);
    box-shadow: var(--shadow-premium);
    display: flex !important;
  }

  .sidebar.open {
    left: 0;
  }

  .btn-menu-close {
    display: block;
  }

  /* Hide desktop theme toggle button to prevent redundancy */
  #theme-toggle-desktop {
    display: none !important;
  }

  /* Responsive swipeable filter container */
  .header-actions {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    display: flex;
    gap: 12px;
    justify-content: flex-start;
    box-sizing: border-box;
  }

  .header-actions::-webkit-scrollbar {
    height: 4px;
  }
  
  .header-actions::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .header-actions::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 4px;
  }

  .date-filter {
    flex-shrink: 0;
  }
  
  .header-actions .btn {
    flex-shrink: 0;
  }

  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
  }

  .chart-card {
    grid-column: span 12;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  /* Table layout overrides for mobile */
  .table-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .search-box {
    max-width: 100%;
    width: 100%;
  }

  .table-filters {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    gap: 12px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }

  .table-filters select {
    flex-shrink: 0;
  }
  
  .table-filters::-webkit-scrollbar {
    height: 4px;
  }
  
  .table-filters::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .table-filters::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 4px;
  }
}

/* ==========================================================================
   TOP RANKED LIST (COMMODITIES)
   ========================================================================== */
.top-list-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.top-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.top-list-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateX(4px);
}

.top-list-item .rank-name {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-list-item .rank-num {
  width: 24px;
  height: 24px;
  background: rgba(95, 93, 236, 0.1);
  color: var(--color-primary);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-list-item:nth-child(1) .rank-num {
  background: rgba(245, 158, 11, 0.2);
  color: var(--color-warning);
}
.top-list-item:nth-child(2) .rank-num {
  background: rgba(200, 200, 200, 0.2);
  color: #d1d5db;
}
.top-list-item:nth-child(3) .rank-num {
  background: rgba(180, 110, 50, 0.2);
  color: #cd7f32;
}

.top-list-item .item-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.top-list-item .item-value {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-primary);
  background: rgba(95, 93, 236, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
}

/* ==========================================================================
   REKAP KOMODITAS PAGE
   ========================================================================== */
.rekap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.rekap-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.25s ease;
}

.rekap-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  border-color: rgba(95, 93, 236, 0.25);
  box-shadow: var(--shadow-premium);
}

.rekap-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rekap-card-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rekap-stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rekap-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rekap-stat-val {
  font-size: 1.15rem;
  font-weight: 800;
}

.rekap-stat-val.freq {
  color: var(--color-primary);
}

.rekap-stat-val.vol {
  color: var(--color-success);
}


