/* BukuWiFi RT-RW CSS Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg-main: #060913;
  --bg-surface: rgba(17, 24, 39, 0.6);
  --bg-card: rgba(30, 41, 59, 0.45);
  --border-glow: rgba(16, 185, 129, 0.15); /* default green glow for accounting */
  --border-light: rgba(255, 255, 255, 0.06);
  
  --primary: #10b981; /* Green primary theme for financial/bookkeeping */
  --primary-glow: rgba(16, 185, 129, 0.4);
  --secondary: #3b82f6; /* Blue for invoices/billing */
  --accent: #a855f7; /* Purple for nets/balance */
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.2);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.2);
  --info: #0ea5e9;
  
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --sidebar-width: 260px;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.04) 0%, transparent 40%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Page Layout */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(10, 15, 30, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: all 0.3s ease;
}

.logo-container {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  box-shadow: 0 0 15px var(--primary-glow);
}

.logo-text {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(to right, #ffffff, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}

.logo-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.nav-menu {
  list-style: none;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.nav-item a:hover, .nav-item.active a {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active a {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.03) 100%);
  border-left: 3px solid var(--primary);
  box-shadow: inset 5px 0 15px rgba(16, 185, 129, 0.05);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.nav-item a:hover svg {
  transform: scale(1.1);
  color: var(--primary);
}

.nav-item.active svg {
  color: var(--primary);
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2s infinite;
}

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

/* Main Content Area */
.main-content {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  padding: 30px;
  min-height: 100vh;
  transition: all 0.3s ease;
}

/* Header Styles */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.header-title-area h1 {
  font-family: var(--font-title);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-title-area p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

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

.date-badge {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

/* Mobile Toggle */
.mobile-nav-toggle {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Base UI Components (Cards, Buttons, Badges) */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: 0 12px 40px 0 rgba(16, 185, 129, 0.06);
}

/* Dashboard Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 15px;
}

.stat-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--secondary); }
.stat-icon.purple { background: rgba(168, 85, 247, 0.15); color: var(--accent); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.stat-icon.orange { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.stat-value {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.stat-trend {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* Dashboard Content Grid */
.dashboard-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 25px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-main);
}

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

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: #dc2626;
}

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

.btn-circle {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.25); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.25); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.25); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: var(--info); border: 1px solid rgba(59, 130, 246, 0.25); }
.badge-purple { background: rgba(168, 85, 247, 0.15); color: var(--accent); border: 1px solid rgba(168, 85, 247, 0.25); }

/* Table design */
.table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  margin-top: 15px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-light);
}

.data-table td {
  padding: 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

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

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

/* Financial values text styling */
.text-income {
  color: var(--success) !important;
  font-weight: 600;
}

.text-expense {
  color: var(--danger) !important;
  font-weight: 600;
}

/* Views display controllers */
.app-view {
  display: none;
  animation: fadeIn 0.4s ease;
}

.app-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Speed chart / Canvas styles */
.chart-container {
  position: relative;
  height: 250px;
  width: 100%;
  margin-top: 15px;
}

/* Form inputs styling */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  background: rgba(10, 15, 30, 0.5);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 12px;
  color: white;
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

/* Form inputs styling */
.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* Modals styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-family: var(--font-title);
  font-size: 1.25rem;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.close-btn:hover {
  color: white;
}

.modal-footer {
  margin-top: 25px;
  padding-top: 15px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Invoice detail print layout */
.invoice-print-area {
  display: none;
}

/* Filter Controls */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-wrapper {
  position: relative;
  flex-grow: 1;
  max-width: 400px;
}

.search-input {
  padding-left: 40px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.filters-actions {
  display: flex;
  gap: 10px;
}

/* Print Stylesheet Overrides */
@media print {
  body {
    background: white !important;
    color: black !important;
  }
  
  .sidebar, 
  .main-content > *:not(.print-container-visible), 
  .header-bar, 
  .modal-overlay,
  .sidebar-backdrop {
    display: none !important;
  }
  
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Enforce thermal ticket layout on print for invoice/bill */
  body:not(.print-report-mode) #invoice-print-container {
    display: block !important;
    width: 80mm !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 2mm !important;
    background: white !important;
    color: black !important;
    box-sizing: border-box;
  }

  body:not(.print-report-mode) #invoice-print-container * {
    color: black !important;
    background: transparent !important;
  }
  
  /* Zero margins to maximize print area on roll */
  @page {
    margin: 0 !important;
    size: auto;
  }

  /* Custom Print Report Styles */
  .print-report-mode #view-reports {
    display: block !important;
    background: white !important;
    color: black !important;
    padding: 20px !important;
  }

  .print-report-mode .sidebar,
  .print-report-mode .header-bar,
  .print-report-mode .filter-bar,
  .print-report-mode .btn,
  .print-report-mode .stats-grid,
  .print-report-mode .logo-container {
    display: none !important;
  }

  .print-report-mode .glass-card {
    background: white !important;
    border: none !important;
    box-shadow: none !important;
    color: black !important;
    padding: 0 !important;
    margin-bottom: 30px !important;
  }

  .print-report-mode .data-table th, 
  .print-report-mode .data-table td {
    border-bottom: 1px solid #000 !important;
    color: black !important;
    padding: 8px !important;
  }
}

/* Tablet view styling */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
  .reports-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile responsive styling */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }
  
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    padding: 20px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  
  .mobile-nav-toggle {
    display: flex;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .header-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
  }
  
  .date-badge {
    display: none !important;
  }
  
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-wrapper {
    max-width: none;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Sidebar backdrop for mobile view */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 95;
}
.sidebar-backdrop.active {
  display: block;
}

