/* ============================================================
   BS-FINANCE DESIGN SYSTEM
   A modern, premium, minimalistic dashboard design
   Inspired by Stripe, Notion, Linear, Vercel
   ============================================================ */

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

/* ============================================================
   1. DESIGN TOKENS (CSS Custom Properties)
   ============================================================ */
:root {
  /* Brand Colors */
  --primary-dark: #2A1A14;
  --primary-brown: #3B241C;
  --primary-gold: #B8893B;
  --gold-hover: #A07832;
  --soft-gold: #F6EFE3;
  --background: #FAFAF8;
  --card: #FFFFFF;
  --border: #E7DED1;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --success: #22C55E;
  --success-soft: #F0FDF4;
  --danger: #EF4444;
  --danger-soft: #FEF2F2;
  --warning: #F59E0B;
  --warning-soft: #FFFBEB;
  --info: #B8893B;
  --info-soft: #F6EFE3;

  /* Typography */
  --font-inter: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(42, 26, 20, 0.04);
  --shadow-sm: 0 1px 3px rgba(42, 26, 20, 0.06);
  --shadow-md: 0 4px 12px rgba(42, 26, 20, 0.06);
  --shadow-lg: 0 8px 24px rgba(42, 26, 20, 0.08);
  --shadow-xl: 0 16px 40px rgba(42, 26, 20, 0.10);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* ============================================================
   2. GLOBAL STYLES
   ============================================================ */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-inter);
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

a {
  color: var(--primary-gold);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--gold-hover);
}

small, .small {
  font-size: 0.8125rem;
  line-height: 1.5;
}

img {
  max-width: 100%;
  height: auto;
}

/* ============================================================
   3. LAYOUT
   ============================================================ */

/* -- App Wrapper -- */
.app-wrapper {
  min-height: 100vh;
  display: flex;
}

/* -- Sidebar -- */
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--border);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow);
}

/* Sidebar Brand / Logo */
.sidebar-brand {
  flex-shrink: 0;
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  align-items: center;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--primary-dark);
}

.brand-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--primary-dark);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.5px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-copy span {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.3px;
}

.brand-copy small {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Sidebar Navigation */
.sidebar-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(107, 114, 128, 0.25) transparent;
}

.sidebar-wrapper::-webkit-scrollbar {
  width: 4px;
}

.sidebar-wrapper::-webkit-scrollbar-thumb {
  background: rgba(107, 114, 128, 0.25);
  border-radius: var(--radius-full);
}

/* Section Headers */
.nav-header {
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-secondary) !important;
  padding: 0.75rem 0.75rem 0.35rem;
  margin-top: 0.25rem;
}

/* Menu Items */
.sidebar-menu {
  padding: 0;
  margin: 0;
  list-style: none;
}

.sidebar-menu .nav-item {
  margin: 1px 0;
}

.sidebar-menu .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
  min-height: 40px;
  transition: all var(--transition-fast);
  text-decoration: none;
  position: relative;
  font-size: 0.85rem;
  font-weight: 500;
}

.sidebar-menu .nav-link:hover {
  background: var(--soft-gold);
  color: var(--primary-dark);
}

.sidebar-menu .nav-link.active {
  background: var(--soft-gold);
  color: var(--primary-dark);
  font-weight: 600;
}

.sidebar-menu .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--primary-gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-menu .nav-link p {
  margin: 0;
  line-height: 1.2;
}

/* Sidebar Bottom Branding */
.sidebar-footer {
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.sidebar-footer small {
  color: var(--text-secondary);
  font-size: 0.65rem;
  opacity: 0.6;
}

/* -- Main Content Area -- */
.app-main {
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: calc(100% - 260px);
}

/* -- Top Navigation -- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}

.app-header .header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 2rem;
  height: 64px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Notification Bell */
.notification-btn {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.notification-btn:hover {
  background: var(--soft-gold);
  color: var(--primary-dark);
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--card);
}

/* User Avatar Dropdown */
.user-dropdown {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem 0.35rem 0.35rem;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-dropdown:hover {
  background: var(--soft-gold);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--soft-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-gold);
  font-size: 0.8rem;
  font-weight: 700;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Date Badge */
.date-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--soft-gold);
  border: none;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--primary-brown);
}

/* -- Content Section -- */
.app-content {
  flex: 1;
  padding: 1.75rem 2rem 3rem;
}

