/* ==========================================
   MSN Energy Demo - Cueprise Design System
   ========================================== */

/* CSS Variables (from MOCKS analysis) */
:root {
  /* Primary Colors */
  --sidebar-bg: #1a1035;
  --sidebar-hover: #2d1b69;
  --sidebar-active: #6366f1;

  /* Accent Colors */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --teal: #14b8a6;
  --teal-light: #2dd4bf;

  /* Status Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* Neutrals */
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Sizing */
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

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

html {
  font-size: 14px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--gray-100);
  color: var(--gray-800);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================
   Sidebar Styles
   ========================================== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #0f0720 100%);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.logo i {
  font-size: 1.75rem;
  color: var(--primary-light);
}

.client-badge {
  margin-top: 0.75rem;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid var(--primary);
  color: var(--primary-light);
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.nav-section {
  margin-bottom: 1.5rem;
}

.nav-label {
  display: block;
  padding: 0.5rem 1.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-400);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1.5rem;
  border: none;
  background: transparent;
  color: var(--gray-300);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

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

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--white);
}

.nav-item i {
  font-size: 1.25rem;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.back-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--white);
}

/* ==========================================
   Main Content Area
   ========================================== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

/* Top Bar */
.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  min-width: 300px;
}

.search-box i {
  color: var(--gray-400);
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.875rem;
  color: var(--gray-700);
  width: 100%;
}

.search-box input::placeholder {
  color: var(--gray-400);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.icon-btn {
  position: relative;
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 1.25rem;
  border-radius: 8px;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.icon-btn .badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--danger);
  color: white;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 99px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.user-profile:hover {
  background: var(--gray-100);
}

.user-profile img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.user-profile span {
  font-weight: 500;
  color: var(--gray-700);
}

.user-profile i {
  color: var(--gray-400);
}

/* Content Area */
.content-area {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

/* ==========================================
   Module Styles
   ========================================== */
.module {
  display: none;
  animation: fadeIn 0.3s ease;
}

.module.active {
  display: block;
}

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

.module-header {
  margin-bottom: 1.5rem;
}

.module-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
}

.module-header .subtitle {
  color: var(--gray-500);
  font-size: 0.875rem;
}

/* ==========================================
   KPI Cards
   ========================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-grid.four-col {
  grid-template-columns: repeat(4, 1fr);
}

.kpi-card {
  background: var(--white);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
}

.kpi-card.compact {
  padding: 1rem;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.kpi-icon.blue {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}

.kpi-icon.green {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

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

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

.kpi-icon.purple {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}

.kpi-content {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.kpi-card.compact .kpi-value {
  font-size: 1.5rem;
}

.kpi-change {
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.25rem;
}

.kpi-change.positive {
  color: var(--success);
}
.kpi-change.negative {
  color: var(--danger);
}
.kpi-change.neutral {
  color: var(--gray-500);
}

/* ==========================================
   Charts
   ========================================== */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--white);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
}

.chart-card.wide {
  grid-column: span 1;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.chart-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.chart-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--gray-100);
  padding: 0.25rem;
  border-radius: 6px;
}

.chart-tabs button {
  padding: 0.375rem 0.75rem;
  border: none;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.chart-tabs button.active {
  background: var(--white);
  color: var(--gray-800);
  box-shadow: var(--shadow-sm);
}

.chart-container {
  height: 200px;
}

/* ==========================================
   Tables
   ========================================== */
.table-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
}

.table-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.search-inline i {
  color: var(--gray-400);
  font-size: 0.875rem;
}

.search-inline input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.8125rem;
  width: 160px;
}

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

.data-table th,
.data-table td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
}

.data-table th {
  background: var(--gray-50);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  font-size: 0.875rem;
  color: var(--gray-700);
}

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

.data-table tbody tr.variance-row {
  background: rgba(239, 68, 68, 0.05);
}

.data-table tbody tr.critical-row {
  background: rgba(239, 68, 68, 0.05);
}

