:root,
[data-bs-theme="light"] {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #1e293b;
  --topbar-bg: #ffffff;
}

[data-bs-theme="dark"] {
  --bg-main: #0b0f19;
  --bg-surface: #151c2c;
  --bg-surface-hover: #1e293b;
  --border-color: #27354a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --sidebar-bg: #0b0f19;
  --sidebar-text: #64748b;
  --sidebar-active: #f8fafc;
  --sidebar-active-bg: #151c2c;
  --topbar-bg: #151c2c;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.nav-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  padding: 0.75rem 0.75rem 0.25rem;
}

.sidebar-nav .nav-link {
  color: var(--sidebar-text);
  padding: 0.65rem 0.75rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  transition: all 0.15s ease;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  color: var(--sidebar-active);
  background-color: var(--sidebar-active-bg);
}

.sidebar-nav .nav-link i {
  font-size: 1.1rem;
}

/* Main Content Area */
.app-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.app-topbar {
  height: 64px;
  background-color: var(--topbar-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.page-content {
  padding: 1.75rem;
  flex-grow: 1;
}

/* Card Styling */
.card-custom {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  margin-bottom: 1.5rem;
}

.card-custom .card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  font-weight: 600;
}

.card-custom .card-body {
  padding: 1.5rem;
}

/* Stats Widget Card */
.stat-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: transform 0.15s ease;
}

.stat-widget:hover {
  transform: translateY(-2px);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.blue { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
.stat-icon.green { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.stat-icon.amber { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.stat-icon.purple { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }

/* Custom Tables */
.table-custom {
  color: var(--text-main);
  margin-bottom: 0;
}

.table-custom th {
  background-color: var(--bg-surface-hover);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.table-custom td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table-custom tbody tr:hover {
  background-color: var(--bg-surface-hover);
}

/* Status Badges */
.badge-status {
  padding: 0.35em 0.75em;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: capitalize;
}

.badge-draft { background: #e2e8f0; color: #475569; }
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-viewed { background: #e0e7ff; color: #4338ca; }
.badge-paid { background: #d1fae5; color: #047857; }
.badge-partial { background: #fef3c7; color: #b45309; }
.badge-overdue { background: #fee2e2; color: #b91c1c; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }
