/* ============================================
   ACCOUNTING & BILLING SYSTEM – DESIGN SYSTEM
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --primary-text: var(--primary);
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-200: #c7d2fe;
  --primary-rgb: 79, 70, 229;
  --accent: #06b6d4;
  --accent-light: #67e8f9;
  --success: #10b981;
  --success-light: #d1fae5;
  --success-dark: #059669;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-dark: #d97706;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --danger-dark: #dc2626;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-sidebar-hover: #f1f5f9;
  --bg-sidebar-active: #eef2ff;
  --bg-input: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-inverse: #fff;
  --text-sidebar: #475569;
  --text-sidebar-active: #4f46e5;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --border-input: #cbd5e1;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .07), 0 2px 4px -1px rgba(0, 0, 0, .04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .08), 0 4px 6px -2px rgba(0, 0, 0, .03);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 10px 10px -5px rgba(0, 0, 0, .04);
  --sidebar-width: 260px;
  --navbar-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --transition-fast: .15s ease;
  --transition-normal: .25s ease;
}

[data-theme="dark"] {
  color-scheme: dark;
  --primary-text: var(--primary-200);
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #1e293b;
  --bg-card: #1e293b;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #1e293b;
  --bg-input: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #818cf8;
  --border-color: #334155;
  --border-light: #1e293b;
  --border-input: #475569;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, .3);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, .4);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased
}

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

a:hover {
  color: var(--primary-dark)
}

button {
  cursor: pointer;
  font-family: inherit
}

input,
select,
textarea {
  font-family: inherit
}

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

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-width));
  overflow-x: hidden;
  transition: margin-left var(--transition-normal)
}

.page-content {
  flex: 1;
  padding: 24px;
  margin-top: var(--navbar-height);
  max-width: 100%;
  overflow-x: hidden
}

/* Sidebar — Global Standard Enterprise Navigation */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
  color: var(--text-sidebar);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), width var(--transition-normal);
  overflow: hidden;
  border-right: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 2px 0 20px rgba(15, 23, 42, 0.03)
}

.sidebar-brand {
  padding: 14px 14px 12px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  flex-shrink: 0;
  margin: 0;
  background: transparent;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06)
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.26)
}

.sidebar-brand .brand-text {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.35px
}

.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase
}

.sidebar-close-btn {
  display: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(15, 23, 42, 0.03);
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.16s ease
}
.sidebar-close-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25)
}

.sidebar-search-box {
  position: relative;
  margin: 8px 10px 4px;
  flex-shrink: 0
}
.sidebar-search-box .sidebar-search-ic {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none
}
.sidebar-search-box input {
  width: 100%;
  height: 33px;
  padding: 0 28px 0 30px;
  border-radius: 9px;
  border: 1px solid rgba(15, 23, 42, 0.09);
  background: rgba(241, 245, 249, 0.7);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  outline: none;
  transition: all 0.18s ease
}
.sidebar-search-box input::placeholder {
  color: var(--text-tertiary);
  font-weight: 500
}
.sidebar-search-box input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1)
}
.sidebar-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center
}

.sidebar-nav {
  flex: 1;
  padding: 6px 10px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.22) transparent
}
.sidebar-nav::-webkit-scrollbar {
  width: 4px
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.22);
  border-radius: 4px
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 70, 229, 0.35)
}

.nav-section {
  margin-bottom: 6px
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-tertiary);
  padding: 12px 10px 4px
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7.5px 10px;
  border-radius: 10px;
  color: #334155;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
  white-space: nowrap;
  text-decoration: none;
  margin-bottom: 2px;
  position: relative;
  min-width: 0;
  user-select: none
}

.nav-item .nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3
}

.nav-item:hover {
  background: rgba(79, 70, 229, 0.055);
  color: #0f172a
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.11) 0%, rgba(124, 58, 237, 0.07) 100%);
  color: var(--primary);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--primary)
}

.nav-item .nav-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--ic-bg, rgba(79, 70, 229, 0.08));
  color: var(--ic-fg, var(--primary));
  flex-shrink: 0;
  font-size: 14px;
  transition: all 0.18s ease
}
.nav-item .nav-icon svg {
  display: block;
  flex-shrink: 0
}

.nav-item:hover .nav-icon {
  background: var(--ic-bg-hover, rgba(79, 70, 229, 0.14));
  transform: scale(1.03)
}

.nav-item.active .nav-icon {
  background: var(--ic-grad, linear-gradient(135deg, #4f46e5, #7c3aed));
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16)
}

.nav-item .nav-badge {
  margin-left: auto;
  background: linear-gradient(135deg, #ef4444, #f43f5e);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.28)
}

.sidebar-footer {
  display: none !important;
  padding: 8px 10px 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  flex-shrink: 0
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 12px;
  transition: all 0.18s ease
}

.sidebar-user .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.22)
}

.sidebar-user .user-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary)
}

.sidebar-user .user-role {
  font-size: 10.5px;
  color: var(--primary);
  font-weight: 600;
  opacity: .85
}

.sidebar-foot-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  transition: all 0.16s ease
}
.sidebar-foot-btn:hover {
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
  border-color: rgba(79, 70, 229, 0.25)
}
.sidebar-foot-btn.sidebar-foot-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25)
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--navbar-height);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid rgba(79,70,229,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 900;
  transition: left var(--transition-normal)
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 22px;
  padding: 6px;
  border-radius: 10px;
  transition: all 0.2s
}

.menu-toggle:hover {
  background: rgba(79,70,229,0.08)
}

.page-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-top: 1px
}

.navbar-search {
  position: relative;
  width: 320px
}

.navbar-search input {
  width: 100%;
  padding: 10px 18px 10px 42px;
  border: 1.5px solid rgba(79,70,229,0.12);
  border-radius: 14px;
  background: rgba(79,70,229,0.03);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  outline: none;
  transition: all 0.25s
}

.navbar-search input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79,70,229,0.08)
}

.navbar-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary);
  font-size: 15px;
  opacity: 0.6
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 6px
}

.nav-btn {
  position: relative;
  background: rgba(79,70,229,0.04);
  border: 1.5px solid rgba(79,70,229,0.08);
  color: var(--text-secondary);
  font-size: 18px;
  padding: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  transition: all 0.2s
}

.nav-btn:hover {
  background: rgba(79,70,229,0.1);
  border-color: rgba(79,70,229,0.2);
  color: var(--primary);
  transform: translateY(-1px)
}

.nav-btn .badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: linear-gradient(135deg, #ef4444, #f43f5e);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 0 6px rgba(239,68,68,0.4)
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 4px;
  border-radius: 14px;
  border: 1.5px solid rgba(79,70,229,0.1);
  background: rgba(79,70,229,0.03);
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 4px
}

.user-menu:hover {
  border-color: rgba(79,70,229,0.2);
  background: rgba(79,70,229,0.06);
  transform: translateY(-1px)
}

.user-menu .avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(79,70,229,0.25)
}

.user-menu .user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary)
}

/* Dropdown */
.dropdown {
  position: relative
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition-fast);
  z-index: 1100;
  overflow: hidden
}

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

.dropdown-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background var(--transition-fast)
}

.dropdown-menu .dropdown-item:hover {
  background: var(--bg-tertiary)
}

.dropdown-menu .dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0
}

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

/* ── Mobile & Tablet Responsive ── */
@media (max-width: 1024px) {

  /* Sidebar drawer on mobile & tablet */
  .sidebar {
    width: min(292px, 86vw);
    height: 100vh;
    height: 100dvh;
    transform: translateX(-104%);
    z-index: 1005;
    border-radius: 0 18px 18px 0;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 16px 0 44px rgba(15, 23, 42, 0.28);
  }

  .sidebar-close-btn {
    display: inline-flex;
  }

  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
  }

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

  /* Main content full width */
  .main-content {
    margin-left: 0 !important;
    max-width: 100vw !important;
  }

  /* Navbar full width */
  .navbar {
    left: 0 !important;
    padding: 0 12px !important;
    height: 56px !important;
    gap: 8px !important;
  }

  /* Show hamburger menu */
  .menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
  }

  /* Truncate page title */
  .navbar-left {
    flex: 1;
    min-width: 0;
    gap: 8px !important;
  }

  .page-title {
    font-size: 15px !important;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
  }

  .page-subtitle {
    font-size: 11px !important;
    opacity: 0.7;
  }

  /* Hide search bar on mobile */
  .navbar-search {
    display: none !important;
  }

  /* Compact right side */
  .navbar-right {
    gap: 4px !important;
    flex-shrink: 0;
  }

  .nav-btn {
    font-size: 18px !important;
    padding: 6px !important;
    width: 34px !important;
    height: 34px !important;
    flex-shrink: 0 !important;
  }

  /* PWA Install button — hidden on mobile */
  #pwaInstallBtn {
    display: none !important;
  }

  .user-menu .user-name {
    display: none !important;
  }

  .user-menu {
    padding: 2px !important;
    border: none !important;
    background: none !important;
  }

  .user-menu .avatar {
    width: 30px !important;
    height: 30px !important;
    font-size: 12px !important;
  }

  /* Fix page content top margin */
  .page-content {
    margin-top: 56px !important;
    padding: 12px !important;
  }
}

/* ── Global Standard Tree-Rail Submenu & Group Accordion ── */
.nav-group {
    margin-bottom: 2px;
}
.nav-group-toggle .arrow {
    margin-left: 4px;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #94a3b8;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), color 0.18s ease;
}
.nav-group-toggle:hover .arrow {
    color: var(--primary);
}
.nav-group.open > .nav-group-toggle {
    background: rgba(15, 23, 42, 0.03);
    color: #0f172a;
    font-weight: 600;
}
.nav-group.has-active > .nav-group-toggle {
    background: rgba(79, 70, 229, 0.06);
    color: var(--primary);
    font-weight: 700;
}
.nav-group.open > .nav-group-toggle .arrow {
    transform: rotate(180deg);
    color: var(--primary);
}
.nav-submenu {
    display: none;
    margin: 2px 0 6px 23px;
    padding: 2px 0 2px 9px;
    border-left: 1.5px solid rgba(148, 163, 184, 0.28);
}
.nav-group.has-active > .nav-submenu {
    border-left-color: rgba(79, 70, 229, 0.28);
}
.nav-group.open > .nav-submenu {
    display: block !important;
    animation: sbSubmenuOpen 0.16s ease-out;
}
@keyframes sbSubmenuOpen {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
}
.nav-submenu .nav-item {
    font-size: 12.5px;
    font-weight: 500;
    padding: 6.5px 9px;
    gap: 8px;
    margin-bottom: 1.5px;
    border-radius: 8px;
    color: #475569;
    box-shadow: none;
}
.nav-submenu .nav-item::before {
    display: none;
    content: none;
}
.nav-submenu .sub-icon,
.nav-submenu .nav-item .nav-icon.nav-icon-sub {
    width: 20px;
    height: 20px;
    min-width: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(100, 116, 139, 0.08);
    color: #64748b;
    font-size: 11px;
    flex-shrink: 0;
    transition: all 0.18s ease;
}
.nav-submenu .sub-icon svg {
    display: block;
    width: 13px;
    height: 13px;
}
.nav-submenu .nav-item:hover .sub-icon,
.nav-submenu .nav-item:hover .nav-icon.nav-icon-sub {
    background: rgba(79, 70, 229, 0.14);
    color: var(--primary);
    transform: scale(1.05);
}
.nav-submenu .nav-item.active .sub-icon,
.nav-submenu .nav-item.active .nav-icon.nav-icon-sub {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.28);
}