.data-table td.positive {
  color: var(--success);
  font-weight: 600;
}
.data-table td.negative {
  color: var(--danger);
  font-weight: 600;
}
.data-table td.warning {
  color: var(--warning);
  font-weight: 600;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--gray-100);
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.page-btn {
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--gray-200);
  background: var(--white);
  border-radius: 4px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* ==========================================
   Status Badges
   ========================================== */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border-radius: 99px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.status-badge.reconciled {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.status-badge.alert {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* ==========================================
   Buttons
   ========================================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-light);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-secondary.small {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-icon {
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--gray-400);
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

/* ==========================================
   Alert Cards (GRC Module)
   ========================================== */
.alert-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.alert-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.alert-card.critical {
  border-left: 4px solid var(--danger);
}

.alert-card.warning {
  border-left: 4px solid var(--warning);
}

.alert-card.info {
  border-left: 4px solid var(--info);
}

.alert-icon {
  font-size: 1.75rem;
}

.alert-card.critical .alert-icon {
  color: var(--danger);
}
.alert-card.warning .alert-icon {
  color: var(--warning);
}
.alert-card.info .alert-icon {
  color: var(--info);
}

.alert-content {
  flex: 1;
}

.alert-label {
  display: block;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.alert-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
}

.alert-action {
  padding: 0.375rem 0.75rem;
  background: var(--gray-100);
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.alert-action:hover {
  background: var(--gray-200);
}

/* ==========================================
   Contract Types
   ========================================== */
.contract-type {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
}

.contract-type.gpa {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}

.contract-type.gsa {
  background: rgba(20, 184, 166, 0.1);
  color: var(--teal);
}

/* ==========================================
   Project Cards
   ========================================== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.project-card {
  background: var(--white);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
}

.project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.project-type {
  padding: 0.25rem 0.625rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
}

.project-type.pipeline {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}

.project-type.fgc {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.project-progress {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--gray-700);
}

.project-card h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 0.375rem;
}

.project-desc {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
}

.project-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--teal) 100%);
  border-radius: 3px;
}

.project-team {
  display: flex;
  align-items: center;
}

.project-team img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--white);
  margin-left: -8px;
}

.project-team img:first-child {
  margin-left: 0;
}

.more-team {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-left: -8px;
}

/* ==========================================
   Placeholder Content
   ========================================== */
.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: center;
}

.placeholder-content i {
  font-size: 4rem;
  color: var(--gray-300);
  margin-bottom: 1rem;
}

.placeholder-content h3 {
  font-size: 1.25rem;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.placeholder-content p {
  color: var(--gray-500);
  max-width: 400px;
}

/* ==========================================
   Responsive
   ========================================== */

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-700);
  cursor: pointer;
  padding: 0.5rem;
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

/* Tablet Styles (1024px) */
@media (max-width: 1024px) {
  .kpi-grid.four-col {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

  .project-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile Styles (768px) */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
  }

  /* Mobile Menu Toggle */
  .mobile-menu-toggle {
    display: block;
  }

  /* Sidebar - Off-canvas */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
  }

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

  /* Main Content - Full width */
  .main-content {
    margin-left: 0;
    width: 100%;
  }

  /* Topbar adjustments */
  .topbar {
    padding: 0 1rem;
  }

  .topbar-left {
    flex: 1;
  }

  .search-box {
    min-width: auto;
    flex: 1;
    max-width: none;
  }

  .topbar-right {
    gap: 0.5rem;
  }

  .user-profile span {
    display: none;
  }

  .user-profile {
    padding: 0.5rem;
  }

  /* Content Area */
  .content-area {
    padding: 1rem;
  }

  /* KPI Grid */
  .kpi-grid,
  .kpi-grid.four-col {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    padding: 1rem;
  }

  .kpi-value {
    font-size: 1.5rem;
  }

  /* Tables - Horizontal Scroll */
  .table-card {
    overflow: visible;
  }

  .table-card .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  .table-header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .table-header h3 {
    width: 100%;
  }

  .table-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-inline {
    flex: 1;
    min-width: 150px;
  }

  .search-inline input {
    width: 100%;
  }

  .table-footer {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }

  /* Project Grid */
  .project-grid {
    grid-template-columns: 1fr;
  }

  /* Alert Grid */
  .alert-grid {
    grid-template-columns: 1fr;
  }

  .alert-card {
    padding: 1rem;
  }

  /* Chart containers */
  .chart-container {
    height: 180px;
  }

  /* Module Header */
  .module-header h1 {
    font-size: 1.5rem;
  }

  /* Contract type badges */
  .contract-type {
    font-size: 0.625rem;
    padding: 0.2rem 0.4rem;
  }

  /* Document grid */
  .doc-grid {
    grid-template-columns: 1fr;
  }

  /* HR table fixes */
  .hr-table-wrapper {
    overflow-x: auto;
  }

  /* Analytics grid */
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

/* Small Mobile (480px) */
@media (max-width: 480px) {
  .content-area {
    padding: 0.75rem;
  }

  .kpi-card {
    flex-direction: column;
    text-align: center;
  }

  .kpi-icon {
    margin: 0 auto;
  }

  .project-card {
    padding: 1rem;
  }

  .table-card {
    border-radius: 8px;
  }

  .data-table th,
  .data-table td {
    padding: 0.625rem 0.75rem;
    font-size: 0.75rem;
  }

  .btn-primary,
  .btn-secondary {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .chart-tabs {
    width: 100%;
    justify-content: center;
  }

  /* Sidebar footer */
  .sidebar-footer {
    padding: 1rem;
  }
}

/* Prevent horizontal overflow globally */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

.content-area {
  max-width: 100%;
  overflow-x: hidden;
}

/* Ensure tables don't cause overflow */
.data-table {
  min-width: 600px;
}

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

/* ==========================================
   Modal System
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

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

.modal {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
}

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

.modal.large {
  max-width: 800px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-900);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  transition: all 0.2s;
}

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

.modal-body {
  padding: 1.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* ==========================================
   Form Styles
   ========================================== */
.form-group {
  margin-bottom: 1.25rem;
}

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

.form-label.required::after {
  content: " *";
  color: var(--danger);
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--gray-800);
  background: var(--white);
  transition: all 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.form-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--gray-800);
  background: var(--white);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
  padding-right: 2.5rem;
}

.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--gray-800);
  background: var(--white);
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 0.375rem;
}

