/* ==========================================================================
   DESIGN SYSTEM & CONSTANTS (STYLES.CSS)
   ========================================================================== */

:root {
  --font-family: Arial, Helvetica, sans-serif;
  
  /* Color Palette */
  --bg-gradient: linear-gradient(135deg, #090a0f 0%, #121420 100%);
  --sidebar-bg: rgba(13, 15, 26, 0.9);
  --glass-bg: rgba(22, 26, 46, 0.6);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-hover: rgba(255, 255, 255, 0.1);
  --glass-active: rgba(255, 255, 255, 0.15);
  
  --primary-color: #10b981; /* Emerald Green */
  --primary-glow: rgba(16, 185, 129, 0.4);
  --accent-color: #84cc16; /* Lime Green */
  --accent-glow: rgba(132, 204, 22, 0.4);
  
  --income-color: #10b981; /* Emerald Green */
  --income-bg-alpha: rgba(16, 185, 129, 0.15);
  --income-border-alpha: rgba(16, 185, 129, 0.3);
  
  --expense-color: #f43f5e; /* Rose Red */
  --expense-bg-alpha: rgba(244, 63, 94, 0.15);
  --expense-border-alpha: rgba(244, 63, 94, 0.3);
  
  --advance-color: #f59e0b; /* Amber/Orange */
  --advance-bg-alpha: rgba(245, 158, 11, 0.15);
  --advance-border-alpha: rgba(245, 158, 11, 0.3);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & GLOBAL STYLES
   ========================================================================== */

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

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(10, 10, 15, 0.5);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Helper Utility Classes */
.hidden {
  display: none !important;
}

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

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */

.app-container {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: 280px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 24px;
  flex-shrink: 0;
  z-index: 10;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
  padding: 0 8px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.logo-text h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-text span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Navigation menu */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 14px 16px;
  border-radius: var(--border-radius-md);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-smooth);
}

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

.nav-item:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: var(--text-primary);
  box-shadow: 0 4px 15px var(--primary-glow);
}

/* Profile area in Sidebar */
.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
}

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

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--glass-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
}

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

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

/* Header Area */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--glass-border);
}

.main-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

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

/* Time Filter Group */
.filter-group {
  display: flex;
  align-items: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 4px;
  gap: 8px;
}

.filter-toggle {
  display: flex;
  background: rgba(10, 10, 15, 0.4);
  border-radius: 10px;
  padding: 2px;
}

.toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.toggle-btn.active {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.filter-inputs input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  outline: none;
  cursor: pointer;
}

.filter-inputs input::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

/* Button Component Styles */
.btn {
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: var(--text-primary);
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-accent {
  background: var(--accent-color);
  color: var(--text-primary);
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

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

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

.btn-full {
  width: 100%;
}

/* ==========================================================================
   TAB VIEWS CONTROLLERS & CARDS
   ========================================================================== */

.tab-views {
  flex-grow: 1;
}

.tab-view {
  display: none;
  animation: fadeIn 0.4s ease;
  flex-direction: column;
  gap: 25px;
}

.tab-view.active {
  display: flex;
}

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

/* 1. Dashboard Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.metric-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.metric-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.metric-card.fund::before { background: var(--primary-color); }
.metric-card.income::before { background: var(--income-color); }
.metric-card.expense::before { background: var(--expense-color); }
.metric-card.advance::before { background: var(--advance-color); }
.metric-card.remaining::before { background: var(--accent-color); }

.card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.metric-card.fund .card-icon { color: var(--primary-color); background: rgba(16, 185, 129, 0.15); }
.metric-card.income .card-icon { color: var(--income-color); background: var(--income-bg-alpha); }
.metric-card.expense .card-icon { color: var(--expense-color); background: var(--expense-bg-alpha); }
.metric-card.advance .card-icon { color: var(--advance-color); background: var(--advance-bg-alpha); }
.metric-card.remaining .card-icon { color: var(--accent-color); background: rgba(132, 204, 22, 0.15); }

.card-info {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.card-info span {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 2px;
}

.card-title-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.edit-fund-icon {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: var(--transition-smooth);
}

.edit-fund-icon:hover {
  color: var(--primary-color);
  transform: scale(1.15);
}

.card-info h3 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.card-sub {
  font-size: 11px !important;
  color: var(--text-muted) !important;
  margin-top: 4px;
}

/* ==========================================================================
   PANEL MODULES
   ========================================================================== */

.card-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  backdrop-filter: blur(10px);
}

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

.panel-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.panel-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-color);
  background: rgba(16, 185, 129, 0.15);
  padding: 4px 10px;
  border-radius: 8px;
  text-transform: uppercase;
}

