:root {
  /* Color Palette - Tzu Chi One ERP Dark Theme */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: rgba(17, 24, 39, 0.65);
  
  /* Accents */
  --accent-primary: #6366f1; /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-primary-glow: rgba(99, 102, 241, 0.35);
  
  --accent-secondary: #06b6d4; /* Cyan */
  --accent-secondary-hover: #0891b2;
  
  --accent-tertiary: #a855f7; /* Violet */
  
  /* Text */
  --text-main: #f3f4f6;
  --text-secondary: #cbd5e1;
  --text-muted: #6b7280;
  
  /* Borders */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  /* Status Colors */
  --status-success-bg: rgba(16, 185, 129, 0.12);
  --status-success-text: #34d399;
  
  --status-warning-bg: rgba(245, 158, 11, 0.12);
  --status-warning-text: #fbbf24;
  
  --status-danger-bg: rgba(239, 68, 68, 0.12);
  --status-danger-text: #f87171;
  
  --status-info-bg: rgba(59, 130, 246, 0.12);
  --status-info-text: #60a5fa;

  /* Typography */
  --font-heading: 'Outfit', 'Anuphan', sans-serif;
  --font-body: 'Outfit', 'Anuphan', sans-serif;
  
  /* Radii & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  
  --transition-speed: 0.25s;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-body);
  height: 100vh;
  overflow: hidden;
  letter-spacing: 0.15px;
  line-height: 1.6;
}

/* Main Layout Wrapper */
.app-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  width: 100vw;
}

/* Sidebar Styling (Matching Tzu Chi One ERP) */
.sidebar {
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(to right, #ffffff, var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-secondary);
}

.sidebar-menu {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  border-left: 3px solid transparent;
}

.menu-item i {
  font-size: 18px;
  width: 24px;
  text-align: center;
  color: var(--text-muted);
  transition: color var(--transition-speed) ease;
}

.menu-item:hover i {
  color: var(--accent-secondary);
}

.menu-item.active i {
  color: var(--accent-primary);
}

.menu-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: white;
}

.menu-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.12) 0%, rgba(6, 182, 212, 0.04) 100%);
  border-left-color: var(--accent-primary);
  color: white;
  padding-left: 13px; /* Offset border width */
}

/* Main Content Area */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
}

.header {
  height: 80px;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  flex-shrink: 0;
}

#view-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 50px;
  height: 36px;
}

.user-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.content-body {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
}

.view-section {
  display: none;
  animation: fadeIn var(--transition-speed) ease-in-out;
}

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

/* Stats Metrics Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.2);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 12px rgba(99, 102, 241, 0.08);
}

.stat-label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.stat-val {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 800;
  color: white;
}

/* Content Container Card */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 30px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  margin-bottom: 30px;
  transition: all var(--transition-speed) ease;
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.15);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 24px;
  color: white;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: rgba(255, 255, 255, 0.01);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  color: var(--text-secondary);
  font-size: 13.5px;
}

tr:hover td {
  background-color: rgba(255, 255, 255, 0.01);
  color: white;
}

/* Forms layout */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

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

label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-secondary);
}

input, select, textarea {
  padding: 12px 14px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 13.5px;
  color: var(--text-main);
  transition: all var(--transition-speed) ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

option {
  background-color: var(--bg-secondary);
  color: white;
}

/* Buttons */
button {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-primary-hover) 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px var(--accent-primary-glow);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
  filter: brightness(1.05);
}

button:active {
  transform: translateY(0);
}

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

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

/* Badges */
.badge {
  background-color: var(--status-success-bg) !important;
  color: var(--status-success-text) !important;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  padding: 3px 8px;
}

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

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Responsive adjustment */
@media(max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
  }
  .sidebar {
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .sidebar-menu {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    padding: 16px;
  }
  .menu-item {
    padding: 8px 14px;
    border-left: none;
  }
  .menu-item.active {
    background: rgba(99, 102, 241, 0.15);
    border-bottom: 2px solid var(--accent-primary);
    border-radius: var(--radius-sm);
  }
  .content-body {
    padding: 20px;
  }
}
