/* ============================================
   FinanceKu - Design System & Styles
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- CSS Custom Properties ---- */
:root {
  /* Primary Colors */
  --primary-900: #1E3A8A;
  --primary-800: #1E40AF;
  --primary-700: #1D4ED8;
  --primary-600: #2563EB;
  --primary-500: #3B82F6;
  --primary-400: #60A5FA;
  --primary-300: #93BBFD;
  --primary-200: #BFDBFE;
  --primary-100: #DBEAFE;
  --primary-50: #EFF6FF;

  /* Neutral Colors */
  --gray-900: #111827;
  --gray-800: #1F2937;
  --gray-700: #374151;
  --gray-600: #4B5563;
  --gray-500: #6B7280;
  --gray-400: #9CA3AF;
  --gray-300: #D1D5DB;
  --gray-200: #E5E7EB;
  --gray-100: #F3F4F6;
  --gray-50: #F9FAFB;
  --white: #FFFFFF;

  /* Semantic Colors */
  --success-600: #16A34A;
  --success-500: #22C55E;
  --success-100: #DCFCE7;
  --success-50: #F0FDF4;
  --danger-600: #DC2626;
  --danger-500: #EF4444;
  --danger-100: #FEE2E2;
  --danger-50: #FEF2F2;
  --warning-600: #D97706;
  --warning-500: #F59E0B;
  --warning-100: #FEF3C7;
  --warning-50: #FFFBEB;
  --info-600: #0891B2;
  --info-500: #06B6D4;
  --info-100: #CFFAFE;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 0px;
  --navbar-height: 64px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-xs: 6px;
  --border-radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
}

/* ---- Dark Theme Variables ---- */
[data-theme="dark"] {
  --gray-900: #F9FAFB;
  --gray-800: #F3F4F6;
  --gray-700: #E5E7EB;
  --gray-600: #D1D5DB;
  --gray-500: #9CA3AF;
  --gray-400: #6B7280;
  --gray-300: #4B5563;
  --gray-200: #374151;
  --gray-100: #1F2937;
  --gray-50: #111827;
  --white: #1F2937;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.24);
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--gray-900);
  background-color: var(--gray-50);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: inherit;
}

ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary-900) 0%, #162D6B 100%);
  color: var(--white);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-base);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary-400), var(--primary-500));
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-logo-text span {
  color: var(--primary-300);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.sidebar-nav-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  padding: 8px 12px 4px;
  margin-top: 8px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  margin-bottom: 2px;
}

.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.sidebar-nav-item.active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--white);
  box-shadow: inset 3px 0 0 var(--primary-400);
}

.sidebar-nav-item i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-full);
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: capitalize;
}

.sidebar-logout-btn {
  color: rgba(255, 255, 255, 0.5);
  padding: 6px;
  border-radius: var(--border-radius-xs);
  transition: all var(--transition-fast);
}

.sidebar-logout-btn:hover {
  color: var(--danger-500);
  background: rgba(255, 255, 255, 0.1);
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-base);
}

/* ---- Navbar ---- */
.navbar {
  height: var(--navbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  font-size: 1.25rem;
  transition: all var(--transition-fast);
}

.navbar-toggle:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.navbar-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-900);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-date {
  font-size: 0.8125rem;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.page-section {
  display: none;
}

.page-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  overflow: hidden;
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

.card-header-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-900);
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* ---- Summary Cards (Dashboard) ---- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.summary-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.summary-card.income::after { background: linear-gradient(90deg, var(--success-500), var(--success-600)); }
.summary-card.expense::after { background: linear-gradient(90deg, var(--danger-500), var(--danger-600)); }
.summary-card.balance::after { background: linear-gradient(90deg, var(--primary-500), var(--primary-600)); }

.summary-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.summary-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.summary-card.income .summary-card-icon {
  background: var(--success-100);
  color: var(--success-600);
}

.summary-card.expense .summary-card-icon {
  background: var(--danger-100);
  color: var(--danger-600);
}

.summary-card.balance .summary-card-icon {
  background: var(--primary-100);
  color: var(--primary-600);
}

.summary-card-info {
  flex: 1;
  min-width: 0;
}

.summary-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 4px;
}

.summary-card-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.summary-card.income .summary-card-value { color: var(--success-600); }
.summary-card.expense .summary-card-value { color: var(--danger-600); }
.summary-card.balance .summary-card-value { color: var(--primary-700); }