/* Charts Layout Grid */
.dashboard-charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 25px;
}

@media (max-width: 1024px) {
  .dashboard-charts-grid {
    grid-template-columns: 1fr;
  }
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 280px;
}

.chart-wrapper.pie-chart {
  height: 180px;
  margin-top: 15px;
}

/* Coffee Summary KPIs */
.coffee-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.coffee-kpi-item {
  border-radius: var(--border-radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.coffee-kpi-item.buy {
  background: var(--expense-bg-alpha);
  border: 1px solid var(--expense-border-alpha);
}
.coffee-kpi-item.sell {
  background: var(--income-bg-alpha);
  border: 1px solid var(--income-border-alpha);
}

.kpi-icon {
  font-size: 20px;
}
.coffee-kpi-item.buy .kpi-icon { color: var(--expense-color); }
.coffee-kpi-item.sell .kpi-icon { color: var(--income-color); }

.kpi-details span {
  font-size: 11px;
  color: var(--text-secondary);
}
.kpi-details h4 {
  font-size: 16px;
  font-weight: 700;
}
.kpi-details p {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   BUDGETS MODULE
   ========================================================================== */

.budgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 15px;
}

.budget-item {
  background: rgba(10, 10, 15, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.budget-meta {
  display: flex;
  justify-content: space-between;
}

.budget-cat {
  font-weight: 600;
  font-size: 14px;
}

.budget-stats {
  font-size: 12px;
  color: var(--text-secondary);
}

.budget-progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.budget-progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--primary-color);
  width: 0%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.budget-progress-bar.success { background: var(--income-color); }
.budget-progress-bar.warning { background: var(--advance-color); }
.budget-progress-bar.danger { 
  background: var(--expense-color);
  animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
  0% { opacity: 0.8; }
  50% { opacity: 1; box-shadow: 0 0 10px rgba(244, 63, 94, 0.5); }
  100% { opacity: 0.8; }
}

.budget-percentage {
  font-weight: 700;
  font-size: 12px;
  align-self: flex-end;
}
.budget-percentage.danger { color: var(--expense-color); }
.budget-percentage.warning { color: var(--advance-color); }

/* ==========================================================================
   COFFEE SPECIAL TAB
   ========================================================================== */

.coffee-daily-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.summary-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  transition: var(--transition-smooth);
}

.summary-card:hover {
  transform: translateY(-2px);
}

.card-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
}

.summary-card h3 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* ==========================================================================
   DATA TABLES AND LISTS
   ========================================================================== */

.table-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.search-box {
  position: relative;
  min-width: 280px;
}

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

.search-box input {
  background: rgba(10, 10, 15, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 10px 15px 10px 42px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: var(--transition-smooth);
}

.search-box input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 10px var(--primary-glow);
}

.table-filter-selectors {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.table-filter-selectors select {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  padding: 10px 15px;
  outline: none;
  cursor: pointer;
}

/* Responsive Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--border-radius-md);
}

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

.data-table th, .data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table th {
  background: rgba(10, 10, 15, 0.6);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

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

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

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}

.badge.income { color: var(--income-color); background: var(--income-bg-alpha); }
.badge.expense { color: var(--expense-color); background: var(--expense-bg-alpha); }
.badge.advance { color: var(--advance-color); background: var(--advance-bg-alpha); }

.badge-round {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
}
.badge-round.income { color: var(--income-color); background: var(--income-bg-alpha); }
.badge-round.expense { color: var(--expense-color); background: var(--expense-bg-alpha); }
.badge-round.advance { color: var(--advance-color); background: var(--advance-bg-alpha); }

/* Table Action Buttons */
.action-btn {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.action-btn.edit:hover {
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary-color);
}

.action-btn.delete:hover {
  background: rgba(244, 63, 94, 0.15);
  color: var(--expense-color);
}

/* Empty State Styling */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 15px;
}

.empty-state i {
  font-size: 48px;
}

.empty-state p {
  font-size: 15px;
}

/* Sync Indicator */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.sync-indicator.active {
  color: var(--income-color);
}

/* ==========================================================================
   TÀI KHOẢN & QUỸ LAYOUT GRID
   ========================================================================== */

.accounts-grid-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 25px;
  align-items: start;
}

@media (max-width: 1024px) {
  .accounts-grid-layout {
    grid-template-columns: 1fr;
  }
}

.accounts-list-vertical {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 25px;
}