.app-content .container-fluid {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.75rem;
  gap: 1rem;
}

.page-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.page-subtitle {
  margin: 0.25rem 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 400;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ============================================================
   4. COMPONENTS
   ============================================================ */

/* -- Cards -- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-base);
}

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

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

.card-body {
  padding: 1.5rem;
}

.card-footer {
  border-top: 1px solid var(--border);
  background: transparent;
  padding: 1rem 1.5rem;
}

/* -- Stat Cards (Dashboard) -- */
.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

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

/* -- Compact Stat Card -- */
.stat-card.stat-card-compact {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
}

.stat-card.stat-card-compact .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.stat-card.stat-card-compact .stat-label {
  font-size: 0.72rem;
  margin-bottom: 0.25rem;
}

.stat-card.stat-card-compact .stat-value {
  font-size: 1.35rem;
  font-weight: 700;
}

.stat-card.stat-card-compact .stat-caption {
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: var(--soft-gold);
  color: var(--primary-gold);
  margin-bottom: 0.75rem;
}

.stat-card .stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.35rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.5px;
  margin: 0;
  line-height: 1.2;
}

.stat-card .stat-caption {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Gold accent bar on stat cards */
.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  opacity: 0.3;
}

.stat-card:hover::after {
  opacity: 1;
}

/* -- Buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: var(--radius-md);
  font-family: var(--font-inter);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.65rem 1.25rem;
  transition: all var(--transition-base);
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(184, 137, 59, 0.2);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--primary-gold);
  color: #fff;
  border-color: var(--primary-gold);
}

.btn-primary:hover {
  background: var(--gold-hover);
  border-color: var(--gold-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--primary-dark);
  color: #fff;
  border-color: var(--primary-dark);
}

.btn-secondary:hover {
  background: var(--primary-brown);
  border-color: var(--primary-brown);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-success:hover {
  background: #16A34A;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #DC2626;
  color: #fff;
}

.btn-warning {
  background: var(--warning-soft);
  color: var(--primary-dark);
  border-color: transparent;
}

.btn-warning:hover {
  background: var(--soft-gold);
  color: var(--primary-dark);
}

.btn-info {
  background: var(--soft-gold);
  color: var(--primary-gold);
  border-color: transparent;
}

.btn-info:hover {
  background: var(--primary-gold);
  color: #fff;
}

.btn-light {
  background: var(--card);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-light:hover {
  background: var(--soft-gold);
  border-color: var(--border);
  color: var(--primary-dark);
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary-gold);
  border-color: var(--primary-gold);
}

.btn-outline-primary:hover {
  background: var(--primary-gold);
  color: #fff;
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-outline-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* Button sizes */
.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* -- Forms -- */
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  font-family: var(--font-inter);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  appearance: none;
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-gold);
  box-shadow: 0 0 0 3px rgba(184, 137, 59, 0.15);
}