/* Standard White Sidebar */
.sidebar-user.glass-panel {
    background: rgba(248, 250, 252, 0.9);
    backdrop-filter: none;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: none;
    border-radius: 12px
}
.sidebar-user.glass-panel:hover {
    background: rgba(79, 70, 229, 0.05);
    border-color: rgba(79, 70, 229, 0.18)
}

/* Dark mode sidebar override */
[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    border-right: 1px solid rgba(99, 102, 241, 0.14);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35)
}
[data-theme="dark"] .sidebar-brand {
    background: transparent;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: none
}
[data-theme="dark"] .sidebar-brand .brand-text {
    color: #f8fafc
}
[data-theme="dark"] .sidebar-close-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #cbd5e1
}
[data-theme="dark"] .sidebar-search-box input {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(148, 163, 184, 0.16);
    color: #f1f5f9
}
[data-theme="dark"] .sidebar-search-box input:focus {
    background: #1e293b;
    border-color: #818cf8
}
[data-theme="dark"] .sidebar-footer {
    border-top-color: rgba(148, 163, 184, 0.1)
}
[data-theme="dark"] .sidebar-user .user-name,
[data-theme="dark"] .sidebar-user .js-user-name {
    color: #f1f5f9 !important
}
[data-theme="dark"] .sidebar-foot-btn {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(148, 163, 184, 0.16);
    color: #cbd5e1
}
[data-theme="dark"] .navbar {
    background: rgba(15, 23, 42, 0.85);
    border-bottom: 1px solid rgba(99, 102, 241, 0.1)
}
[data-theme="dark"] .nav-btn {
    background: rgba(99, 102, 241, 0.06);
    border-color: rgba(99, 102, 241, 0.1)
}
[data-theme="dark"] .user-menu {
    background: rgba(99, 102, 241, 0.06);
    border-color: rgba(99, 102, 241, 0.12)
}
[data-theme="dark"] .sidebar-user.glass-panel {
    background: rgba(30, 41, 59, 0.65);
    border-color: rgba(148, 163, 184, 0.14)
}
[data-theme="dark"] .nav-item .nav-icon,
[data-theme="dark"] .nav-submenu .nav-item .nav-icon.nav-icon-sub {
    background: var(--ic-bg-dark, rgba(99, 102, 241, 0.16));
    color: var(--ic-fg-dark, #a5b4fc)
}
[data-theme="dark"] .navbar-search input {
    background: rgba(99, 102, 241, 0.06);
    border-color: rgba(99, 102, 241, 0.12)
}

/* ── Dark Mode Comprehensive Fixes ── */

/* Sidebar active nav item — bright text */
[data-theme="dark"] .nav-item {
    color: #cbd5e1
}
[data-theme="dark"] .nav-item:hover {
    background: rgba(99, 102, 241, 0.12);
    color: #f8fafc
}
[data-theme="dark"] .nav-item.active {
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe
}
[data-theme="dark"] .nav-group.open > .nav-group-toggle {
    background: rgba(255, 255, 255, 0.04);
    color: #f1f5f9
}
[data-theme="dark"] .nav-group.has-active > .nav-group-toggle {
    background: rgba(99, 102, 241, 0.16);
    color: #c7d2fe
}
[data-theme="dark"] .nav-submenu {
    border-left-color: rgba(148, 163, 184, 0.2);
}
[data-theme="dark"] .nav-submenu .sub-icon,
[data-theme="dark"] .nav-submenu .nav-item .nav-icon.nav-icon-sub {
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
}
[data-theme="dark"] .nav-submenu .nav-item:hover .sub-icon,
[data-theme="dark"] .nav-submenu .nav-item:hover .nav-icon.nav-icon-sub {
    background: rgba(99, 102, 241, 0.22);
    color: #c7d2fe;
}
[data-theme="dark"] .nav-submenu .nav-item.active .sub-icon,
[data-theme="dark"] .nav-submenu .nav-item.active .nav-icon.nav-icon-sub {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

/* Tab buttons (All, Paid, Pending, Overdue) */
[data-theme="dark"] .tab-btn {
    color: #94a3b8
}
[data-theme="dark"] .tab-btn:hover {
    color: #e2e8f0
}
[data-theme="dark"] .tab-btn.active {
    background: rgba(99,102,241,0.15);
    color: #a5b4fc;
    box-shadow: none
}

/* Outline buttons (Bulk Reminders, etc.) */
[data-theme="dark"] .btn-outline {
    color: #a5b4fc;
    border-color: rgba(129,140,248,0.4);
    background: rgba(99,102,241,0.08)
}
[data-theme="dark"] .btn-outline:hover {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1
}

/* Ghost buttons */
[data-theme="dark"] .btn-ghost {
    color: #94a3b8
}
[data-theme="dark"] .btn-ghost:hover {
    background: rgba(99,102,241,0.1);
    color: #e2e8f0
}

/* Secondary buttons */
[data-theme="dark"] .btn-secondary {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569
}
[data-theme="dark"] .btn-secondary:hover {
    background: #475569
}

/* Table headers & rows */
[data-theme="dark"] .table th {
    background: #1e293b;
    color: #94a3b8;
    border-color: #334155
}
[data-theme="dark"] .table td {
    border-color: #334155;
    color: #e2e8f0
}
[data-theme="dark"] .table tr:hover td {
    background: rgba(99,102,241,0.05)
}

/* Form controls */
[data-theme="dark"] .form-control,
[data-theme="dark"] select.form-control {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-input)
}
[data-theme="dark"] .form-control:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15)
}
[data-theme="dark"] .form-control::placeholder {
    color: #64748b
}
[data-theme="dark"] .form-label {
    color: #94a3b8
}