.account-item-card {
  background: rgba(10, 10, 15, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition-smooth);
}

.account-item-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(10, 10, 15, 0.6);
}

.account-meta-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--glass-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--primary-color);
}

.account-name-label {
  font-weight: 600;
  font-size: 15px;
}

.account-balance-label {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

/* Transfer form */
.account-actions-box {
  border-top: 1px solid var(--glass-border);
  padding-top: 25px;
}

.account-actions-box h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 15px;
}

.transfer-inline-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Form Styles */
.form-row {
  display: flex;
  gap: 15px;
}

.form-row > .form-group {
  flex: 1;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input, 
.form-group select, 
.form-group textarea {
  background: rgba(10, 10, 15, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
  width: 100%;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 10px var(--primary-glow);
}

.form-group textarea {
  resize: vertical;
}

.btn-align {
  display: flex;
  align-items: flex-end;
}

/* Budgets settings form */
.budgets-settings-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* ==========================================================================
   MODAL DIALOG DIALOG BACKDROP & GLASS CARD
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 4, 8, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-backdrop.active {
  display: flex;
  animation: fadeInModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: rgba(18, 22, 40, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 580px;
  padding: 30px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
  transition: var(--transition-smooth);
}

.modal-backdrop.active .modal-content {
  transform: scale(1);
}

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

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
  line-height: 1;
}

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 25px;
}

/* Static input for preview */
.form-control-static {
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--income-color) !important;
  font-weight: 700;
  font-size: 16px !important;
  border-color: rgba(255, 255, 255, 0.03) !important;
}

/* Checkbox Style */
.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  cursor: pointer;
}

.checkbox-group input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

.checkbox-group label {
  cursor: pointer;
  user-select: none;
}

/* ==========================================================================
   RESPONSIVE LAYOUT FOR MOBILE SCREENS (Merged with final PWA Mobile CSS)
   ========================================================================== */

/* ==========================================================================
   BẢNG LƯỚI EXCEL CHẤM CÔNG (EXCEL TIMESHEET GRID)
   ========================================================================== */

.timesheet-grid-wrapper {
  overflow-x: auto !important;
  max-width: 100%;
  margin-top: 15px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--glass-border);
}

.timesheet-grid-table {
  border-collapse: separate !important;
  border-spacing: 0;
  font-size: 13px !important;
  min-width: 1300px; /* Đảm bảo đủ rộng để cuộn ngang mượt mà */
}

.timesheet-grid-table th, 
.timesheet-grid-table td {
  padding: 8px 6px !important;
  text-align: center;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  min-width: 44px;
}

/* Ghim cột Tên nhân viên ở bên trái (Sticky Column) */
.timesheet-grid-table th:first-child, 
.timesheet-grid-table td:first-child {
  position: sticky;
  left: 0;
  background: #111422 !important;
  z-index: 10;
  min-width: 145px;
  max-width: 145px;
  width: 145px;
  text-align: left;
  font-weight: 600;
  border-right: 2px solid rgba(255, 255, 255, 0.18) !important;
  box-shadow: 6px 0 16px rgba(0, 0, 0, 0.55);
}

/* Nội dung bên trong cột sticky: icon + tên */
.timesheet-grid-table td:first-child {
  display: table-cell; /* giữ là table-cell, không dùng flex */
}

/* flex layout được ần vào inner div */
.ts-name-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timesheet-grid-table th:first-child {
  z-index: 11;
  background: #090a12 !important;
  padding-left: 10px !important;
}

/* Định vị ghim các cột tổng hợp ở bên phải nếu cần thiết, hoặc cứ để tự nhiên */
.timesheet-grid-table th.sticky-summary,
.timesheet-grid-table td.sticky-summary {
  font-weight: 700;
  background: rgba(22, 26, 46, 0.95);
  min-width: 85px;
}

.timesheet-grid-table td.sticky-summary {
  color: var(--text-primary);
}

.timesheet-grid-table td.payroll-actions {
  min-width: 230px;
  text-align: left;
}

/* Ô lựa chọn Chấm công custom siêu nhỏ gọn */
.timesheet-cell-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-align-last: center;
  width: 100%;
  height: 28px;
  padding: 2px 0;
  outline: none;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition-smooth);
}

.timesheet-cell-select option {
  background: #121420;
  color: var(--text-primary);
}