/* ==========================================
   Toast Notifications
   ========================================== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  min-width: 320px;
  max-width: 420px;
  transform: translateX(120%);
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(0);
}

.toast-icon {
  font-size: 1.25rem;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-900);
}

.toast-message {
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0.25rem;
}

/* ==========================================
   Sub-Navigation Tabs
   ========================================== */
.module-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--gray-100);
  padding: 0.25rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
}

.module-tab {
  padding: 0.625rem 1.25rem;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.module-tab:hover {
  color: var(--gray-800);
}

.module-tab.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

/* ==========================================
   Detail Cards
   ========================================== */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray-800);
}

.detail-value.large {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ==========================================
   Action Dropdown
   ========================================== */
.action-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  padding: 0.5rem 0;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
}

.action-dropdown:hover .dropdown-menu,
.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  color: var(--gray-700);
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
}

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

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--gray-100);
  margin: 0.5rem 0;
}

/* ==========================================
   Empty State
   ========================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
}

.empty-state i {
  font-size: 3rem;
  color: var(--gray-300);
  margin-bottom: 1rem;
}

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

.empty-state p {
  font-size: 0.875rem;
  color: var(--gray-500);
  max-width: 300px;
}

/* ==========================================
   Timeline / Workflow
   ========================================== */
.workflow-timeline {
  display: flex;
  justify-content: space-between;
  position: relative;
  padding: 0 1rem;
  margin: 1.5rem 0;
}

.workflow-timeline::before {
  content: "";
  position: absolute;
  top: 20px;
  left: 40px;
  right: 40px;
  height: 2px;
  background: var(--gray-200);
}

.workflow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.step-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  background: var(--gray-200);
  color: var(--gray-500);
}

.workflow-step.completed .step-circle {
  background: var(--success);
  color: var(--white);
}