/* ---- Charts ---- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  font-size: 0.8125rem;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: var(--white);
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--success-500), var(--success-600));
  color: var(--white);
  box-shadow: 0 1px 3px rgba(22, 163, 74, 0.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, var(--success-600), #15803d);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger-500), var(--danger-600));
  color: var(--white);
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
  background: linear-gradient(135deg, var(--danger-600), #b91c1c);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
  transform: translateY(-1px);
}

.btn-outline {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-outline:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-ghost {
  color: var(--gray-600);
  padding: 6px 10px;
}

.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

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

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--border-radius-sm);
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  color: var(--gray-900);
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control::placeholder {
  color: var(--gray-400);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-inline {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-inline .form-group {
  margin-bottom: 0;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ---- Tables ---- */
.table-container {
  overflow-x: auto;
  border-radius: var(--border-radius-sm);
}

.data-table {
  width: 100%;
  font-size: 0.8125rem;
}

.data-table thead {
  background: var(--gray-50);
}

.data-table th {
  padding: 12px 16px;
  font-weight: 600;
  color: var(--gray-600);
  text-align: left;
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--primary-50);
}

.data-table .text-right {
  text-align: right;
}

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

.amount-income {
  color: var(--success-600);
  font-weight: 600;
}

.amount-expense {
  color: var(--danger-600);
  font-weight: 600;
}

.amount-balance {
  color: var(--primary-700);
  font-weight: 700;
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--border-radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  gap: 4px;
}

.badge-income {
  background: var(--success-100);
  color: var(--success-600);
}

.badge-expense {
  background: var(--danger-100);
  color: var(--danger-600);
}

.badge-primary {
  background: var(--primary-100);
  color: var(--primary-700);
}

.badge-warning {
  background: var(--warning-100);
  color: var(--warning-600);
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

/* ---- Advanced Analytics (Dashboard) ---- */
.top-expenses-list {
  display: flex;
  flex-direction: column;
}

.top-expense-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition-fast);
}

.top-expense-item:last-child {
  border-bottom: none;
}

.top-expense-item:hover {
  background: var(--gray-50);
}

.top-expense-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.top-expense-cat {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 0.875rem;
}

.top-expense-date {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.top-expense-amount {
  font-weight: 700;
  color: var(--danger-600);
  font-size: 0.9375rem;
}

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

.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-600);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.8125rem;
  font-weight: 500;
  min-width: 300px;
  max-width: 420px;
  animation: toastSlideIn 0.3s ease;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.toast-success {
  background: var(--success-50);
  color: var(--success-600);
  border: 1px solid var(--success-100);
}

.toast-success::before { background: var(--success-500); }

.toast-error {
  background: var(--danger-50);
  color: var(--danger-600);
  border: 1px solid var(--danger-100);
}

.toast-error::before { background: var(--danger-500); }

.toast-warning {
  background: var(--warning-50);
  color: var(--warning-600);
  border: 1px solid var(--warning-100);
}

.toast-warning::before { background: var(--warning-500); }

.toast-info {
  background: var(--primary-50);
  color: var(--primary-700);
  border: 1px solid var(--primary-100);
}

.toast-info::before { background: var(--primary-500); }

.toast-close {
  margin-left: auto;
  color: inherit;
  opacity: 0.5;
  padding: 4px;
  flex-shrink: 0;
}

.toast-close:hover {
  opacity: 1;
}

@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-exit {
  animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* ---- Loading Spinner ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(2px);
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--primary-100);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  background: var(--gray-100);
  border-radius: var(--border-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--gray-400);
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.empty-state-text {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-bottom: 16px;
}

/* ---- Offline Banner ---- */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--warning-500);
  color: var(--gray-900);
  text-align: center;
  padding: 8px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transform: translateY(-100%);
  transition: transform var(--transition-base);
}

.offline-banner.active {
  transform: translateY(0);
}

.offline-banner i {
  font-size: 1rem;
}

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-700) 50%, var(--primary-500) 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  top: -200px;
  right: -200px;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  bottom: -100px;
  left: -100px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  position: relative;
  z-index: 1;
  animation: loginFadeIn 0.5s ease;
}

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

.login-header {
  background: linear-gradient(135deg, var(--primary-800), var(--primary-600));
  padding: 32px;
  text-align: center;
  color: var(--white);
}

.login-header-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  backdrop-filter: blur(10px);
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.login-header p {
  font-size: 0.8125rem;
  opacity: 0.8;
}

.login-body {
  padding: 32px;
}

.login-body .form-group {
  margin-bottom: 20px;
}