/* Định dạng màu sắc trực quan dựa trên trạng thái công */
.timesheet-cell-select[data-val="-"] { 
  color: var(--text-muted); 
  opacity: 0.4; 
}
.timesheet-cell-select[data-val="1"] { 
  color: var(--income-color); 
  background: rgba(16, 185, 129, 0.15); 
}
.timesheet-cell-select[data-val="1+"] { 
  color: #60a5fa; /* Blue */
  background: rgba(59, 130, 246, 0.2); 
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.timesheet-cell-select[data-val="0.5"] { 
  color: var(--advance-color); 
  background: rgba(245, 158, 11, 0.15); 
}
.timesheet-cell-select[data-val="0.5+"] { 
  color: #fb923c; /* Orange */
  background: rgba(249, 115, 22, 0.2); 
}

/* Nút xóa nhân viên nhanh */
.emp-delete-btn {
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 4px;
  transition: var(--transition-smooth);
}

.emp-delete-btn:hover {
  color: var(--expense-color);
  transform: scale(1.2);
}

/* ============================================================
   TIMESHEET SAVE BAR - Floating bar khi có thay đổi chưa lưu
   ============================================================ */
.timesheet-save-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  margin-top: 8px;
  pointer-events: none;
}

.timesheet-save-bar.hidden {
  display: none;
}

.save-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(59, 130, 246, 0.12));
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 14px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  pointer-events: all;
  animation: slideUpBar 0.25s ease;
}

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

#timesheet-pending-count {
  color: #10b981;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.save-bar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Khi có pending thay đổi, highlight select đó */
.timesheet-cell-select.pending-change {
  outline: 2px solid rgba(16, 185, 129, 0.6);
  outline-offset: 1px;
}

@media (max-width: 768px) {
  .save-bar-inner {
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }

  .save-bar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .save-bar-actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* Đảm bảo cột tên không quá rộng trên mobile */
  .timesheet-grid-table th:first-child,
  .timesheet-grid-table td:first-child {
    min-width: 110px;
    max-width: 110px;
    width: 110px;
  }
}

/* ==========================================================================
   MÀN HÌNH ĐĂNG NHẬP & PHÂN QUYỀN (LOGIN & AUTH STYLES)
   ========================================================================== */

.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 10, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 30px;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  background: linear-gradient(135deg, rgba(22, 26, 46, 0.4) 0%, rgba(10, 12, 22, 0.6) 100%);
  animation: fadeIn 0.4s ease-out;
}

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

.login-logo {
  animation: float 3s ease-in-out infinite;
}

.login-error-msg {
  background: rgba(239, 68, 68, 0.1) !important;
  border: 1px solid rgba(239, 68, 68, 0.25) !important;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 10px;
}

/* Nút đăng xuất */
#btn-logout:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  color: var(--expense-color) !important;
}

/* Ẩn theo vai trò */
.hidden-by-role {
  display: none !important;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0px); }
}

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


/* ==========================================================================
   MOBILE RESPONSIVE — iOS & ANDROID NATIVE FEEL
   ========================================================================== */