/* User Profile Widget in Sidebar */
.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 10px;
}

.profile-avatar-container {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.profile-avatar-container:hover {
  transform: scale(1.05);
}

.profile-avatar-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.profile-avatar-container:hover .profile-avatar-overlay {
  opacity: 1;
}

.profile-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Login Screen Overlay */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-main);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.07) 0%, transparent 45%);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
  padding: 40px 30px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.6);
  animation: loginScaleIn 0.3s ease;
}

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



/* Theme-safe login controls and copyright */
.login-form-control {
  background: rgba(10, 15, 30, 0.7);
  border: 1px solid var(--border-light);
  color: var(--text-main);
}

.form-control::placeholder {
  color: var(--text-muted);
  opacity: 0.82;
}

.login-copyright {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

/* Light Theme Variables & Styles */
body.light-theme {
  --bg-main: #f1f5f9;
  --bg-surface: rgba(255, 255, 255, 0.65);
  --bg-card: rgba(255, 255, 255, 0.85);
  --border-light: rgba(15, 23, 42, 0.08);
  --border-glow: rgba(16, 185, 129, 0.25);
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  --primary: #10b981;
  --secondary: #2563eb;
  
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.04) 0%, transparent 40%);
}

body.light-theme .sidebar {
  background: rgba(255, 255, 255, 0.9);
  border-right: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .logo-text {
  background: linear-gradient(to right, #0f172a, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.light-theme .nav-item a {
  color: #475569;
}

body.light-theme .nav-item a:hover, body.light-theme .nav-item.active a {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.04);
}

body.light-theme .nav-item.active a {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.02) 100%);
  border-left: 3px solid var(--primary);
  box-shadow: inset 5px 0 15px rgba(16, 185, 129, 0.02);
}

body.light-theme .form-control {
  background: rgba(255, 255, 255, 0.8);
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

body.light-theme .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

body.light-theme .glass-card {
  box-shadow: 0 8px 32px 0 rgba(148, 163, 184, 0.12);
}

body.light-theme .data-table th {
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
}

body.light-theme .data-table td {
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
}

body.light-theme .data-table tbody tr:hover {
  background-color: rgba(15, 23, 42, 0.02);
}

body.light-theme .modal-overlay {
  background: rgba(15, 23, 42, 0.4);
}

body.light-theme select option {
  background: white !important;
  color: #0f172a !important;
}

body.light-theme #role-selector {
  color: #0f172a !important;
}

body.light-theme .logo-details .logo-subtext {
  color: #64748b;
}

body.light-theme .status-dot {
  box-shadow: 0 0 8px var(--primary);
}

body.light-theme .header-actions .date-badge {
  background: rgba(255, 255, 255, 0.8);
  color: #475569;
}

body.light-theme .header-actions div select {
  color: #0f172a;
}



/* Complete light-theme contrast corrections */
body.light-theme .mobile-nav-toggle,
body.light-theme .header-icon-btn,
body.light-theme #notification-bell,
body.light-theme #theme-toggle-btn,
body.light-theme #logout-btn {
  color: #0f172a;
}

body.light-theme .btn-secondary {
  background: rgba(255, 255, 255, 0.92);
  border-color: #cbd5e1;
  color: #0f172a;
}

body.light-theme .btn-secondary:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}

body.light-theme .close-btn:hover {
  color: #0f172a;
}

body.light-theme .login-card {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
}

body.light-theme .login-form-control,
body.light-theme #login-role,
body.light-theme #login-password {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a;
}

body.light-theme .login-form-control::placeholder,
body.light-theme #login-password::placeholder {
  color: #64748b !important;
  opacity: 1;
}

body.light-theme select,
body.light-theme select.form-control,
body.light-theme #role-selector {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a;
}

body.light-theme select option {
  background: #ffffff !important;
  color: #0f172a !important;
}

body.light-theme .filter-bar {
  background: rgba(255, 255, 255, 0.78) !important;
}

body.light-theme #notification-dropdown {
  background: rgba(255, 255, 255, 0.98);
  color: #0f172a;
  border-color: #cbd5e1 !important;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18) !important;
}

body.light-theme .data-table tbody tr,
body.light-theme .data-table tbody tr:hover {
  color: #0f172a;
}

body.light-theme .data-table td::before {
  color: #475569;
}

body.light-theme .sidebar-footer,
body.light-theme .login-copyright {
  color: #64748b;
}

/* Pagination Styling */
.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border-light);
  padding-top: 15px;
}

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

.pagination-buttons {
  display: flex;
  gap: 6px;
}

.pagination-btn {
  padding: 6px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}

.pagination-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border-color: var(--primary);
}

.pagination-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

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

body.light-theme .pagination-btn {
  background: white;
  border-color: #cbd5e1;
  color: #0f172a;
}

body.light-theme .pagination-btn:hover:not(:disabled) {
  background: #f1f5f9;
  color: #0f172a;
  border-color: var(--primary);
}

body.light-theme .pagination-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Pagination Limit Selector Styling */
.pagination-limit {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.pagination-limit select {
  padding: 4px 8px;
  background: rgba(10, 15, 30, 0.5);
  border: 1px solid var(--border-light);
  color: white;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  font-family: var(--font-body);
}

body.light-theme .pagination-limit select {
  background: white;
  border-color: #cbd5e1;
  color: #0f172a;
}

/* Responsive mobile pagination tweaks */
@media (max-width: 580px) {
  .pagination-container {
    flex-direction: column;
    gap: 12px;
    align-items: center;
    text-align: center;
  }
  .pagination-buttons {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
  }
  .pagination-info {
    order: -1;
  }
}



/* Report layout refinements */
.report-summary-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

#view-reports .table-container {
  width: 100%;
  overflow-x: auto;
}