.form-control::placeholder {
  color: #9CA3AF;
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--danger);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.invalid-feedback {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 0.25rem;
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* Input Group */
.input-group {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.input-group .form-control {
  flex: 1;
  min-width: 0;
}

.input-group .btn {
  border-radius: 0;
  margin-left: -1px;
}

.input-group .btn:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .btn:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group .form-control:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .form-control:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

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

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-check-input {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border);
  accent-color: var(--primary-gold);
  cursor: pointer;
}

.form-check-input:focus {
  border-color: var(--primary-gold);
  box-shadow: 0 0 0 3px rgba(184, 137, 59, 0.15);
}

.form-check-label {
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
}

/* -- Tables -- */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table thead th {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--soft-gold);
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

.table tbody td {
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  vertical-align: middle;
  border-bottom: 1px solid rgba(231, 222, 209, 0.4);
  color: var(--text-primary);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: rgba(246, 239, 227, 0.4);
}

.table thead th:first-child {
  border-radius: var(--radius-md) 0 0 0;
}

.table thead th:last-child {
  border-radius: 0 var(--radius-md) 0 0;
}

/* Table bordered variant */
.table-bordered {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-bordered th,
.table-bordered td {
  border: 1px solid var(--border);
}

/* Table sm variant */
.table-sm thead th {
  padding: 0.65rem 0.85rem;
}

.table-sm tbody td {
  padding: 0.65rem 0.85rem;
}

/* -- Badges -- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.4;
  white-space: nowrap;
}

.badge.bg-success {
  background: var(--success-soft) !important;
  color: #15803D;
}

.badge.bg-danger {
  background: var(--danger-soft) !important;
  color: #B91C1C;
}

.badge.bg-warning {
  background: var(--warning-soft) !important;
  color: #B45309;
}

.badge.bg-secondary {
  background: #F3F4F6 !important;
  color: #6B7280;
}

.badge.bg-info {
  background: var(--info-soft) !important;
  color: var(--primary-gold);
}

.badge.bg-primary {
  background: var(--info-soft) !important;
  color: var(--primary-gold);
}

/* -- Alerts -- */
.alert {
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}

.alert-success {
  background: var(--success-soft);
  color: #15803D;
}

.alert-danger {
  background: var(--danger-soft);
  color: #B91C1C;
}

.alert-warning {
  background: var(--warning-soft);
  color: #B45309;
}

.alert-info {
  background: var(--info-soft);
  color: var(--primary-brown);
}

/* -- Pagination -- */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 0;
  margin: 0;
  list-style: none;
}

.pagination .page-item {
  display: inline-flex;
}

.pagination .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.pagination .page-link:hover {
  background: var(--soft-gold);
  border-color: var(--border);
  color: var(--primary-dark);
}

.pagination .page-item.active .page-link {
  background: var(--primary-gold);
  border-color: var(--primary-gold);
  color: #fff;
}

.pagination .page-item.disabled .page-link {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* -- Modals -- */
.modal-content {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow-xl);
}

.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
}

.modal-title {
  font-weight: 700;
  font-size: 1.125rem;
}

.modal-backdrop {
  background: rgba(42, 26, 20, 0.3);
  backdrop-filter: blur(2px);
}

/* -- Dropdowns -- */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  min-width: 180px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--soft-gold);
  color: var(--primary-dark);
}

.dropdown-divider {
  border-top: 1px solid var(--border);
  margin: 0.35rem 0;
}

/* ============================================================
   5. UTILITY CLASSES
   ============================================================ */

/* Text colors */
.text-primary { color: var(--primary-gold) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-dark { color: var(--text-primary) !important; }
.text-muted { color: var(--text-secondary) !important; }

/* Background colors */
.bg-white { background: var(--card) !important; }
.bg-light { background: var(--background) !important; }
.bg-primary { background: var(--primary-gold) !important; }
.bg-primary-subtle { background: var(--soft-gold) !important; }
.bg-success-subtle { background: var(--success-soft) !important; }
.bg-danger-subtle { background: var(--danger-soft) !important; }
.bg-warning-subtle { background: var(--warning-soft) !important; }

/* Border colors */
.border { border: 1px solid var(--border) !important; }

/* Font weights */
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }

/* Spacing utilities */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }

/* Grid gap */
.g-4 { gap: 1.5rem !important; }
.g-3 { gap: 1rem !important; }
.g-2 { gap: 0.5rem !important; }

/* Rounded */
.rounded { border-radius: var(--radius-md) !important; }
.rounded-4 { border-radius: var(--radius-xl) !important; }
.rounded-pill { border-radius: var(--radius-full) !important; }

/* ============================================================
   6. POS PAGE SPECIFIC
   ============================================================ */

.sales-product-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  padding: 1.25rem;
  transition: all var(--transition-base);
  height: 100%;
}

.sales-product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--primary-gold);
}

.cart-item-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.sticky-cart {
  position: sticky;
  top: 88px;
}

.filter-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
}

/* ============================================================
   7. RESPONSIVE
   ============================================================ */

/* Tablet & below */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.show {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
    width: 100%;
  }

  .app-header .header-inner {
    padding: 0.75rem 1.25rem;
  }

  .app-content {
    padding: 1.25rem;
  }

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

  .page-title {
    font-size: 1.5rem;
  }

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

  .date-badge {
    display: none;
  }
}

/* Mobile */
@media (max-width: 575.98px) {
  .app-content {
    padding: 1rem;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .card-body {
    padding: 1.25rem;
  }

  .table thead th,
  .table tbody td {
    padding: 0.65rem 0.75rem;
  }

  .stat-card {
    padding: 1.25rem;
  }

  .stat-card .stat-value {
    font-size: 1.35rem;
  }

  .sidebar-footer {
    display: none;
  }

  .user-name {
    display: none;
  }
}

/* ============================================================
   8. OVERRIDES & COMPATIBILITY
   ============================================================ */

/* Chart containers */
.chart-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  padding: 1.5rem;
  box-shadow: var(--shadow-xs);
}