/* ---- Mobile Top Header Bar ---- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: rgba(10, 12, 22, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 200;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
}
.mobile-menu-btn, .mobile-profile-btn {
  background: none; border: none;
  color: var(--text-primary);
  font-size: 20px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}
.mobile-menu-btn:active, .mobile-profile-btn:active {
  background: var(--glass-hover);
}
.mobile-header-title { display: flex; flex-direction: column; align-items: center; }
.mobile-app-name { font-size: 17px; font-weight: 700; color: var(--text-primary); }

/* ---- Sidebar Overlay ---- */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ---- Bottom Navigation Bar ---- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(60px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(10, 12, 22, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  z-index: 200;
  flex-direction: row;
  align-items: stretch;
}
.bottom-nav-item {
  flex: 1; background: none; border: none;
  color: var(--text-muted);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; padding: 6px 2px;
  cursor: pointer; font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}
.bottom-nav-item i { font-size: 20px; transition: transform 0.2s; }
.bottom-nav-item span { font-size: 10px; font-weight: 500; }
.bottom-nav-item.active { color: var(--primary-color); }
.bottom-nav-item.active i { transform: translateY(-2px); }
.bottom-nav-item:active i { transform: scale(0.88); }

/* ---- Mobile Layout (max 768px) ---- */
@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .bottom-nav { display: flex; }

  body {
    padding-top: calc(56px + env(safe-area-inset-top));
  }

  .app-container { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 85vw;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    padding-top: calc(24px + env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overflow-x: hidden;
  }
  .sidebar.open { transform: translateX(0); }

  .nav-menu {
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .nav-item {
    flex-direction: row !important;
    padding: 14px 16px !important;
    font-size: 15px !important;
    width: 100% !important;
    height: auto !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
  }
  .nav-item span {
    display: inline-block !important;
  }

  /* Tài khoản & Quỹ tab layout sang 1 cột dọc */
  .accounts-grid-layout {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .accounts-grid-layout > .card-panel {
    grid-column: span 1 !important;
  }

  /* Sửa tiêu đề bị xuống dòng nhiều trên mobile */
  .panel-header h3 {
    font-size: 16px !important;
    line-height: 1.3 !important;
    white-space: normal !important;
  }
  .panel-header {
    gap: 8px !important;
    align-items: flex-start !important;
  }

  .main-content {
    width: 100%; height: auto;
    padding: 16px 14px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
    gap: 16px;
  }
  .main-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .main-header h1 { font-size: 20px; }
  .header-controls { width: 100%; }

  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .stat-card { padding: 14px !important; }
  .stat-number { font-size: 18px !important; }

  /* Bảng thành thẻ trên mobile */
  .table-responsive:not(.timesheet-grid-wrapper) {
    border: none;
    overflow-x: visible;
  }
  .data-table:not(.timesheet-grid-table), 
  .data-table:not(.timesheet-grid-table) thead, 
  .data-table:not(.timesheet-grid-table) tbody, 
  .data-table:not(.timesheet-grid-table) th, 
  .data-table:not(.timesheet-grid-table) td, 
  .data-table:not(.timesheet-grid-table) tr {
    display: block;
  }
  .data-table:not(.timesheet-grid-table) thead {
    display: none;
  }
  .data-table:not(.timesheet-grid-table) tbody tr {
    margin-bottom: 16px;
    background: rgba(22, 26, 46, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    padding: 12px 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  }
  .data-table:not(.timesheet-grid-table) td {
    border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
    padding: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
  }
  .data-table:not(.timesheet-grid-table) td:last-child {
    border-bottom: none;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 12px;
  }
  .data-table:not(.timesheet-grid-table) td::before {
    content: attr(data-label);
    float: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: left;
  }

  .form-grid { grid-template-columns: 1fr !important; }
  input, select, textarea { font-size: 16px !important; min-height: 44px; }
  button { min-height: 40px; }

  .charts-grid { grid-template-columns: 1fr !important; }
  .panel-grid, .two-col-grid { grid-template-columns: 1fr !important; }

  .login-card { padding: 28px 18px; }
  
  /* Lưới chỉ số và modal */
  .metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
  }
  .metric-card {
    padding: 16px;
    gap: 12px;
  }
  .card-icon {
    width: 44px;
    height: 44px;
    font-size: 16px;
    border-radius: 10px;
  }
  .card-info h3 {
    font-size: 18px;
  }
  .coffee-kpis {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .modal-content {
    padding: 20px;
    max-width: 92%;
  }

  ::-webkit-scrollbar { width: 2px; height: 2px; }
}

/* ---- Tablet (769px - 1024px) ---- */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { width: 220px; padding: 16px; }
  .logo-text h2 { font-size: 15px; }
  .main-content { padding: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ==========================================================================
   USERS TAB — Card Layout
   ========================================================================== */

.users-tab-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 20px;
}

.users-form-card,
.users-list-card {
  padding: 20px;
  border-radius: var(--border-radius-md);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--glass-border);
}

.users-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.users-list-card .users-section-title {
  color: var(--text-primary);
}

.users-form-card .form-group {
  margin-bottom: 12px;
}

.users-form-card input,
.users-form-card select {
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  margin-top: 4px;
  font-family: var(--font-family);
  font-size: 14px;
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 12px;
  margin-top: 4px;
}

/* User Cards */
.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  margin-bottom: 10px;
  transition: background 0.2s;
}
.user-card:last-child { margin-bottom: 0; }
.user-card:hover { background: rgba(255,255,255,0.06); }

.user-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

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

.user-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-role-badge {
  font-size: 12px;
  font-weight: 500;
  margin-top: 2px;
}

.user-card-role-select {
  margin-top: 6px;
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  padding: 5px 8px;
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 12px;
}

.user-card-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.user-card-delete-btn {
  background: rgba(244,63,94,0.1);
  border: 1px solid rgba(244,63,94,0.2);
  color: var(--expense-color);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.user-card-delete-btn:hover,
.user-card-delete-btn:active {
  background: rgba(244,63,94,0.25);
  transform: scale(1.05);
}

.user-card-self-tag {
  font-size: 11px;
  color: var(--primary-color);
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.2);
  padding: 3px 8px;
  border-radius: 20px;
}