#view-reports .data-table {
  width: 100%;
  min-width: 640px;
  table-layout: auto;
  border-collapse: collapse;
}

#view-reports .data-table th,
#view-reports .data-table td {
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
}

#view-reports .data-table th:last-child,
#view-reports .data-table td:last-child {
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .report-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .report-summary-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   MOBILE RESPONSIVE REFINEMENTS
   ========================================================= */
.header-role-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  min-width: 0;
}

.notification-area {
  position: relative;
}

.dashboard-chart-header,
.report-toolbar,
.report-export-actions,
.report-filter-grid,
.quick-actions-buttons,
.payment-method-actions {
  display: flex;
}

.dashboard-chart-header,
.report-toolbar {
  justify-content: space-between;
  align-items: center;
}

.dashboard-chart-header {
  margin-bottom: 15px;
}

.dashboard-chart-legend,
.report-export-actions {
  display: flex;
  gap: 8px;
}

.dashboard-chart-legend {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.quick-actions-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.quick-actions-buttons {
  flex-direction: column;
  gap: 12px;
}

.report-toolbar {
  gap: 16px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 15px;
  margin-bottom: 20px;
}

.report-filter-grid {
  gap: 15px;
  flex-wrap: wrap;
  width: 100%;
}

.settings-shell {
  max-width: 650px;
  margin: 0 auto;
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  padding: 20px;
  border-radius: 12px;
}

.payment-method-actions {
  gap: 15px;
  justify-content: center;
}

@media screen and (max-width: 768px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    overflow-x: hidden;
  }

  body {
    min-height: 100dvh;
  }

  .app-container {
    min-height: 100dvh;
  }

  .sidebar {
    width: min(84vw, 290px);
    height: 100dvh;
    overflow: hidden;
  }

  .nav-menu {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px 12px;
    gap: 5px;
  }

  .nav-item a {
    padding: 11px 13px;
    font-size: 0.9rem;
  }

  .logo-container {
    padding: 16px;
  }

  .sidebar-profile {
    padding: 13px 16px;
    margin-bottom: 0;
  }

  .sidebar-footer {
    padding: 14px 16px;
  }

  .main-content {
    width: 100%;
    min-width: 0;
    padding: 12px;
  }

  .header-bar {
    width: 100%;
    margin-bottom: 14px;
    padding-bottom: 12px;
    gap: 10px;
  }

  .header-title-area {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    column-gap: 10px;
    align-items: center;
  }

  .header-title-area h1 {
    min-width: 0;
    font-size: clamp(1.15rem, 5vw, 1.45rem);
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .header-title-area p {
    display: none;
  }

  .mobile-nav-toggle {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .header-actions {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px 40px 40px;
    gap: 8px;
    align-items: center;
  }

  .header-role-selector {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 5px 8px;
    gap: 5px;
    overflow: hidden;
  }

  .header-role-selector > span {
    flex: 0 0 auto;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  #role-selector {
    width: 100% !important;
    min-width: 0;
    height: 30px;
    padding: 2px 20px 2px 4px !important;
    text-overflow: ellipsis;
  }

  #theme-toggle-btn {
    grid-column: 2;
  }

  .notification-area {
    grid-column: 3;
    margin: 0 !important;
    width: 40px;
    height: 40px;
  }

  #logout-btn {
    grid-column: 4;
  }

  .header-icon-btn,
  #notification-bell,
  #logout-btn,
  #theme-toggle-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
    margin: 0 !important;
    border-radius: 10px;
  }

  #notification-dropdown {
    position: fixed !important;
    top: 112px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100dvh - 130px);
    overflow: hidden;
    padding: 12px !important;
    z-index: 1200 !important;
  }

  #notification-list {
    max-height: calc(100dvh - 210px) !important;
  }

  .date-badge {
    display: none !important;
  }

  .glass-card {
    min-width: 0;
    padding: 14px;
    border-radius: 12px;
  }

  .glass-card:hover {
    transform: none;
  }

  /* Dashboard dibuat dua kolom agar tidak terlalu panjang. */
  .stats-grid,
  #view-dashboard .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px;
    margin-bottom: 14px;
  }

  .stat-card {
    min-height: 126px;
    padding: 12px;
  }

  .stat-header {
    gap: 6px;
    margin-bottom: 10px;
  }

  .stat-title {
    max-width: calc(100% - 34px);
    font-size: 0.66rem;
    line-height: 1.25;
    letter-spacing: 0.35px;
  }

  .stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 0.9rem;
    flex: 0 0 30px;
  }

  .stat-value {
    font-size: clamp(1rem, 4.4vw, 1.28rem);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 7px;
  }

  .stat-trend {
    min-width: 0;
    font-size: 0.68rem;
    line-height: 1.3;
    gap: 3px;
    overflow-wrap: anywhere;
  }

  #stat-monthly-income-breakdown {
    font-size: 0.62rem !important;
    line-height: 1.25;
  }

  .dashboard-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px;
  }

  .dashboard-chart-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
  }

  .dashboard-chart-header h3,
  .quick-actions-card h3,
  #view-dashboard > .glass-card h3 {
    font-size: 1rem;
    line-height: 1.3;
  }

  .dashboard-chart-legend {
    width: 100%;
    flex-wrap: wrap;
    gap: 5px 12px;
    font-size: 0.7rem;
  }

  .chart-container {
    height: 190px;
    margin-top: 6px;
  }

  .chart-container canvas {
    display: block;
    max-width: 100%;
  }

  .quick-actions-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .quick-actions-buttons .btn {
    width: 100%;
    min-width: 0;
    padding: 9px 7px;
    font-size: 0.76rem;
    line-height: 1.25;
    white-space: normal;
  }

  .quick-actions-buttons .btn:nth-child(3) {
    grid-column: 1 / -1;
  }

  #view-dashboard > .glass-card {
    margin-top: 12px !important;
  }

  /* Filter dan tombol aksi pada semua menu. */
  .filter-bar {
    width: 100%;
    gap: 10px;
    margin-bottom: 14px;
  }

  .search-wrapper {
    width: 100%;
    max-width: none;
  }

  .filters-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .filters-actions > *,
  .filters-actions .form-control,
  .filters-actions .btn {
    width: 100% !important;
    min-width: 0;
  }

  #view-customers .filters-actions .btn {
    grid-column: 1 / -1;
  }

  #csv-actions-row {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch !important;
    gap: 8px !important;
  }

  #csv-actions-row .btn {
    width: 100%;
    min-width: 0;
    padding: 8px 6px;
    white-space: normal;
    line-height: 1.25;
  }

  #csv-actions-row .btn:nth-of-type(3) {
    grid-column: 1 / -1;
  }

  /* Toolbar laporan dan filter laporan. */
  .report-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 12px;
    margin-bottom: 14px;
  }

  .report-toolbar h3 {
    font-size: 1.05rem;
    line-height: 1.3;
  }

  .report-export-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .report-export-actions .btn {
    width: 100%;
    min-width: 0;
    white-space: normal;
    line-height: 1.2;
  }

  #view-reports > .glass-card > .filter-bar {
    padding: 12px !important;
  }

  .report-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .report-filter-grid > div {
    min-width: 0 !important;
    width: 100%;
    flex: none !important;
  }

  .report-filter-grid > div:first-child,
  .report-filter-grid > div:last-child {
    grid-column: 1 / -1;
  }

  .report-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
  }

  .report-summary-grid > .glass-card {
    padding: 11px !important;
    min-height: 102px;
  }

  .report-summary-grid > .glass-card:last-child {
    grid-column: 1 / -1;
  }

  .report-summary-grid > .glass-card > span {
    font-size: 0.65rem !important;
    line-height: 1.25;
  }

  .report-summary-grid > .glass-card > div:nth-child(2) {
    font-size: 1.05rem !important;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .reports-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px;
  }

  #view-reports .table-container {
    max-height: none !important;
    overflow: visible !important;
  }

  /* Semua tabel berubah menjadi kartu vertikal yang tetap terstruktur. */
  .table-container {
    width: 100%;
    max-width: 100%;
    overflow: visible;
    margin-top: 10px;
  }

  .data-table,
  #view-reports .data-table {
    display: block;
    width: 100%;
    min-width: 0 !important;
    table-layout: auto;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: grid;
    width: 100%;
    gap: 9px;
  }

  .data-table tbody tr {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.025);
    overflow: hidden;
  }

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

  .data-table tbody td,
  #view-reports .data-table tbody td {
    display: grid;
    grid-template-columns: minmax(96px, 40%) minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 8px 2px !important;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.79rem;
    line-height: 1.35;
    text-align: right;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  .data-table tbody td::before {
    content: attr(data-label);
    min-width: 0;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.25px;
    overflow-wrap: anywhere;
  }

  .data-table tbody td:last-child {
    border-bottom: 0;
  }

  .data-table tbody td > * {
    min-width: 0;
    max-width: 100%;
  }

  .data-table tbody td .badge {
    justify-self: end;
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  .data-table tbody td:last-child > div {
    display: flex !important;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px !important;
  }

  .data-table tbody td:last-child .btn {
    max-width: 100%;
    padding: 6px 8px;
    font-size: 0.72rem;
    white-space: normal;
    line-height: 1.2;
  }

  .data-table tbody tr.mobile-empty-row {
    padding: 0;
  }

  .data-table tbody tr.mobile-empty-row td,
  .data-table tbody td[colspan] {
    display: block;
    padding: 18px 10px !important;
    text-align: center !important;
    border-bottom: 0;
  }

  .data-table tbody tr.mobile-empty-row td::before,
  .data-table tbody td[colspan]::before {
    display: none;
  }

  /* Pagination tetap ringkas dan tidak menambah banyak tinggi. */
  .pagination-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    padding-top: 10px;
    text-align: left;
  }

  .pagination-info {
    grid-column: 1;
    grid-row: 1;
    font-size: 0.72rem;
  }

  .pagination-limit {
    grid-column: 2;
    grid-row: 1;
    font-size: 0.72rem;
  }

  .pagination-buttons {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
  }

  .pagination-btn {
    min-width: 32px;
    padding: 6px 9px;
  }

  /* Form, modal, dan menu pengaturan. */
  .form-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .form-group {
    margin-bottom: 14px;
  }

  .form-control {
    min-height: 42px;
    font-size: 16px;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 8px;
  }

  .modal-content {
    max-width: 100%;
    max-height: 94dvh;
    padding: 16px;
    border-radius: 14px 14px 8px 8px;
  }

  .modal-header {
    position: sticky;
    top: -16px;
    z-index: 2;
    margin: -16px -16px 14px;
    padding: 14px 16px 10px;
    background: color-mix(in srgb, var(--bg-main) 88%, transparent);
    backdrop-filter: blur(16px);
  }

  .modal-header h3 {
    font-size: 1.05rem;
  }

  .modal-footer {
    position: sticky;
    bottom: -16px;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 16px -16px -16px;
    padding: 12px 16px 16px;
    background: color-mix(in srgb, var(--bg-main) 88%, transparent);
    backdrop-filter: blur(16px);
  }

  .modal-footer .btn {
    width: 100%;
    min-width: 0;
  }

  .payment-method-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
  }

  .settings-shell {
    max-width: none;
    width: 100%;
  }

  .settings-panel {
    padding: 14px;
  }

  .settings-panel > .btn,
  .settings-panel form > .btn {
    width: 100%;
  }

  .settings-panel h4 {
    line-height: 1.35;
  }

  #view-packages .filter-bar {
    justify-content: stretch !important;
  }

  #view-packages .filter-bar .btn {
    width: 100%;
  }

  .login-overlay {
    padding: 12px;
  }

  .login-card {
    max-height: 96dvh;
    overflow-y: auto;
    padding: 24px 18px;
  }
}

