/* ============================================
   BILLING SYSTEM - PREMIUM DESIGN SYSTEM
   ============================================ */

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

/* ---- CSS Variables ---- */
:root {
  /* Professional blue & white palette */
  --primary: #0066cc;
  --primary-light: #3399ff;
  --primary-dark: #0052a3;
  --primary-bg: #e6f2ff;

  --sidebar-bg: #f5f9ff;
  --sidebar-hover: #e6f2ff;
  --sidebar-active: #cce5ff;

  --bg: #ffffff;
  --card: #ffffff;

  --success: #059669;
  --success-bg: #ecfdf5;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --info: #0284c7;
  --info-bg: #f0f9ff;

  --text-primary: #1e3a5f;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --border: #b3d9ff;
  --border-light: #f1f5f9;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 15px rgba(29, 78, 216, 0.15);
  
  /* Modern border radii */
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --sidebar-width: 280px;
  --navbar-height: 64px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Typography */
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

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

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

html:has(.app-wrapper),
html:has(.app-wrapper) body {
  height: 100%;
  overflow: hidden;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; font-family: var(--font-body); }
input, select, textarea { font-family: var(--font-body); }

/* ---- App Layout ---- */
.app-wrapper {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.content-area {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px 20px 20px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #b3d9ff transparent;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  overflow: hidden;
  box-shadow: 2px 0 12px rgba(29, 78, 216, 0.06);
  border-right: 1px solid var(--border);
}

/* Sidebar brand stays fixed at top */
.sidebar-brand {
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  flex-shrink: 0;
}

.sidebar-brand::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 24px;
  right: 24px;
  height: 1px;
  background: var(--border);
}

.sidebar-brand .brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-dark) 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25);
}

.sidebar-brand .brand-text {
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.sidebar-brand .brand-sub {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.sidebar-menu {
  padding: 12px 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 102, 204, 0.2) transparent;
}

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

.sidebar-menu::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(0, 102, 204, 0.2);
  border-radius: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 102, 204, 0.4);
}

.sidebar-menu .menu-label {
  padding: 0 16px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.sidebar-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--transition);
  border-radius: 10px;
  margin-bottom: 4px;
}

.sidebar-menu .menu-item:hover {
  background: var(--sidebar-hover);
  color: var(--primary);
  transform: translateX(4px);
}

.sidebar-menu .menu-item.active {
  background: var(--sidebar-active);
  color: var(--primary);
  position: relative;
}

.sidebar-menu .menu-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10%;
  height: 80%;
  width: 4px;
  background: var(--primary-light);
  border-radius: 0 4px 4px 0;
  box-shadow: var(--shadow-glow);
}

.sidebar-menu .menu-item i { 
  font-size: 1.2rem;
  transition: var(--transition);
}

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

.sidebar-footer {
  padding: 12px 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-footer .menu-item { padding: 12px 16px; border-radius: 10px; }

/* ---- Top Navbar ---- */
.top-navbar {
  height: var(--navbar-height);
  flex-shrink: 0;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  transition: var(--transition);
}

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

.navbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.navbar-breadcrumb .current { 
  color: var(--text-primary); 
  font-weight: 700; 
  font-family: var(--font-display);
}

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

.navbar-search input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  border: 1px solid transparent;
  border-radius: 20px;
  font-size: 0.9rem;
  background: rgba(241, 245, 249, 0.8);
  transition: var(--transition);
}

.navbar-search input:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.1);
}

.navbar-search i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

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

.navbar-right .nav-icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
  font-size: 1.1rem;
}

.navbar-right .nav-icon-btn:hover { 
  background: var(--bg); 
  color: var(--primary); 
  border-color: var(--border);
}

.navbar-right .nav-icon-btn .badge-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.navbar-right .nav-datetime {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  margin-right: 8px;
}

.navbar-right .user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px;
  border-radius: 30px;
  padding-right: 16px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.navbar-right .user-profile:hover { 
  background: var(--bg); 
  border-color: var(--border);
}

.navbar-right .user-profile .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.3);
}

.navbar-right .user-profile .user-info { line-height: 1.2; }
.navbar-right .user-profile .user-name { font-weight: 700; font-size: 0.9rem; color: var(--text-primary); }
.navbar-right .user-profile .user-role { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }

/* ---- Page Header ---- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.5rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header h1 i {
  color: var(--primary);
  background: var(--primary-bg);
  padding: 8px;
  border-radius: 10px;
  font-size: 1.4rem;
}

.page-header p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: var(--transition);
  overflow: hidden;
}

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

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(248, 250, 252, 0.5);
}

.card-header h5 { 
  font-size: 1.1rem; 
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 16px; }
.card-footer { padding: 14px 16px; border-top: 1px solid var(--border-light); background: rgba(248, 250, 252, 0.5); }

/* ---- Stat Cards ---- */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: transparent;
  transition: var(--transition);
}

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

.stat-card:hover::before {
  background: linear-gradient(90deg, var(--primary) 0%, var(--info) 100%);
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 12px;
}

.stat-card .stat-icon.blue { background: var(--primary-bg); color: var(--primary); }
.stat-card .stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-card .stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-card .stat-icon.orange { background: var(--warning-bg); color: var(--warning); }

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-display);
  line-height: 1.1;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card .stat-trend {
  font-size: 0.85rem;
  margin-top: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
}

.stat-card .stat-trend.up { color: var(--success); background: var(--success-bg); }
.stat-card .stat-trend.down { color: var(--danger); background: var(--danger-bg); }

/* ---- Tables ---- */
.table-container {
  overflow-x: auto;
  overflow-y: visible;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
  transition: var(--transition);
}

.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { 
  background: #f1f5f9; 
}
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  font-family: var(--font-body);
}

.btn:active { transform: scale(0.97); }

.btn-primary { 
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); 
  color: #fff; 
  box-shadow: 0 4px 10px rgba(29, 78, 216, 0.2);
}
.btn-primary:hover { 
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%); 
  box-shadow: 0 6px 14px rgba(29, 78, 216, 0.3);
  transform: translateY(-1px);
}