.login-body .form-control {
  padding: 12px 14px;
  border: 2px solid var(--gray-200);
}

.login-body .form-control:focus {
  border-color: var(--primary-500);
}

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.9375rem;
  font-weight: 700;
  border-radius: var(--border-radius-sm);
  margin-top: 8px;
}

.login-footer {
  text-align: center;
  padding: 0 32px 24px;
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.login-footer a {
  color: var(--primary-600);
  font-weight: 600;
  cursor: pointer;
}

.login-footer a:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

/* ---- Page Header / Toolbar ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
}

.page-header-subtitle {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ---- Filter Bar ---- */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
}

.filter-bar .form-group {
  margin-bottom: 0;
  min-width: 140px;
}

/* ---- Report Sections ---- */
.report-section {
  margin-bottom: 32px;
}

.report-section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.report-section-title i {
  color: var(--primary-500);
}

.report-total-row td {
  font-weight: 700 !important;
  color: var(--gray-900) !important;
  border-top: 2px solid var(--gray-300) !important;
  background: var(--gray-50);
}

/* ---- Tab Navigation ---- */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-nav-item {
  padding: 10px 20px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
}

.tab-nav-item:hover {
  color: var(--primary-600);
}

.tab-nav-item.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-500);
}

.tab-content,
.report-tab-content {
  display: none;
}

.tab-content.active,
.report-tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ---- Sidebar Overlay (Mobile) ---- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ---- Confirm Dialog ---- */
.confirm-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: var(--border-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
}

.confirm-icon.warning {
  background: var(--warning-100);
  color: var(--warning-600);
}

.confirm-icon.danger {
  background: var(--danger-100);
  color: var(--danger-600);
}

.confirm-text {
  text-align: center;
  font-size: 0.9375rem;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.confirm-subtext {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--gray-500);
}

/* ---- Backup/Restore ---- */
.backup-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.backup-card {
  text-align: center;
  padding: 32px 20px;
}

.backup-card i {
  font-size: 2.5rem;
  color: var(--primary-500);
  margin-bottom: 12px;
}

.backup-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.backup-card p {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-bottom: 16px;
}

/* ---- Role-Based UI ---- */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--border-radius-full);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  animation: badgePulse 2s ease-in-out infinite;
}

.role-badge.admin {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.15));
  color: var(--warning-600);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.role-badge.user {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(37, 99, 235, 0.1));
  color: var(--primary-600);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.admin-user-select {
  background: linear-gradient(135deg, var(--warning-50), rgba(254, 243, 199, 0.5));
  border: 1.5px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--border-radius-sm);
  padding: 14px;
  margin-bottom: 20px;
  position: relative;
}

.admin-user-select::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--warning-500), var(--warning-600));
  border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

.admin-user-select .form-label {
  color: var(--warning-600);
  font-weight: 700;
}

.admin-user-select .form-label i {
  margin-right: 4px;
}

.target-user-label {
  font-size: 0.75rem;
  color: var(--warning-600);
  margin-top: 6px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.target-user-label:empty {
  display: none;
}

.user-badge-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--border-radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--primary-50);
  color: var(--primary-700);
  border: 1px solid var(--primary-100);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .navbar-toggle {
    display: flex;
  }

  .page-content {
    padding: 16px;
  }

  .summary-cards {
    grid-template-columns: 1fr;
  }

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

  .chart-container {
    height: 250px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .form-group {
    min-width: auto;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal {
    max-width: 100%;
    margin: 10px;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: auto;
    max-width: none;
  }

  .data-table {
    font-size: 0.75rem;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }

  .btn-group {
    width: 100%;
  }

  .btn-group .btn {
    flex: 1;
  }

  .tab-nav {
    gap: 0;
  }

  .tab-nav-item {
    padding: 8px 12px;
    font-size: 0.75rem;
  }

  .summary-card-value {
    font-size: 1.25rem;
  }

  .backup-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .navbar {
    padding: 0 12px;
  }

  .navbar-date {
    display: none;
  }

  .login-body {
    padding: 24px;
  }

  .login-header {
    padding: 24px;
  }
}

/* ---- Utility Classes ---- */
.text-success { color: var(--success-600); }
.text-danger { color: var(--danger-600); }
.text-primary { color: var(--primary-600); }
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none !important; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ---- Print Styles ---- */
@media print {
  .sidebar,
  .navbar,
  .filter-bar,
  .btn,
  .toast-container,
  .offline-banner {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .page-content {
    padding: 0 !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }
}