@media screen and (max-width: 420px) {
  .main-content {
    padding: 10px;
  }

  .header-actions {
    grid-template-columns: minmax(0, 1fr) 38px 38px 38px;
    gap: 6px;
  }

  .header-icon-btn,
  #notification-bell,
  #logout-btn,
  #theme-toggle-btn,
  .notification-area {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px;
  }

  .header-role-selector {
    height: 38px;
    padding: 4px 6px;
  }

  .header-role-selector > span {
    display: none;
  }

  .stats-grid,
  #view-dashboard .stats-grid {
    gap: 7px;
  }

  .stat-card {
    min-height: 120px;
    padding: 10px;
  }

  .filters-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  #view-customers .filters-actions .btn {
    grid-column: auto;
  }

  .data-table tbody td,
  #view-reports .data-table tbody td {
    grid-template-columns: minmax(88px, 38%) minmax(0, 1fr);
    gap: 8px;
    font-size: 0.76rem;
  }

  .report-summary-grid > .glass-card {
    min-height: 96px;
  }
}

@media screen and (max-width: 340px) {
  .stats-grid,
  #view-dashboard .stats-grid,
  .report-summary-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .report-summary-grid > .glass-card:last-child {
    grid-column: auto;
  }
}

/* Prevent wide desktop tables from forcing the entire app outside the viewport. */
@media screen {
  .main-content {
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
  }
}