.btn-success { 
  background: linear-gradient(135deg, var(--success) 0%, #34d399 100%);
  color: #fff; 
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}
.btn-success:hover { 
  background: linear-gradient(135deg, #059669 0%, var(--success) 100%); 
  transform: translateY(-1px);
}

.btn-danger { 
  background: linear-gradient(135deg, var(--danger) 0%, #f87171 100%);
  color: #fff; 
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { 
  background: var(--bg); 
  color: var(--text-primary);
  border-color: #cbd5e1;
}

.btn-sm { padding: 6px 14px; font-size: 0.85rem; border-radius: 6px;}
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: 12px;}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  transition: var(--transition);
}

.btn-icon:hover { background: #f1f5f9; transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn-icon.edit:hover { color: var(--primary); border-color: var(--primary-light); background: var(--primary-bg); }
.btn-icon.delete:hover { color: var(--danger); border-color: #fca5a5; background: var(--danger-bg); }

/* ---- Form Controls ---- */
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: #f8fafc;
  transition: var(--transition);
}

.form-control:hover { background: #fff; border-color: #cbd5e1; }

.form-control:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.1);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { 
  appearance: none; 
  cursor: pointer; 
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(14, 165, 233, 0.2); }
.badge-primary { background: var(--primary-bg); color: var(--primary); border: 1px solid rgba(29, 78, 216, 0.2); }

/* ---- Searchable Dropdown ---- */
.sd-wrapper {
  position: relative;
  width: 100%;
}

.sd-dropdown {
  /* position: fixed + left/top/width set in JS (SearchableDropdown._position()),
     from the input's own getBoundingClientRect() — this panel lives on <body>,
     not inside .sd-wrapper, specifically so an ancestor card/section with
     `overflow: hidden` can't clip it (see utils.js for the full rationale). */
  position: fixed;
  max-height: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 4000; /* above .modal-overlay (2000) and .toast-container (3000) — this can open from inside a modal */
  overflow-y: auto;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 102, 204, 0.2) transparent;
}

.sd-dropdown::-webkit-scrollbar { width: 4px; }
.sd-dropdown::-webkit-scrollbar-thumb { background: rgba(0, 102, 204, 0.2); border-radius: 4px; }

.sd-visible {
  display: block;
  animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.sd-item {
  padding: 8px 12px;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
}

.sd-item strong {
  color: var(--primary);
  font-weight: 700;
}

.sd-item:hover, .sd-highlight {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.sd-empty {
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.active { display: flex; opacity: 1; }

.modal-box {
  background: var(--card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-header h5 { font-size: 1.3rem; }

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: var(--danger-bg); color: var(--danger); border-color: transparent; transform: rotate(90deg); }

.modal-body { padding: 32px; }
.modal-footer {
  padding: 20px 32px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: #f8fafc;
  position: sticky;
  bottom: 0;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  justify-content: flex-end;
}

.pagination button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
}

.pagination button:hover { background: #f1f5f9; color: var(--text-primary); }
.pagination button.active { 
  background: var(--primary); 
  color: #fff; 
  border-color: var(--primary); 
  box-shadow: 0 4px 10px rgba(29, 78, 216, 0.3);
}

/* ---- Status Indicators ---- */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}

.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--danger); }
.status-dot.low { background: var(--warning); }

/* ---- Invoice Specific ---- */
.invoice-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.invoice-section:hover { box-shadow: var(--shadow); }

.invoice-section .section-title {
  padding: 10px 16px;
  background: #f8fafc;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}

.invoice-section .section-title i { color: var(--primary); font-size: 1.1rem; }
.invoice-section .section-body { padding: 14px 16px; }

.invoice-summary {
  background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--border-light);
}

.invoice-summary .summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.invoice-summary .summary-row span:last-child { font-weight: 600; color: var(--text-primary); }

.invoice-summary .summary-row.total {
  border-top: 2px dashed #cbd5e1;
  margin-top: 12px;
  padding-top: 16px;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  font-family: var(--font-display);
}
.invoice-summary .summary-row.total span:last-child { color: var(--primary); }

/* Compact invoice form layout */
.content-area:has(#invoice-items-table) .page-header p { margin-top: 2px; font-size: 0.85rem; }
.content-area:has(#invoice-items-table) .invoice-section:last-of-type { margin-bottom: 0; }
#invoice-items-table th,
#invoice-items-table td { padding: 8px 10px; font-size: 0.85rem; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.data-table .empty-state,
td .empty-state {
  padding: 14px 12px;
}

.data-table .empty-state i,
td .empty-state i {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.data-table .empty-state h5,
td .empty-state h5 {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.data-table .empty-state p,
td .empty-state p {
  font-size: 0.85rem;
}

.empty-state i { 
  font-size: 2.5rem; 
  margin-bottom: 12px; 
  color: #cbd5e1;
  display: block;
}
.empty-state h5 { font-size: 1.2rem; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { font-size: 0.95rem; color: var(--text-secondary); }

/* ---- Login Page ---- */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(29, 78, 216, 0.08) 0%, transparent 60%);
  z-index: 0;
}

.login-card {
  background: #ffffff;
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(29, 78, 216, 0.12);
  width: 100%;
  max-width: 440px;
  padding: 48px;
  position: relative;
  z-index: 1;
  border: 1px solid var(--border);
}

.login-card .login-brand { text-align: center; margin-bottom: 40px; }

.login-card .login-brand .icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.8rem;
  margin-bottom: 20px;
  box-shadow: 0 10px 20px rgba(29, 78, 216, 0.2);
}

.login-card .login-brand h2 { font-size: 1.8rem; font-weight: 800; color: var(--text-primary); }
.login-card .login-brand p { font-size: 0.95rem; color: var(--text-secondary); margin-top: 8px; }

.login-card .password-wrapper { position: relative; }

.login-card .password-wrapper .toggle-pw {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
}

.login-card .form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
}

.login-card .form-check input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
}

.login-card .form-check label { font-size: 0.9rem; color: var(--text-secondary); margin: 0; cursor: pointer;}

.login-card .forgot-link {
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 600;
  transition: var(--transition);
}
.login-card .forgot-link:hover { color: var(--primary-dark); text-decoration: underline; }

.login-card .btn-login {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
}

/* ---- Utility Classes ---- */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 14px; }
.mb-24 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.85rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.modal-box.modal-compact {
  max-width: 680px;
  max-height: none;
  overflow: visible;
}

.modal-compact .modal-header { padding: 14px 18px; }
.modal-compact .modal-header h5 { font-size: 1.05rem; }
.modal-compact .modal-body { padding: 16px 18px 10px; }
.modal-compact .modal-footer { padding: 12px 18px; }
.modal-compact .form-group { margin-bottom: 8px; }
.modal-compact .form-group label { font-size: 0.8rem; margin-bottom: 3px; }
.modal-compact .form-control { padding: 7px 10px; font-size: 0.85rem; }
.modal-compact textarea.form-control { min-height: 34px; resize: none; }
.modal-compact .grid-2,
.modal-compact .grid-3 { gap: 10px; }

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

@media (max-width: 768px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ---- Alert / Toast ---- */
.toast-container {
  position: fixed;
  top: 90px;
  right: 32px;
  z-index: 3000;
}

.toast {
  background: #fff;
  border-left: 5px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px 24px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.95rem;
  font-weight: 500;
  min-width: 320px;
  animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast i { font-size: 1.2rem; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(50px) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
  gap: 8px;
}

.tab-btn {
  padding: 12px 24px;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  font-family: var(--font-body);
}

.tab-btn:hover { color: var(--text-primary); background: rgba(0,0,0,0.02); border-radius: 8px 8px 0 0; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- Chart Container ---- */
.chart-container { position: relative; padding: 8px 0; width: 100%; height: 200px; max-height: 24vh; }

/* ---- Responsive ---- */

/* Large desktops — sidebar narrower on mid-size screens */
@media (max-width: 1400px) {
  :root {
    --sidebar-width: 250px;
  }
}

@media (max-width: 1200px) {
  :root {
    --sidebar-width: 230px;
  }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  .sidebar-menu .menu-item {
    padding: 8px 12px;
    font-size: 0.9rem;
    gap: 10px;
  }

  .sidebar-menu .menu-item i {
    font-size: 1.1rem;
  }

  .sidebar-brand .brand-text {
    font-size: 1.2rem;
  }

  .sidebar-brand .brand-icon {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
  }
}

/* Tablets — sidebar becomes an off-canvas drawer */
@media (max-width: 992px) {
  :root {
    --sidebar-width: 280px;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  .main-content { margin-left: 0; }
  .top-navbar { padding: 0 16px; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2-1 { grid-template-columns: 1fr; }
  /* Scoped to the cramped top navbar's own global search box only — .navbar-search
     is also reused as the plain filter-search input on several list pages
     (products/customers/suppliers/invoice/inventory/cashflow), which live in the
     roomy content area, not the navbar, and have no reason to disappear here. */
  .top-navbar .navbar-search { display: none; }

  .navbar-right .nav-datetime {
    display: none;
  }
}

/* Small tablets / large phones */
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content-area { padding: 12px 14px 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }

  .navbar-right .user-info {
    display: none;
  }

  .top-navbar {
    padding: 0 12px;
  }

  .navbar-right {
    gap: 8px;
  }

  .navbar-right .nav-icon-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}

/* Small phones */
@media (max-width: 480px) {
  :root {
    --sidebar-width: 260px;
    --navbar-height: 56px;
  }

  .sidebar-brand {
    padding: 14px 16px;
    gap: 12px;
  }

  .sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    border-radius: 10px;
  }

  .sidebar-brand .brand-text {
    font-size: 1.15rem;
  }

  .sidebar-menu {
    padding: 8px 8px;
  }

  .sidebar-menu .menu-item {
    padding: 10px 12px;
    font-size: 0.9rem;
    gap: 10px;
    margin-bottom: 2px;
  }

  .sidebar-footer {
    padding: 8px 8px 12px;
  }

  .content-area {
    padding: 10px 12px 14px;
  }

  .page-header h1 {
    font-size: 1.25rem;
  }

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

  .btn {
    padding: 8px 16px;
    font-size: 0.85rem;
  }

  .navbar-breadcrumb {
    font-size: 0.8rem;
    gap: 6px;
  }
}

/* Very small screens */
@media (max-width: 360px) {
  :root {
    --sidebar-width: 240px;
  }

  .sidebar-menu .menu-item {
    padding: 9px 10px;
    font-size: 0.85rem;
  }

  .sidebar-menu .menu-item i {
    font-size: 1rem;
  }
}

/* Landscape phones — limit sidebar height properly */
@media (max-height: 500px) {
  .sidebar-brand {
    padding: 10px 16px;
  }

  .sidebar-menu .menu-item {
    padding: 6px 12px;
    margin-bottom: 1px;
  }

  .sidebar-menu .menu-label {
    padding: 0 16px 6px;
    font-size: 0.7rem;
  }

  .sidebar-footer {
    padding: 6px 8px 8px;
  }

  .sidebar-footer .menu-item {
    padding: 8px 16px;
  }
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1.4rem;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.menu-toggle:active { background: var(--bg); }

@media (max-width: 992px) {
  .menu-toggle { display: flex; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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