/* Hero card */
.hero-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 26, 20, 0.3);
  z-index: 1039;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-slow);
}

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

/* Product image thumbnails */
.product-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
}

.product-thumb-placeholder {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--soft-gold);
  color: var(--text-secondary);
  font-size: 1.2rem;
}

/* Color/Size checkboxes pill style */
.pill-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--card);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  user-select: none;
}

.pill-checkbox:hover {
  border-color: var(--primary-gold);
  background: var(--soft-gold);
}

.pill-checkbox input[type="checkbox"] {
  display: none;
}

.pill-checkbox input[type="checkbox"]:checked + span {
  color: var(--primary-gold);
}

.pill-checkbox:has(input:checked) {
  background: var(--soft-gold);
  border-color: var(--primary-gold);
  color: var(--primary-gold);
}

/* Login specific */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--background);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-card .auth-body {
  padding: 2.5rem;
}

.auth-card .auth-header {
  padding: 2rem 2.5rem 0;
  text-align: center;
}

.auth-card .auth-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  background: var(--primary-dark);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
}

.auth-card .auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.5px;
  margin-bottom: 0.25rem;
}

.auth-card .auth-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* Print styles */
@media print {
  .app-sidebar,
  .app-header {
    display: none !important;
  }

  .app-main {
    margin: 0 !important;
    width: 100% !important;
  }
}

/* ============================================================
   9. MOBILE RESPONSIVE REFINEMENTS
   ============================================================ */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.app-wrapper {
  max-width: 100%;
  overflow-x: clip;
}

img,
canvas,
svg {
  max-width: 100%;
}

.app-main,
.app-content,
.app-content .container-fluid,
.row > * {
  min-width: 0;
}

.stat-card > .d-flex > div:first-child {
  min-width: 0;
}

.stat-value,
.money-value,
.currency-value,
#grandTotalText,
#changeText {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  font-variant-numeric: tabular-nums;
}

.dashboard-stats-grid,
.financial-summary-grid {
  row-gap: 14px;
}

.expense-stats-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 1rem !important;
  margin-bottom: 1.5rem !important;
}

@media (max-width: 575.98px) {
  .expense-stats-grid {
    grid-template-columns: 1fr !important;
  }
}

.report-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.report-stats-grid .stat-card {
  height: 100%;
  min-width: 0;
}

.sales-filter-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.625rem;
}

.sales-filter-actions .btn,
.report-export-actions .btn {
  width: 100%;
}

.table-responsive {
  width: 100%;
  overscroll-behavior-inline: contain;
}

.table td:last-child,
.table th:last-child {
  white-space: nowrap;
}

.table td:last-child .btn,
.table td:last-child form {
  margin-block: 0.125rem;
}

.chart-responsive {
  position: relative;
  width: 100%;
  min-height: 280px;
  overflow: hidden;
}

.chart-responsive canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
}

.responsive-toolbar,
.responsive-toolbar-form {
  min-width: 0;
}

.pos-search {
  width: 100%;
  max-width: 420px;
}

.pos-cart-card {
  position: sticky;
  top: 88px;
}

.mobile-draft-list {
  display: none;
}

@media (max-width: 991.98px) {
  body.sidebar-open {
    overflow: hidden;
  }

  .app-sidebar {
    width: min(320px, 86vw);
    box-shadow: var(--shadow-xl);
    z-index: 1050;
  }

  .sidebar-overlay {
    z-index: 1045;
  }

  .app-header .header-inner {
    padding: 0.75rem 1.5rem;
  }

  .app-content {
    padding: 1.5rem 1.5rem 2.5rem;
  }

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

  .page-actions > * {
    flex: 1 1 auto;
  }

  .pos-cart-card {
    position: static !important;
    top: auto !important;
  }

  .modal-dialog {
    margin: 1rem;
    max-width: calc(100% - 2rem);
  }

  .modal-content {
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
  }

  .btn,
  .form-control,
  .form-select {
    min-height: 44px;
  }

  .report-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 1200px) {
  .report-stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 1045;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  }

  .app-sidebar.show {
    left: 0;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

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

  .app-wrapper {
    padding-left: 0 !important;
  }

  .dashboard-stats-grid,
  .expense-stats-grid {
    row-gap: 1rem;
  }

  .financial-summary-grid > [class*="col-"] {
    margin-bottom: 0.875rem;
  }
  .financial-summary-grid > [class*="col-"]:last-child {
    margin-bottom: 0;
  }
}