/* =========================================================
   MOBILE LAYOUT FINAL OVERRIDES - 2026-06-14
   ========================================================= */
.sidebar-logout-btn {
  width: calc(100% - 24px);
  margin: 8px 12px 4px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.sidebar-logout-btn:hover {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
}

.sidebar-logout-icon {
  width: 22px;
  text-align: center;
  font-size: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
}

.header-icon-btn,
#theme-toggle-btn,
#notification-bell {
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  margin: 0;
  border-radius: 11px;
  background: var(--bg-surface);
  font-size: 1.1rem;
  cursor: pointer;
}

.notification-area {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}

#notification-bell {
  position: relative;
}

#notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 1px 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bg-main);
  border-radius: 999px;
  font-size: 0.64rem;
  line-height: 1;
}

.notification-dropdown {
  position: absolute;
  top: 50px;
  right: 0;
  width: min(340px, calc(100vw - 28px));
  max-height: min(430px, 62vh);
  padding: 12px;
  overflow: hidden;
  z-index: 1300;
  border: 1px solid var(--border-light);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  text-align: left;
}

.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 9px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.notification-dropdown-header h4 {
  margin: 0;
  min-width: 0;
  font-family: var(--font-title);
  font-size: 0.88rem;
  line-height: 1.25;
}

#notification-title-count {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 400;
}

.notification-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.notification-header-actions .btn {
  padding: 5px 7px;
  font-size: 0.67rem;
}