/* Dropdown menus */
[data-theme="dark"] .dropdown-menu {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4)
}
[data-theme="dark"] .dropdown-item {
    color: #e2e8f0
}
[data-theme="dark"] .dropdown-item:hover {
    background: rgba(99,102,241,0.1)
}
[data-theme="dark"] .dropdown-divider {
    border-color: #334155
}

/* Cards */
[data-theme="dark"] .card {
    background: #1e293b;
    border-color: #334155
}

/* Page headers */
[data-theme="dark"] .page-header h1 {
    color: #f1f5f9
}
[data-theme="dark"] .page-header p {
    color: #94a3b8
}

/* Status badges */
[data-theme="dark"] .badge {
    border: 1px solid rgba(255,255,255,0.1)
}

/* Modals */
[data-theme="dark"] .modal-content {
    background: #1e293b;
    border-color: #334155
}
[data-theme="dark"] .modal-overlay {
    background: rgba(0,0,0,0.7)
}

/* Toolbar & search */
[data-theme="dark"] .toolbar {
    border-color: #334155
}

/* Nav submenu items */
[data-theme="dark"] .nav-submenu .nav-item {
    color: #94a3b8
}
[data-theme="dark"] .nav-submenu .nav-item:hover {
    color: #c7d2fe
}
[data-theme="dark"] .nav-submenu .nav-item.active {
    color: #a5b4fc
}

/* Notification panel */
[data-theme="dark"] .notif-panel {
    background: #1e293b;
    border-color: #334155
}

/* Scrollbars */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #0f172a
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #334155
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #475569
}
/* Document Totals */
.summary-label { color: var(--text-secondary); }
[data-theme="dark"] .summary-label, html[data-theme="dark"] .summary-label { color: var(--text-primary) !important; }
.summary-total { color: var(--primary); }
[data-theme="dark"] .summary-total, html[data-theme="dark"] .summary-total { color: var(--primary-200) !important; }