@media (max-width: 767.98px) {
  body {
    font-size: 14px;
    line-height: 1.5;
  }

  .app-header {
    min-height: 62px;
    padding: 0 0.875rem;
  }

  .app-header .header-inner {
    height: 62px;
    padding: 0.5rem 0.25rem;
  }

  .header-right {
    gap: 0.375rem;
  }

  .notification-btn,
  .sidebar-toggle,
  .user-dropdown {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
  }

  .app-content {
    padding: 1rem 0.875rem 2.5rem;
  }

  .app-content .container-fluid {
    padding: 0;
  }

  .page-header {
    margin-bottom: 1.25rem;
    gap: 0.75rem;
    flex-direction: column;
    align-items: flex-start !important;
  }

  .page-title {
    font-size: 1.45rem;
    line-height: 1.3;
  }

  .page-subtitle {
    font-size: 0.825rem;
    margin-top: 0.25rem;
  }

  .card,
  .stat-card,
  .modal-content {
    border-radius: 16px;
    margin-bottom: 1rem;
  }

  .card-header {
    padding: 1rem 1.125rem;
  }

  .card-body {
    padding: 1.125rem;
  }

  .card-footer {
    padding: 1rem 1.125rem;
  }

  .stat-card {
    padding: 1.125rem;
  }

  .stat-card:hover {
    transform: none;
  }

  .stat-card .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
    border-radius: 12px;
  }

  .stat-card .stat-value {
    font-size: clamp(1.25rem, 5.5vw, 1.5rem);
    letter-spacing: -0.03em;
  }

  .btn:not(.btn-sm),
  .form-control,
  .form-select {
    min-height: 44px;
    font-size: 0.875rem;
    border-radius: 10px;
  }

  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
  }

  .table {
    margin-bottom: 0;
    width: 100%;
    white-space: nowrap;
  }

  .table thead th,
  .table tbody td {
    padding: 0.75rem 0.875rem;
    font-size: 0.8125rem;
    vertical-align: middle;
  }

  .table .btn-sm {
    min-height: 36px;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .pagination {
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    justify-content: center;
  }

  .chart-responsive {
    height: 220px !important;
    min-height: 220px !important;
  }

  .report-stats-grid {
    grid-template-columns: 1fr;
    gap: 0.875rem;
  }

  .sales-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    width: 100%;
  }

  .sales-filter-actions .btn,
  .report-filter-form .btn {
    width: 100%;
    min-height: 44px;
  }

  .report-filter-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.875rem;
  }

  .report-export-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
    width: 100%;
  }

  .pos-search,
  .pos-search .input-group {
    width: 100%;
  }

  .pos-product-grid {
    row-gap: 0.875rem;
  }

  .pos-product-card img,
  .pos-product-card .product-image-placeholder {
    width: 68px !important;
    height: 68px !important;
  }

  .pos-cart-card .btn[type="submit"] {
    width: 100%;
    min-height: 48px;
    font-size: 0.95rem;
  }

  .stock-color-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.625rem;
  }

  .stock-color-toolbar .form-control {
    max-width: none !important;
  }

  .form-actions-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    width: 100%;
    margin-top: 1.25rem;
  }

  .form-actions-mobile .btn {
    width: 100%;
    min-height: 44px;
  }

  .auth-card {
    margin: 1.5rem auto;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  }

  .auth-card .auth-body {
    padding: 1.5rem 1.25rem 1.75rem;
  }

  .auth-card .auth-header {
    padding: 1.75rem 1.25rem 0;
  }
}

@media (max-width: 575.98px) {
  .report-export-actions {
    grid-template-columns: 1fr;
  }

/* -- Report Stats Grid (5 Cards Side-by-Side) -- */
.report-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1199.98px) {
  .report-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 767.98px) {
  .report-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .report-stats-grid {
    grid-template-columns: 1fr;
  }
}