.notification-close-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.notification-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(330px, 48vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media screen and (max-width: 768px) {
  .main-content {
    width: 100% !important;
    max-width: 100% !important;
    padding: 10px !important;
  }

  .header-bar {
    width: 100%;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center !important;
    gap: 8px !important;
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  .header-title-area {
    width: auto !important;
    min-width: 0;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
  }

  .mobile-nav-toggle {
    width: 38px;
    height: 38px;
  }

  .header-title-area h1 {
    font-size: clamp(1.02rem, 4.8vw, 1.35rem);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-title-area p,
  .date-badge,
  .header-role-selector,
  #logout-btn {
    display: none !important;
  }

  .header-actions {
    width: auto !important;
    display: flex !important;
    grid-template-columns: none !important;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-left: auto;
  }

  .header-icon-btn,
  #theme-toggle-btn,
  #notification-bell,
  .notification-area {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
  }

  .notification-area {
    flex-basis: 38px;
  }

  .notification-dropdown {
    position: fixed !important;
    top: 58px !important;
    right: 10px !important;
    left: auto !important;
    width: min(326px, calc(100vw - 20px)) !important;
    max-width: calc(100vw - 20px) !important;
    max-height: min(390px, 58dvh) !important;
    padding: 11px !important;
  }

  .notification-list {
    max-height: min(285px, 43dvh) !important;
  }

  /* Dashboard status wajib tetap dua kolom, termasuk layar 320 px. */
  #view-dashboard > .stats-grid,
  #view-dashboard .stats-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
  }

  #view-dashboard .stat-card {
    min-width: 0;
    min-height: 112px;
    padding: 9px !important;
  }

  #view-dashboard .stat-title {
    max-width: calc(100% - 28px);
    font-size: 0.61rem;
    line-height: 1.2;
    letter-spacing: 0.15px;
  }

  #view-dashboard .stat-icon {
    width: 27px;
    height: 27px;
    flex-basis: 27px;
    font-size: 0.78rem;
  }

  #view-dashboard .stat-value {
    font-size: clamp(0.88rem, 4.1vw, 1.12rem);
    line-height: 1.15;
  }

  #view-dashboard .stat-trend {
    font-size: 0.62rem;
    line-height: 1.24;
  }

  #stat-monthly-income-breakdown {
    font-size: 0.56rem !important;
  }

  /* Pelanggan: kartu dua kolom yang tidak menumpuk secara acak. */
  #view-customers > .glass-card {
    padding: 10px !important;
  }

  #view-customers .filter-bar,
  #view-customers .filters-actions {
    gap: 7px;
  }

  #view-customers .filters-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #view-customers .filters-actions .btn {
    grid-column: 1 / -1 !important;
  }

  #view-customers #csv-actions-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #view-customers #csv-actions-row .btn:nth-of-type(3) {
    grid-column: 1 / -1;
  }

  #table-customers tbody {
    display: grid !important;
    gap: 10px;
  }

  #table-customers tbody tr:not(.mobile-empty-row) {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
    padding: 8px;
    overflow: visible;
  }

  #table-customers tbody td {
    display: block !important;
    width: auto !important;
    min-width: 0;
    padding: 8px !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 8px;
    background: var(--bg-surface);
    text-align: left !important;
    overflow-wrap: anywhere;
  }

  #table-customers tbody td::before {
    display: block !important;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.2px;
    text-align: left;
  }

  #table-customers tbody td:nth-child(1),
  #table-customers tbody td:nth-child(2),
  #table-customers tbody td:nth-child(6),
  #table-customers tbody td:nth-child(8) {
    grid-column: 1 / -1;
  }

  #table-customers tbody td .badge {
    justify-self: start !important;
    display: inline-flex;
    width: auto;
    max-width: 100%;
  }

  #table-customers tbody td:last-child > div {
    justify-content: flex-start !important;
  }

  #table-customers tbody td:last-child .btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
  }

  /* Laporan dibuat selebar layar; nilai tidak dipaksa ke kolom sempit. */
  #view-reports > .glass-card {
    width: 100%;
    max-width: 100%;
    padding: 10px !important;
  }

  #view-reports .reports-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    max-width: 100%;
    gap: 10px;
  }

  #report-card-income,
  #report-card-expense,
  #report-card-unpaid {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 10px !important;
    margin-top: 10px !important;
  }

  #view-reports .data-table tbody tr:not(.mobile-empty-row) {
    width: 100%;
    padding: 7px 9px;
  }

  #view-reports .data-table tbody td {
    display: block !important;
    width: 100% !important;
    padding: 8px 2px !important;
    text-align: left !important;
  }

  #view-reports .data-table tbody td::before {
    display: block !important;
    margin-bottom: 4px;
    text-align: left !important;
  }

  #view-reports .data-table tbody td .badge {
    justify-self: start !important;
  }
}

@media screen and (max-width: 340px) {
  /* Jangan kembali menjadi satu kolom pada HP kecil. */
  #view-dashboard > .stats-grid,
  #view-dashboard .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #view-dashboard .stat-card {
    min-height: 108px;
    padding: 8px !important;
  }

  #view-dashboard .stat-title {
    font-size: 0.56rem;
  }

  #view-dashboard .stat-value {
    font-size: 0.82rem;
  }

  .notification-dropdown {
    right: 7px !important;
    width: calc(100vw - 14px) !important;
    max-width: calc(100vw - 14px) !important;
  }
}

/* Notification popover stays compact so the mobile screen remains usable. */
@media screen and (max-width: 768px) {
  .notification-dropdown {
    max-height: min(330px, 46dvh) !important;
  }

  .notification-list {
    max-height: min(225px, 31dvh) !important;
  }
}


/* =========================================================
   MOBILE FIX V3 - HEADER, RECENT LEDGER, CUSTOMER GRID, LOGOUT
   ========================================================= */
.nav-item-logout {
  width: 100%;
}

.nav-item-logout .sidebar-logout-btn {
  width: 100%;
  margin: 0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(239, 68, 68, 0.24);
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.07);
  color: var(--danger);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.nav-item-logout .sidebar-logout-btn:hover {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.42);
}