.workflow-step.current .step-circle {
  background: var(--primary);
  color: var(--white);
}

.step-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-600);
}

/* ==========================================
   Badge Variants
   ========================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 99px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.badge-primary {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

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

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

.badge-info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}

/* File Upload */
.file-upload {
  border: 2px dashed var(--gray-300);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.file-upload:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.02);
}

.file-upload i {
  font-size: 2.5rem;
  color: var(--gray-400);
  margin-bottom: 0.75rem;
}

.file-upload p {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.file-upload span {
  color: var(--primary);
  font-weight: 500;
}

/* Loading State */
.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--white);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

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

/* Financial Module Specific */
.financial-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.journal-entry {
  background: var(--white);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--primary);
  margin-bottom: 0.75rem;
}

.journal-entry.debit {
  border-left-color: var(--danger);
}

.journal-entry.credit {
  border-left-color: var(--success);
}

.entry-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.entry-account {
  font-weight: 600;
  color: var(--gray-800);
}

.entry-amount {
  font-weight: 700;
  font-size: 1.125rem;
}

.entry-amount.debit { color: var(--danger); }
.entry-amount.credit { color: var(--success); }

.entry-meta {
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* Mobile adjustments for modals */
@media (max-width: 768px) {
  .modal {
    width: 95%;
    max-height: 90vh;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .detail-grid {
    grid-template-columns: 1fr;
  }
  
  .financial-summary {
    grid-template-columns: 1fr;
  }
  
  .toast {
    min-width: auto;
    max-width: calc(100vw - 2rem);
  }
}

/* ===========================================
   Table Footer & Pagination
   =========================================== */
.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.pagination {
  display: flex;
  gap: 0.25rem;
}

.page-btn {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.page-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Detail Grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-weight: 500;
  color: var(--text-primary);
}

/* View More Link */
.view-more {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: gap 0.2s ease;
}

.view-more:hover {
  gap: 0.5rem;
}

/* Positive/Negative Colors in Tables */
td.positive {
  color: var(--success);
  font-weight: 600;
}

td.negative {
  color: var(--danger);
  font-weight: 600;
}

td.neutral {
  color: var(--text-secondary);
}

/* ===========================================
   Invoice Items Section
   =========================================== */
.modal-wide {
  max-width: 700px;
}

.invoice-items-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
}

.invoice-items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.invoice-items-header h4 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.invoice-item {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border);
}

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

.invoice-item .form-group {
  margin-bottom: 0;
  flex: 1;
}

.invoice-item .item-subtotal {
  flex: 0 0 100px;
  text-align: right;
}

.invoice-item .subtotal-label {
  font-weight: 600;
  color: var(--primary);
}

.invoice-item .remove-item {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.25rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.invoice-item .remove-item:hover {
  opacity: 1;
}

.invoice-total {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  padding-top: 1rem;
  margin-top: 0.5rem;
  border-top: 2px solid var(--border);
}

.invoice-total .total-label {
  font-weight: 500;
  color: var(--text-secondary);
}

.invoice-total .total-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* ===========================================
   Dropdown Panels (Notifications & User Menu)
   =========================================== */
.notification-wrapper,
.user-wrapper {
  position: relative;
}

.dropdown-panel {
  position: absolute;
  top: 100%;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 320px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000;
  margin-top: 0.5rem;
}

.dropdown-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-panel.user-menu {
  min-width: 200px;
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.dropdown-header h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.dropdown-content {
  max-height: 350px;
  overflow-y: auto;
}

.dropdown-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Notification Items */
.notification-item {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

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

.notification-item:hover {
  background: var(--surface);
}

.notification-item.urgent {
  background: rgba(239, 68, 68, 0.05);
}

.notification-item.urgent i {
  color: var(--danger);
}

.notification-item i {
  font-size: 1.5rem;
  color: var(--primary);
  flex-shrink: 0;
}

.notification-text {
  flex: 1;
}

.notification-text strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.notification-text p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 0.25rem 0;
}

.notification-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* User Menu Items */
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background: var(--surface);
}

.dropdown-item i {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger i {
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}