@media screen and (max-width: 768px) {
  /* Header controls are anchored independently so they can never overlap. */
  .header-bar {
    position: relative !important;
    display: block !important;
    min-height: 42px;
    padding-right: 92px !important;
    box-sizing: border-box;
  }

  .header-title-area {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: 38px minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  .header-actions {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    width: 84px !important;
    height: 38px !important;
    display: grid !important;
    grid-template-columns: 38px 38px !important;
    grid-template-rows: 38px !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: end !important;
  }

  #theme-toggle-btn {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  .notification-area {
    grid-column: 2 !important;
    grid-row: 1 !important;
    position: relative !important;
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    flex: none !important;
    margin: 0 !important;
  }

  #theme-toggle-btn,
  #notification-bell {
    position: relative !important;
    inset: auto !important;
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
  }

  #notification-badge {
    top: -5px !important;
    right: -5px !important;
  }

  /* Put recent transactions directly after status cards on mobile. */
  #view-dashboard {
    display: none;
  }

  #view-dashboard.active {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    min-width: 0;
  }

  #view-dashboard > .stats-grid {
    order: 1;
  }

  #dashboard-recent-card {
    order: 2;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-top: 12px !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  #view-dashboard > .dashboard-layout {
    order: 3;
    margin-top: 12px;
  }

  #dashboard-recent-card .table-container,
  #dashboard-recent-card .data-table,
  #dashboard-recent-ledger {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    visibility: visible !important;
  }

  #dashboard-recent-ledger tr {
    display: block !important;
    width: 100% !important;
    margin-bottom: 8px;
  }

  #dashboard-recent-ledger td {
    display: grid !important;
    grid-template-columns: minmax(84px, 37%) minmax(0, 1fr) !important;
    width: 100% !important;
  }

  /* Two customer cards per row, rather than only two fields inside one full-width card. */
  #table-customers tbody {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  #table-customers tbody tr:not(.mobile-empty-row) {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 100%;
    padding: 7px !important;
    box-sizing: border-box;
  }

  #table-customers tbody tr.mobile-empty-row {
    grid-column: 1 / -1 !important;
  }

  #table-customers tbody td,
  #table-customers tbody td:nth-child(n) {
    display: block !important;
    grid-column: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 6px !important;
    margin: 0 !important;
    box-sizing: border-box;
    font-size: 0.68rem !important;
    line-height: 1.28 !important;
    text-align: left !important;
  }

  #table-customers tbody td::before {
    display: block !important;
    margin-bottom: 3px !important;
    font-size: 0.52rem !important;
    line-height: 1.15 !important;
  }

  #table-customers tbody td > div,
  #table-customers tbody td span {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  #table-customers tbody td .badge {
    display: inline-flex !important;
    width: auto !important;
    max-width: 100%;
    padding: 3px 5px !important;
    font-size: 0.56rem !important;
    line-height: 1.15 !important;
  }

  #table-customers tbody td:last-child > div {
    display: grid !important;
    grid-template-columns: repeat(3, 30px) !important;
    justify-content: start !important;
    gap: 5px !important;
  }

  #table-customers tbody td:last-child .btn {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    padding: 0 !important;
    font-size: 0.72rem !important;
  }

  /* Logout remains immediately below Pengaturan & Backup inside the menu list. */
  .nav-item-logout .sidebar-logout-btn {
    padding: 11px 13px;
    font-size: 0.9rem;
  }
}

@media screen and (max-width: 340px) {
  .header-bar {
    padding-right: 88px !important;
  }

  .header-actions {
    width: 80px !important;
    grid-template-columns: 36px 36px !important;
    gap: 8px !important;
  }

  #theme-toggle-btn,
  #notification-bell,
  .notification-area {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
  }

  #table-customers tbody {
    gap: 6px !important;
  }

  #table-customers tbody tr:not(.mobile-empty-row) {
    padding: 5px !important;
  }

  #table-customers tbody td,
  #table-customers tbody td:nth-child(n) {
    padding: 5px !important;
    font-size: 0.63rem !important;
  }
}

/* Filter-first workflow: desktop remains instant, mobile waits for an explicit filter action. */
.mobile-filter-actions {
  display: none;
}

.filter-required-state {
  display: none;
  min-height: 128px;
  padding: 24px 18px;
  border: 1px dashed var(--border-light);
  border-radius: 12px;
  background: var(--bg-surface);
  color: var(--text-muted);
  text-align: center;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
}

.filter-required-state strong {
  color: var(--text-main);
  font-size: 0.98rem;
}

.filter-required-state span {
  max-width: 580px;
  font-size: 0.84rem;
  line-height: 1.5;
}

.filter-results-block {
  display: block;
  min-width: 0;
  width: 100%;
}

@media screen and (max-width: 768px) {
  .mobile-filter-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    margin-top: 8px;
  }

  .mobile-filter-actions .btn {
    width: 100%;
    min-width: 0;
    padding: 10px 8px;
    font-size: 0.78rem;
    white-space: normal;
    line-height: 1.25;
  }

  .filter-required-state {
    display: flex;
    min-height: 118px;
    padding: 20px 14px;
    margin-top: 4px;
  }

  .filter-results-block {
    display: none;
  }

  .report-filter-actions {
    margin-top: 12px;
  }

  .pagination-container {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    gap: 8px;
  }

  .pagination-limit,
  .pagination-info,
  .pagination-buttons {
    max-width: 100%;
  }

  .pagination-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .pagination-btn {
    min-width: 34px;
    padding: 7px 8px;
    font-size: 0.72rem;
  }
}


/* =========================================================
   LOGOUT MENU ICON & DISTINCT BACKGROUND - V5
   ========================================================= */
.nav-item-logout .sidebar-logout-btn {
  min-height: 44px;
  padding: 12px 16px;
  gap: 12px;
  border: 1px solid rgba(239, 68, 68, 0.42);
  border-left: 3px solid #ef4444;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.22) 0%, rgba(239, 68, 68, 0.08) 100%);
  color: #fca5a5;
  box-shadow: inset 5px 0 15px rgba(239, 68, 68, 0.08);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-item-logout .sidebar-logout-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  font-size: initial;
  color: #f87171;
  transition: transform 0.2s ease, color 0.2s ease;
}

.nav-item-logout .sidebar-logout-btn:hover,
.nav-item-logout .sidebar-logout-btn:focus-visible {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.34) 0%, rgba(239, 68, 68, 0.14) 100%);
  border-color: rgba(248, 113, 113, 0.72);
  color: #ffffff;
  outline: none;
}

.nav-item-logout .sidebar-logout-btn:hover .sidebar-logout-icon,
.nav-item-logout .sidebar-logout-btn:focus-visible .sidebar-logout-icon {
  color: #ffffff;
  transform: translateX(2px);
}

body.light-theme .nav-item-logout .sidebar-logout-btn {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.05) 100%);
  border-color: rgba(220, 38, 38, 0.32);
  border-left-color: #dc2626;
  color: #b91c1c;
  box-shadow: inset 5px 0 15px rgba(239, 68, 68, 0.05);
}

body.light-theme .nav-item-logout .sidebar-logout-icon {
  color: #dc2626;
}

body.light-theme .nav-item-logout .sidebar-logout-btn:hover,
body.light-theme .nav-item-logout .sidebar-logout-btn:focus-visible {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.25) 0%, rgba(239, 68, 68, 0.10) 100%);
  border-color: rgba(220, 38, 38, 0.55);
  color: #7f1d1d;
}

body.light-theme .nav-item-logout .sidebar-logout-btn:hover .sidebar-logout-icon,
body.light-theme .nav-item-logout .sidebar-logout-btn:focus-visible .sidebar-logout-icon {
  color: #991b1b;
}

/* =========================================================
   FIELD OPERATIONS / PENAGIHAN LAPANGAN - V8
   ========================================================= */
.fieldops-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  margin-bottom: 18px;
  border-left: 4px solid var(--secondary);
}
.fieldops-notice strong { display: block; margin-bottom: 5px; color: var(--text-main); }
.fieldops-notice p { margin: 0; color: var(--text-muted); font-size: .84rem; line-height: 1.5; }
.fieldops-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.fieldops-summary-card { padding: 16px; min-width: 0; }
.fieldops-summary-card span { display: block; color: var(--text-muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; }
.fieldops-summary-card strong { display: block; margin: 7px 0 2px; color: var(--text-main); font-family: var(--font-title); font-size: 1.25rem; overflow-wrap: anywhere; }
.fieldops-summary-card small { color: var(--text-muted); font-size: .72rem; }
.fieldops-section-card { padding: 18px; margin-bottom: 18px; min-width: 0; }
.section-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-heading-row h3 { font-family: var(--font-title); font-size: 1rem; margin: 0 0 5px; }
.section-heading-row p { color: var(--text-muted); font-size: .78rem; line-height: 1.45; margin: 0; }
.fieldops-officer-filter { width: min(230px, 100%); }
.payment-context {
  display: grid;
  gap: 5px;
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--bg-surface);
}
.payment-context strong { color: var(--text-main); }
.payment-context span { color: var(--text-muted); font-size: .8rem; }
.payment-context b { color: var(--success); font-size: 1.05rem; }
.cash-warning-box {
  padding: 12px 14px;
  border: 1px solid rgba(245,158,11,.35);
  border-radius: 10px;
  background: rgba(245,158,11,.09);
  color: var(--warning);
  font-size: .8rem;
  line-height: 1.45;
  margin-bottom: 15px;
}
.form-help { display: block; margin-top: 6px; color: var(--text-muted); font-size: .72rem; line-height: 1.4; }
.checkbox-form-group { display: flex; align-items: center; }
.checkbox-label { display: flex; align-items: flex-start; gap: 9px; color: var(--text-main); font-size: .82rem; line-height: 1.45; cursor: pointer; }
.checkbox-label input { margin-top: 3px; flex: 0 0 auto; }
.proof-preview-modal { max-width: 760px; }
.proof-meta { display: grid; gap: 5px; margin-bottom: 12px; color: var(--text-muted); font-size: .8rem; }
.proof-meta strong { color: var(--text-main); font-size: .95rem; }
.proof-image { display: block; max-width: 100%; max-height: 65vh; margin: 0 auto; border-radius: 10px; object-fit: contain; background: #fff; }
.proof-frame { width: 100%; height: 65vh; border: 0; border-radius: 10px; background: #fff; }
.cell-subtext { margin-top: 3px; color: var(--text-muted); font-size: .72rem; }
.table-action-group { display: flex; flex-wrap: wrap; gap: 6px; }
.empty-table-cell { text-align: center !important; color: var(--text-muted) !important; padding: 28px 14px !important; }

@media screen and (max-width: 1024px) {
  .fieldops-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 768px) {
  .fieldops-notice { align-items: stretch; flex-direction: column; padding: 14px; }
  .fieldops-notice .btn { width: 100%; }
  .fieldops-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  .fieldops-summary-card { padding: 11px 10px; }
  .fieldops-summary-card span { font-size: .62rem; line-height: 1.25; }
  .fieldops-summary-card strong { font-size: .92rem; }
  .fieldops-summary-card small { font-size: .6rem; }
  .fieldops-section-card { padding: 12px; }
  .section-heading-row { flex-direction: column; gap: 10px; }
  .fieldops-officer-filter, .section-heading-row .btn { width: 100%; }
  .table-action-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .table-action-group .btn { width: 100%; min-width: 0; white-space: normal; }
  #table-transfer-verification .table-action-group { grid-template-columns: 1fr; }
  .proof-frame { height: 55vh; }
}
