/* ============================================================
   Chris's Garage Doors — Invoice App Design System
   Joist-inspired invoicing UI with sidebar navigation
   ============================================================ */

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

/* ============================================================
   1. CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* — Brand Colors — */
  --color-primary:          #498F66;
  --color-primary-rgb:      73, 143, 102;
  --color-primary-hover:    #3a7353;
  --color-primary-light:    #e8f5ee;
  --color-primary-lighter:  #d0ebdb;

  /* — Dark Palette — */
  --color-dark:             #0A1015;
  --color-dark-secondary:   #1D1E20;
  --color-dark-tertiary:    #2a2c30;

  /* — Text — */
  --text-dark:              #1a1a2e;
  --text-secondary:         #555555;
  --text-gray:              #888888;
  --text-light:             #b0b0b0;
  --text-white:             #ffffff;
  --text-inverse:           #ffffff;

  /* — Backgrounds — */
  --bg-primary:             #f5f7fa;
  --bg-card:                #ffffff;
  --bg-sidebar:             #0A1015;
  --bg-header:              #ffffff;
  --bg-input:               #f0f2f5;
  --bg-hover:               rgba(255, 255, 255, 0.06);
  --bg-active:              rgba(73, 143, 102, 0.12);

  /* — Borders — */
  --border-color:           #e2e8f0;
  --border-light:           #f0f0f0;
  --border-input:           #d1d5db;
  --border-focus:           #498F66;

  /* — Status Colors — */
  --color-success:          #498F66;
  --color-success-light:    #e8f5ee;
  --color-danger:           #e74c3c;
  --color-danger-light:     #fdecea;
  --color-warning:          #f59e0b;
  --color-warning-light:    #fef3c7;
  --color-info:             #3b82f6;
  --color-info-light:       #eff6ff;
  --color-draft:            #6b7280;
  --color-draft-light:      #f3f4f6;

  /* — Spacing Scale — */
  --space-1:    4px;
  --space-2:    8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-5:   20px;
  --space-6:   24px;
  --space-7:   28px;
  --space-8:   32px;
  --space-10:  40px;
  --space-12:  48px;
  --space-16:  64px;

  /* — Typography — */
  --font-family:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs:       0.75rem;   /* 12px */
  --font-size-sm:       0.8125rem; /* 13px */
  --font-size-base:     0.875rem;  /* 14px */
  --font-size-md:       1rem;      /* 16px */
  --font-size-lg:       1.125rem;  /* 18px */
  --font-size-xl:       1.25rem;   /* 20px */
  --font-size-2xl:      1.5rem;    /* 24px */
  --font-size-3xl:      1.875rem;  /* 30px */
  --font-size-4xl:      2.25rem;   /* 36px */
  --font-weight-light:  300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semi:   600;
  --font-weight-bold:   700;
  --line-height:        1.6;

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

  /* — Shadows — */
  --shadow-xs:    0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:    0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg:    0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl:    0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-card:  0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-card-hover: 0 8px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.04);
  --shadow-focus: 0 0 0 3px rgba(73, 143, 102, 0.25);

  /* — Transitions — */
  --transition-fast:   all 0.15s ease;
  --transition-base:   all 0.2s ease;
  --transition-slow:   all 0.3s ease;
  --transition-spring: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* — Layout — */
  --sidebar-width:     260px;
  --header-height:     68px;
  --content-max-width: 1400px;

  /* — Z-Index Scale — */
  --z-base:     1;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  500;
  --z-modal:    600;
  --z-toast:    700;
  --z-tooltip:  800;
}

/* ============================================================
   2. RESET & BASE STYLES
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height);
  color: var(--text-dark);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

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

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

ul, ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semi);
  line-height: 1.3;
  color: var(--text-dark);
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl);  }
h5 { font-size: var(--font-size-lg);  }
h6 { font-size: var(--font-size-md);  }

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

::selection {
  background: var(--color-primary-light);
  color: var(--text-dark);
}

/* Focus-visible for accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ============================================================
   3. APP LAYOUT SHELL
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   4. SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: var(--text-white);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sticky);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s ease;
}

/* Scrollbar inside sidebar */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

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

.sidebar::-webkit-scrollbar-thumb {
  background: var(--color-dark-tertiary);
  border-radius: var(--radius-full);
}

/* ---------- Sidebar Logo ---------- */
.sidebar-logo {
  padding: var(--space-6) var(--space-6) var(--space-5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--text-white);
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-logo-text .company-name {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semi);
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.sidebar-logo-text .company-tagline {
  font-size: var(--font-size-xs);
  color: var(--text-light);
  font-weight: var(--font-weight-normal);
  line-height: 1.3;
}

/* ---------- Sidebar Navigation ---------- */
.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
}

.sidebar-nav-section {
  margin-bottom: var(--space-5);
}

.sidebar-nav-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 var(--space-3) var(--space-2);
}

.sidebar-nav-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-light);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  transition: var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  border-left: 3px solid transparent;
  position: relative;
}

.sidebar-nav-item svg,
.sidebar-nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: var(--transition-base);
}

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

.sidebar-nav-item:hover svg,
.sidebar-nav-item:hover .nav-icon {
  opacity: 1;
}

.sidebar-nav-item.active {
  background-color: var(--bg-active);
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  font-weight: var(--font-weight-semi);
}

.sidebar-nav-item.active svg,
.sidebar-nav-item.active .nav-icon {
  opacity: 1;
  color: var(--color-primary);
}

.sidebar-nav-item .nav-badge {
  margin-left: auto;
  background-color: var(--color-primary);
  color: var(--text-white);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semi);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  line-height: 1.4;
}

/* ---------- Sidebar Bottom / Settings ---------- */
.sidebar-bottom {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.sidebar-bottom .sidebar-nav-item {
  color: var(--text-gray);
}

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

/* ---------- Sidebar User Info ---------- */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semi);
  font-size: var(--font-size-sm);
  color: var(--text-white);
  flex-shrink: 0;
}

.sidebar-user-info {
  overflow: hidden;
}

.sidebar-user-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: var(--font-size-xs);
  color: var(--text-gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   5. TOP HEADER
   ============================================================ */
.header {
  position: sticky;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  margin-left: var(--sidebar-width);
  z-index: var(--z-sticky);
  gap: var(--space-4);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* Hamburger toggle — hidden on desktop */
.header-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-dark);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.header-toggle:hover {
  background-color: var(--bg-input);
}

.header-toggle svg {
  width: 22px;
  height: 22px;
}

/* ---------- Header Search ---------- */
.header-search {
  position: relative;
  max-width: 400px;
  flex: 1;
}

.header-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-gray);
  pointer-events: none;
}

.header-search input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background-color: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-dark);
  transition: var(--transition-base);
}

.header-search input::placeholder {
  color: var(--text-gray);
}

.header-search input:focus {
  outline: none;
  background-color: var(--bg-card);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

/* ---------- Header Page Title ---------- */
.header-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semi);
  color: var(--text-dark);
  white-space: nowrap;
}

/* ---------- Notification Bell ---------- */
.header-notification {
  position: relative;
  background: none;
  border: none;
  color: var(--text-gray);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: var(--transition-base);
}

.header-notification:hover {
  background-color: var(--bg-input);
  color: var(--text-dark);
}

.header-notification svg {
  width: 20px;
  height: 20px;
}

.header-notification .notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background-color: var(--color-danger);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-header);
}

/* ============================================================
   6. MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  padding: var(--space-8);
  min-height: calc(100vh - var(--header-height));
  max-width: calc(var(--content-max-width) + var(--sidebar-width));
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.page-header h1,
.page-header h2 {
  margin: 0;
}

.page-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-gray);
  font-weight: var(--font-weight-normal);
  margin-top: var(--space-1);
}

/* ============================================================
   7. CARDS
   ============================================================ */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  transition: var(--transition-base);
  border: 1px solid var(--border-light);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

.card-header h3,
.card-header h4 {
  margin: 0;
  font-size: var(--font-size-lg);
}

.card-body {
  color: var(--text-secondary);
}

.card-footer {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Glassmorphism variant */
.card.glass {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.card.glass:hover {
  background: rgba(255, 255, 255, 0.8);
}

/* No-hover variant (static cards) */
.card.card-static:hover {
  box-shadow: var(--shadow-card);
  transform: none;
}

/* ============================================================
   8. STAT CARDS
   ============================================================ */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.stat-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: var(--transition-base);
  border: 1px solid var(--border-light);
}

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

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-icon svg {
  width: 24px;
  height: 24px;
}

.stat-card-icon.icon-green {
  background-color: var(--color-success-light);
  color: var(--color-success);
}

.stat-card-icon.icon-red {
  background-color: var(--color-danger-light);
  color: var(--color-danger);
}

.stat-card-icon.icon-amber {
  background-color: var(--color-warning-light);
  color: var(--color-warning);
}

.stat-card-icon.icon-blue {
  background-color: var(--color-info-light);
  color: var(--color-info);
}

.stat-card-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-card-label {
  font-size: var(--font-size-sm);
  color: var(--text-gray);
  font-weight: var(--font-weight-medium);
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-card-value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-dark);
  line-height: 1.1;
}

.stat-card-value.animate-count {
  animation: countUp 0.8s ease-out forwards;
}

.stat-card-change {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  margin-top: var(--space-2);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.stat-card-change.positive {
  color: var(--color-success);
}

.stat-card-change.negative {
  color: var(--color-danger);
}

/* ============================================================
   9. DATA TABLES
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  background-color: var(--bg-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-base);
}

.data-table thead th {
  background-color: var(--bg-input);
  padding: var(--space-4) var(--space-5);
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semi);
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.data-table thead th:first-child {
  border-top-left-radius: var(--radius-xl);
}

.data-table thead th:last-child {
  border-top-right-radius: var(--radius-xl);
}

.data-table tbody tr {
  transition: var(--transition-base);
  border-bottom: 1px solid var(--border-light);
}

.data-table tbody tr:nth-child(even) {
  background-color: rgba(245, 247, 250, 0.5);
}

.data-table tbody tr:hover {
  background-color: var(--color-primary-light);
}

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

.data-table tbody td {
  padding: var(--space-4) var(--space-5);
  color: var(--text-dark);
  vertical-align: middle;
}

.data-table .col-actions {
  text-align: right;
  white-space: nowrap;
}

.data-table .col-amount {
  font-weight: var(--font-weight-semi);
  font-variant-numeric: tabular-nums;
}

.data-table .col-date {
  color: var(--text-gray);
  white-space: nowrap;
}

.data-table .client-name {
  font-weight: var(--font-weight-medium);
  color: var(--text-dark);
}

.data-table .invoice-number {
  font-weight: var(--font-weight-semi);
  color: var(--color-primary);
}

/* Sortable column headers */
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  background-color: var(--border-color);
}

.data-table th.sortable::after {
  content: '⇅';
  margin-left: var(--space-2);
  opacity: 0.3;
  font-size: var(--font-size-xs);
}

.data-table th.sort-asc::after {
  content: '↑';
  opacity: 0.8;
}

.data-table th.sort-desc::after {
  content: '↓';
  opacity: 0.8;
}

/* ============================================================
   10. STATUS BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semi);
  line-height: 1.4;
  white-space: nowrap;
  text-transform: capitalize;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.badge-paid {
  background-color: var(--color-success-light);
  color: var(--color-success);
}

.badge-paid::before {
  background-color: var(--color-success);
}

.badge-pending {
  background-color: var(--color-warning-light);
  color: var(--color-warning);
}

.badge-pending::before {
  background-color: var(--color-warning);
}

.badge-overdue {
  background-color: var(--color-danger-light);
  color: var(--color-danger);
}

.badge-overdue::before {
  background-color: var(--color-danger);
}

.badge-draft {
  background-color: var(--color-draft-light);
  color: var(--color-draft);
}

.badge-draft::before {
  background-color: var(--color-draft);
}

/* ============================================================
   11. BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: 1.4;
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}

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

.btn:disabled,
.btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Primary */
.btn-primary {
  background-color: var(--color-primary);
  color: var(--text-white);
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.35);
}

.btn-primary:focus-visible {
  box-shadow: var(--shadow-focus);
}

/* Secondary (outlined) */
.btn-secondary {
  background-color: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

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

/* Danger */
.btn-danger {
  background-color: var(--color-danger);
  color: var(--text-white);
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background-color: #c0392b;
  border-color: #c0392b;
  box-shadow: 0 2px 8px rgba(231, 76, 60, 0.35);
}

/* Ghost */
.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background-color: var(--bg-input);
  color: var(--text-dark);
}

/* Size Variants */
.btn-sm {
  padding: 6px 14px;
  font-size: var(--font-size-sm);
  border-radius: var(--radius-sm);
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: var(--font-size-md);
  border-radius: var(--radius-lg);
}

.btn-lg svg {
  width: 20px;
  height: 20px;
}

/* Icon-only button */
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
}

.btn-icon.btn-lg {
  width: 48px;
  height: 48px;
}

/* Button group */
.btn-group {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* ============================================================
   12. FORMS
   ============================================================ */
.form-group {
  margin-bottom: var(--space-5);
}

.form-group label,
.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-dark);
  margin-bottom: var(--space-2);
}

.form-group label .required,
.form-label .required {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-dark);
  transition: var(--transition-base);
  line-height: 1.5;
}

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

.form-control:hover {
  border-color: var(--text-gray);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.form-control.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--color-danger);
  margin-top: var(--space-1);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-gray);
  margin-top: var(--space-1);
}

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

/* Select */
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Side-by-side fields */
.form-row {
  display: flex;
  gap: var(--space-4);
}

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

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.form-check label {
  font-size: var(--font-size-base);
  color: var(--text-dark);
  cursor: pointer;
  margin-bottom: 0;
}

/* ============================================================
   13. MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-4);
  animation: fadeIn 0.2s ease;
  opacity: 1;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background-color: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease;
  position: relative;
}

.modal.modal-lg {
  max-width: 780px;
}

.modal.modal-sm {
  max-width: 400px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
}

.modal-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-gray);
  cursor: pointer;
  transition: var(--transition-base);
  font-size: var(--font-size-lg);
}

.modal-close:hover {
  background-color: var(--bg-input);
  color: var(--text-dark);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

/* ============================================================
   14. LINE ITEMS (Invoice Editor)
   ============================================================ */
.line-items {
  width: 100%;
  margin-bottom: var(--space-5);
}

.line-items-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-input);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semi);
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.line-items-header .col-description {
  flex: 1;
}

.line-items-header .col-qty {
  width: 80px;
  text-align: center;
}

.line-items-header .col-price {
  width: 120px;
  text-align: right;
}

.line-items-header .col-total {
  width: 120px;
  text-align: right;
}

.line-items-header .col-action {
  width: 40px;
}

.line-item-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-base);
}

.line-item-row:hover {
  background-color: rgba(245, 247, 250, 0.5);
}

.line-item-row .col-description {
  flex: 1;
  min-width: 0;
}

.line-item-row .col-description input,
.line-item-row .col-description textarea {
  width: 100%;
}

.line-item-row .col-qty {
  width: 80px;
}

.line-item-row .col-qty input {
  width: 100%;
  text-align: center;
}

.line-item-row .col-price {
  width: 120px;
}

.line-item-row .col-price input {
  width: 100%;
  text-align: right;
}

.line-item-row .col-total {
  width: 120px;
  text-align: right;
  font-weight: var(--font-weight-semi);
  color: var(--text-dark);
  font-variant-numeric: tabular-nums;
}

.line-item-row .col-action {
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.line-item-delete {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-base);
}

.line-item-delete:hover {
  background-color: var(--color-danger-light);
  color: var(--color-danger);
}

.line-items-add {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: none;
  color: var(--color-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: var(--transition-base);
  width: 100%;
}

.line-items-add:hover {
  background-color: var(--color-primary-light);
}

.line-items-add svg {
  width: 16px;
  height: 16px;
}

/* Totals Summary */
.line-items-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  width: 260px;
  padding: var(--space-2) 0;
  font-size: var(--font-size-base);
}

.totals-row .totals-label {
  color: var(--text-gray);
}

.totals-row .totals-value {
  font-weight: var(--font-weight-medium);
  font-variant-numeric: tabular-nums;
}

.totals-row.totals-grand {
  border-top: 2px solid var(--text-dark);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}

.totals-row.totals-grand .totals-label {
  font-weight: var(--font-weight-semi);
  color: var(--text-dark);
}

.totals-row.totals-grand .totals-value {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--text-dark);
}

/* ============================================================
   15. INVOICE PREVIEW (Printable)
   ============================================================ */
.invoice-preview {
  background-color: var(--bg-card);
  padding: var(--space-12);
  max-width: 800px;
  margin: 0 auto;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  font-size: var(--font-size-base);
  color: var(--text-dark);
}

.invoice-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-10);
  padding-bottom: var(--space-8);
  border-bottom: 3px solid var(--color-primary);
}

.invoice-company {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.invoice-company-name {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.invoice-company-address {
  font-size: var(--font-size-sm);
  color: var(--text-gray);
  line-height: 1.6;
}

.invoice-title-block {
  text-align: right;
}

.invoice-title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-dark);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: var(--space-3);
}

.invoice-meta {
  font-size: var(--font-size-sm);
  color: var(--text-gray);
  line-height: 1.8;
}

.invoice-meta strong {
  color: var(--text-dark);
  font-weight: var(--font-weight-medium);
}

/* Bill-to */
.invoice-billing {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  margin-bottom: var(--space-10);
}

.invoice-billing-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semi);
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.invoice-billing-name {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semi);
  color: var(--text-dark);
  margin-bottom: var(--space-1);
}

.invoice-billing-address {
  font-size: var(--font-size-sm);
  color: var(--text-gray);
  line-height: 1.6;
}

/* Invoice line items table */
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-8);
}

.invoice-table thead th {
  background-color: var(--color-primary);
  color: var(--text-white);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semi);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.invoice-table thead th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
  text-align: right;
}

.invoice-table thead th.text-right {
  text-align: right;
}

.invoice-table thead th.text-center {
  text-align: center;
}

.invoice-table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  font-size: var(--font-size-base);
}

.invoice-table tbody td:last-child {
  text-align: right;
  font-weight: var(--font-weight-medium);
}

.invoice-table tbody td.text-right {
  text-align: right;
}

.invoice-table tbody td.text-center {
  text-align: center;
}

/* Invoice totals */
.invoice-totals {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-10);
}

.invoice-totals-table {
  width: 280px;
}

.invoice-totals-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  font-size: var(--font-size-base);
}

.invoice-totals-row .label {
  color: var(--text-gray);
}

.invoice-totals-row .value {
  font-weight: var(--font-weight-medium);
  font-variant-numeric: tabular-nums;
}

.invoice-totals-row.grand-total {
  border-top: 2px solid var(--text-dark);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
  font-size: var(--font-size-lg);
}

.invoice-totals-row.grand-total .label {
  font-weight: var(--font-weight-semi);
  color: var(--text-dark);
}

.invoice-totals-row.grand-total .value {
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
}

/* Invoice notes */
.invoice-notes {
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-light);
}

.invoice-notes-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semi);
  color: var(--text-dark);
  margin-bottom: var(--space-2);
}

.invoice-notes-text {
  font-size: var(--font-size-sm);
  color: var(--text-gray);
  line-height: 1.6;
}

.invoice-footer {
  text-align: center;
  padding-top: var(--space-8);
  margin-top: var(--space-8);
  border-top: 1px solid var(--border-light);
  font-size: var(--font-size-xs);
  color: var(--text-light);
}

/* ============================================================
   16. ANIMATIONS & KEYFRAMES
   ============================================================ */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

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

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

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

@keyframes progressBar {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}

/* Animation utility classes */
.animate-in {
  animation: fadeIn 0.4s ease forwards;
}

.animate-slide-in {
  animation: slideIn 0.3s ease forwards;
}

.animate-slide-right {
  animation: slideInRight 0.3s ease forwards;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Staggered entry for children */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }

/* ============================================================
   17. EMPTY STATES
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--text-gray);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-5);
  color: var(--text-light);
  opacity: 0.5;
}

.empty-state-icon svg {
  width: 100%;
  height: 100%;
}

.empty-state-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semi);
  color: var(--text-dark);
  margin-bottom: var(--space-2);
}

.empty-state-message {
  font-size: var(--font-size-base);
  color: var(--text-gray);
  max-width: 400px;
  margin-bottom: var(--space-6);
  line-height: 1.6;
}

.empty-state .btn {
  margin-top: var(--space-2);
}

/* ============================================================
   18. TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  min-width: 300px;
  max-width: 420px;
  pointer-events: auto;
  animation: slideInRight 0.35s ease forwards;
  position: relative;
  overflow: hidden;
}

.toast.dismiss {
  animation: slideOutRight 0.3s ease forwards;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition-base);
}

.toast-close:hover {
  opacity: 1;
}

/* Auto-dismiss progress bar */
.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.4);
  animation: progressBar 4s linear forwards;
}

/* Variants */
.toast-success {
  background-color: var(--color-success);
  color: var(--text-white);
}

.toast-error {
  background-color: var(--color-danger);
  color: var(--text-white);
}

.toast-info {
  background-color: var(--color-info);
  color: var(--text-white);
}

.toast-warning {
  background-color: var(--color-warning);
  color: #1a1a2e;
}

/* ============================================================
   19. FILTER BAR / SEARCH BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.filter-bar .filter-search {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.filter-bar .filter-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-gray);
  pointer-events: none;
}

.filter-bar .filter-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-dark);
  transition: var(--transition-base);
}

.filter-bar .filter-search input::placeholder {
  color: var(--text-light);
}

.filter-bar .filter-search input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.filter-bar .filter-select {
  min-width: 140px;
}

.filter-bar .filter-select select {
  width: 100%;
  padding: 10px 36px 10px 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-dark);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
  transition: var(--transition-base);
}

.filter-bar .filter-select select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.filter-bar .filter-date {
  min-width: 160px;
}

.filter-bar .filter-date input[type="date"] {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-dark);
  transition: var(--transition-base);
}

.filter-bar .filter-date input[type="date"]:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

/* Active filter chip */
.filter-chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 10px;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.filter-chip button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  background: none;
  color: var(--color-primary);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: var(--transition-base);
  font-size: var(--font-size-xs);
  padding: 0;
}

.filter-chip button:hover {
  background-color: var(--color-primary);
  color: var(--text-white);
}

/* ============================================================
   20. TABS
   ============================================================ */
.tabs {
  margin-bottom: var(--space-6);
}

.tab-list {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  gap: 0;
  overflow-x: auto;
}

.tab-item {
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-gray);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-family);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-base);
  white-space: nowrap;
  position: relative;
}

.tab-item:hover {
  color: var(--text-dark);
}

.tab-item.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: var(--font-weight-semi);
}

.tab-panel {
  display: none;
  padding-top: var(--space-5);
  animation: fadeIn 0.25s ease;
}

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

.tab-count {
  margin-left: var(--space-2);
  background-color: var(--bg-input);
  color: var(--text-gray);
  font-size: var(--font-size-xs);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: var(--font-weight-medium);
}

.tab-item.active .tab-count {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
}

/* ============================================================
   21. DROPDOWN
   ============================================================ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: var(--transition-base);
}

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  color: var(--text-dark);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-family);
  transition: var(--transition-base);
}

.dropdown-item:hover {
  background-color: var(--bg-input);
}

.dropdown-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-gray);
}

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

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

.dropdown-divider {
  height: 1px;
  background-color: var(--border-light);
  margin: var(--space-2) 0;
}

/* ============================================================
   22. TOOLTIPS
   ============================================================ */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-3);
  background-color: var(--color-dark);
  color: var(--text-white);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-base);
  pointer-events: none;
  z-index: var(--z-tooltip);
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ============================================================
   23. LOADING / SKELETON
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-input) 25%,
    var(--border-light) 50%,
    var(--bg-input) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
}

.skeleton-text.short {
  width: 60%;
}

.skeleton-heading {
  height: 24px;
  width: 40%;
  margin-bottom: var(--space-4);
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
}

.skeleton-card {
  height: 120px;
}

/* Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

/* ============================================================
   24. AVATARS
   ============================================================ */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semi);
  font-size: var(--font-size-base);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: var(--font-size-xs);
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: var(--font-size-xl);
}

/* ============================================================
   25. PROGRESS BAR
   ============================================================ */
.progress {
  width: 100%;
  height: 8px;
  background-color: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.progress-bar.danger {
  background-color: var(--color-danger);
}

.progress-bar.warning {
  background-color: var(--color-warning);
}

/* ============================================================
   26. UTILITY CLASSES
   ============================================================ */

/* Text alignment */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }

/* Margin top */
.mt-1 { margin-top: var(--space-2); }
.mt-2 { margin-top: var(--space-4); }
.mt-3 { margin-top: var(--space-6); }
.mt-4 { margin-top: var(--space-8); }

/* Margin bottom */
.mb-1 { margin-bottom: var(--space-2); }
.mb-2 { margin-bottom: var(--space-4); }
.mb-3 { margin-bottom: var(--space-6); }
.mb-4 { margin-bottom: var(--space-8); }

/* Flexbox */
.flex         { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; justify-content: center; align-items: center; }
.flex-end     { display: flex; justify-content: flex-end; align-items: center; }
.flex-col     { display: flex; flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.flex-1       { flex: 1; }

/* Gaps */
.gap-1 { gap: var(--space-2); }
.gap-2 { gap: var(--space-4); }
.gap-3 { gap: var(--space-6); }

/* Visibility */
.hidden       { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Truncation */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Font weight helpers */
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semi   { font-weight: var(--font-weight-semi); }
.font-bold   { font-weight: var(--font-weight-bold); }

/* Text color helpers */
.text-primary { color: var(--color-primary); }
.text-danger  { color: var(--color-danger); }
.text-gray    { color: var(--text-gray); }
.text-light   { color: var(--text-light); }
.text-dark    { color: var(--text-dark); }

/* Divider */
.divider {
  height: 1px;
  background-color: var(--border-light);
  margin: var(--space-6) 0;
}

/* ============================================================
   27. PRINT STYLES
   ============================================================ */
@media print {
  *,
  *::before,
  *::after {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
  }

  /* Hide everything except the invoice preview */
  .sidebar,
  .header,
  .header-toggle,
  .btn,
  .btn-group,
  .filter-bar,
  .tabs,
  .toast-container,
  .modal-overlay,
  .stat-cards,
  .page-header .btn,
  .line-items-add,
  .line-item-delete,
  .empty-state .btn,
  .sidebar-overlay {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  .invoice-preview {
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .invoice-preview-header {
    border-bottom-color: #000 !important;
  }

  .invoice-table thead th {
    background-color: #eee !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  a {
    text-decoration: none !important;
    color: #000 !important;
  }

  .card {
    border: 1px solid #ddd !important;
    page-break-inside: avoid;
  }

  .invoice-table {
    page-break-inside: auto;
  }

  .invoice-table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
}

/* ============================================================
   28. RESPONSIVE — TABLET & MOBILE
   ============================================================ */

/* Sidebar overlay backdrop (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-sticky) - 1);
}

@media (max-width: 1024px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  /* Sidebar becomes overlay */
  .sidebar {
    transform: translateX(-100%);
    z-index: var(--z-overlay);
  }

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

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

  /* Header */
  .header {
    margin-left: 0;
    left: 0;
    padding: 0 var(--space-4);
  }

  .header-toggle {
    display: flex;
  }

  /* Main content */
  .main-content {
    margin-left: 0;
    padding: var(--space-4);
  }

  /* Stat cards stack */
  .stat-cards {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

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

  .data-table {
    min-width: 600px;
  }

  /* Form rows stack */
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  /* Filter bar stacks */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .filter-search {
    min-width: unset;
  }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  /* Modal */
  .modal {
    max-width: 100%;
    margin: var(--space-4);
    max-height: calc(100vh - var(--space-8));
  }

  /* Invoice preview */
  .invoice-preview {
    padding: var(--space-6);
  }

  .invoice-preview-header {
    flex-direction: column;
    gap: var(--space-5);
  }

  .invoice-title-block {
    text-align: left;
  }

  .invoice-billing {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .invoice-title {
    font-size: var(--font-size-3xl);
  }

  /* Line items */
  .line-items-header {
    display: none;
  }

  .line-item-row {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-4);
  }

  .line-item-row .col-description {
    flex: 1 1 100%;
  }

  .line-item-row .col-qty,
  .line-item-row .col-price,
  .line-item-row .col-total {
    width: auto;
    flex: 1;
  }

  /* Toast */
  .toast-container {
    bottom: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
  }

  .toast {
    min-width: unset;
    max-width: unset;
    width: 100%;
  }

  /* Tabs scroll */
  .tab-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Buttons: full width on small screens */
  .btn-block-mobile {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .header-search {
    display: none;
  }

  .card {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
  }

  .stat-card {
    padding: var(--space-4);
  }

  .stat-card-value {
    font-size: var(--font-size-2xl);
  }

  .invoice-preview {
    padding: var(--space-4);
  }

  .invoice-table {
    font-size: var(--font-size-sm);
  }

  .invoice-table thead th,
  .invoice-table tbody td {
    padding: var(--space-2) var(--space-3);
  }
}

/* ============================================================
   29. SCROLLBAR CUSTOMIZATION (webkit)
   ============================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-light);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

/* ============================================================
   30. MISCELLANEOUS / CONTEXT-SPECIFIC
   ============================================================ */

/* Quick-action row (e.g., dashboard) */
.quick-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Currency input with symbol prefix */
.input-currency {
  position: relative;
}

.input-currency::before {
  content: '$';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-gray);
  font-weight: var(--font-weight-medium);
  pointer-events: none;
}

.input-currency input {
  padding-left: 28px;
}

/* Tag / label */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background-color: var(--bg-input);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

/* Separator */
.separator {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-6) 0;
  color: var(--text-light);
  font-size: var(--font-size-sm);
}

.separator::before,
.separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--border-light);
}

/* Floating action button */
.fab {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-8);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background-color: var(--color-primary);
  color: var(--text-white);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-base);
  z-index: var(--z-base);
}

.fab:hover {
  background-color: var(--color-primary-hover);
  transform: scale(1.08);
  box-shadow: var(--shadow-xl);
}

.fab svg {
  width: 24px;
  height: 24px;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-gray);
  margin-bottom: var(--space-4);
}

.breadcrumbs a {
  color: var(--text-gray);
  transition: var(--transition-base);
}

.breadcrumbs a:hover {
  color: var(--color-primary);
}

.breadcrumbs .separator {
  margin: 0;
  font-size: var(--font-size-xs);
}

.breadcrumbs .separator::before,
.breadcrumbs .separator::after {
  display: none;
}

.breadcrumbs .current {
  color: var(--text-dark);
  font-weight: var(--font-weight-medium);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background-color: var(--border-color);
  border-radius: var(--radius-full);
  transition: var(--transition-base);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--bg-card);
  border-radius: var(--radius-full);
  transition: var(--transition-base);
  box-shadow: var(--shadow-xs);
}

.toggle input:checked + .toggle-slider {
  background-color: var(--color-primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Notification dot */
.has-notification::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background-color: var(--color-danger);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-card);
}

/* ============================================================
   BRIDGE CLASSES — used by app.js
   ============================================================ */

/* --- Stats Grid (dashboard) --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.stats-grid .stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  padding: var(--space-6);
  transition: var(--transition-base);
}

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

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-gray);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-dark);
  line-height: 1.1;
}

/* --- Quick Actions --- */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.quick-actions .icon {
  margin-right: var(--space-2);
}

/* --- Table (JS uses .table, CSS has .data-table) --- */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-base);
}

.table thead th {
  background-color: var(--bg-input);
  padding: 12px 16px;
  text-align: left;
  font-weight: var(--font-weight-semi);
  font-size: var(--font-size-sm);
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table tbody tr {
  transition: var(--transition-fast);
  border-bottom: 1px solid var(--border-light);
}

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

.table tbody tr:hover {
  background-color: rgba(73, 143, 102, 0.04);
}

.table tbody td {
  padding: 14px 16px;
  color: var(--text-dark);
  vertical-align: middle;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* --- Badge aliases (JS uses badge-success/info/danger/secondary) --- */
.badge-success {
  background-color: var(--color-success-light);
  color: var(--color-success);
}

.badge-success::before {
  background-color: var(--color-success);
}

.badge-info {
  background-color: var(--color-info-light);
  color: var(--color-info);
}

.badge-info::before {
  background-color: var(--color-info);
}

.badge-danger {
  background-color: var(--color-danger-light);
  color: var(--color-danger);
}

.badge-danger::before {
  background-color: var(--color-danger);
}

.badge-secondary {
  background-color: var(--color-draft-light);
  color: var(--color-draft);
}

.badge-secondary::before {
  background-color: var(--color-draft);
}

/* --- Button success variant --- */
.btn-success {
  background-color: var(--color-success);
  color: var(--text-white);
  border: none;
}

.btn-success:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* --- Form card (invoice/estimate forms) --- */
.form-card {
  padding: var(--space-8);
}

.form-card h3 {
  margin-top: var(--space-6);
  margin-bottom: var(--space-4);
  font-size: var(--font-size-lg);
  color: var(--text-dark);
}

/* --- Line item rows (invoice builder) --- */
.line-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-light);
}

.line-item .li-desc {
  flex: 1;
  min-width: 200px;
}

.line-item .li-qty {
  width: 80px;
  text-align: center;
}

.line-item .li-price {
  width: 120px;
}

.line-item .li-total {
  width: 120px;
  font-weight: var(--font-weight-semi);
  color: var(--text-dark);
  text-align: right;
  padding: 0 var(--space-2);
}

.line-item .li-remove {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

/* --- Totals section --- */
.totals-section {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 2px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.total-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-10);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-dark);
}

/* --- Form actions --- */
.form-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-light);
}

/* --- Modal open state --- */
.modal-overlay.modal-open {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 540px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideIn 0.3s ease;
}

.modal-content h2 {
  margin-bottom: var(--space-6);
  font-size: var(--font-size-2xl);
}

/* Hide modal by default */
.modal-overlay {
  display: none;
}

/* --- Spacing utilities --- */
.mt-sm { margin-top: var(--space-3); }
.mt-md { margin-top: var(--space-6); }
.mt-lg { margin-top: var(--space-8); }
.mb-sm { margin-bottom: var(--space-3); }
.mb-md { margin-bottom: var(--space-6); }
.mb-lg { margin-bottom: var(--space-8); }

/* --- Text utilities --- */
.text-muted {
  color: var(--text-gray) !important;
}

/* --- Page title in header --- */
.page-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semi);
  color: var(--text-dark);
  margin: 0;
}

/* --- Mobile header --- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  z-index: var(--z-sticky);
}

.mobile-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dark);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
}

.mobile-title {
  font-weight: var(--font-weight-semi);
  font-size: var(--font-size-md);
  color: var(--text-dark);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 199;
}

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

/* --- Nav items (bridge .nav-item in HTML to sidebar styles) --- */
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-light);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  transition: var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  border-left: 3px solid transparent;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: var(--transition-base);
}

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

.nav-item:hover .nav-icon {
  opacity: 1;
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  font-weight: var(--font-weight-semi);
}

.nav-item.active .nav-icon {
  opacity: 1;
  color: var(--color-primary);
}

/* --- Sidebar bottom nav item text color --- */
.sidebar-bottom .nav-item {
  color: var(--text-gray);
}

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

/* --- Logo section helpers --- */
.logo-icon { flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; overflow: hidden; }
.logo-title { font-size: var(--font-size-base); font-weight: var(--font-weight-semi); color: var(--text-white); white-space: nowrap; }
.logo-subtitle { font-size: var(--font-size-xs); color: var(--text-light); }

/* --- Invoice preview bridge classes used by JS --- */
.invoice-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-8);
}

.invoice-company h2 {
  font-size: var(--font-size-2xl);
  color: var(--text-dark);
  margin-bottom: var(--space-2);
}

.invoice-company p {
  margin: 2px 0;
  color: var(--text-gray);
  font-size: var(--font-size-sm);
}

.invoice-meta {
  text-align: right;
}

.invoice-meta h1 {
  font-size: var(--font-size-4xl);
  color: var(--color-primary);
  margin-bottom: var(--space-4);
  letter-spacing: 2px;
}

.invoice-meta p {
  margin: 4px 0;
  font-size: var(--font-size-sm);
  color: var(--text-gray);
}

.bill-to {
  margin-bottom: var(--space-8);
  padding: var(--space-5);
  background: var(--bg-input);
  border-radius: var(--radius-lg);
}

.bill-to h4 {
  color: var(--text-gray);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-2);
}

.bill-to p {
  margin: 2px 0;
  color: var(--text-dark);
}

.invoice-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.invoice-totals .total-line {
  display: flex;
  justify-content: space-between;
  min-width: 250px;
  padding: var(--space-2) 0;
  font-size: var(--font-size-md);
}

.invoice-totals .total-line.grand-total {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-xl);
  border-top: 2px solid var(--text-dark);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}

.invoice-notes {
  margin-top: var(--space-8);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-color);
}

.invoice-notes h4 {
  font-size: var(--font-size-sm);
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.invoice-actions {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

/* --- Responsive overrides for mobile --- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }

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

  .mobile-header {
    display: flex;
  }

  .header {
    margin-left: 0;
    top: 56px;
  }

  .main-content {
    margin-left: 0;
    padding: var(--space-4);
    padding-top: calc(56px + var(--header-height) + var(--space-4));
  }

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

  .line-item {
    flex-wrap: wrap;
  }

  .line-item .li-desc {
    min-width: 100%;
  }

  .invoice-header-row {
    flex-direction: column;
    gap: var(--space-4);
  }

  .invoice-meta {
    text-align: left;
  }

  .form-row {
    flex-direction: column;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .quick-actions {
    flex-direction: column;
  }

  .quick-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .invoice-actions {
    flex-wrap: wrap;
  }
}

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

  .actions-cell {
    flex-direction: column;
    align-items: stretch;
  }
}

/* --- Loading spinner --- */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) 0;
  color: var(--text-gray);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: var(--space-4);
}

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

/* --- Settings page specifics --- */
.settings-section {
  margin-bottom: var(--space-8);
}

.settings-section h3 {
  margin-bottom: var(--space-4);
}

.logo-preview {
  max-width: 200px;
  max-height: 100px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-top: var(--space-2);
}

.danger-zone {
  margin-top: var(--space-8);
  padding: var(--space-6);
  border: 2px solid var(--color-danger-light);
  border-radius: var(--radius-lg);
  background: rgba(231, 76, 60, 0.03);
}

.danger-zone h3 {
  color: var(--color-danger);
  margin-bottom: var(--space-4);
}

/* ============================================================
   20. UX OVERHAUL — clickable rows, global search, notifications,
       client profile page, login screen
   ============================================================ */

/* ---------- Clickable table rows ---------- */
tr.row-link {
  cursor: pointer;
}

tr.row-link:hover td {
  background-color: var(--color-primary-light);
}

tr.row-link .actions-cell {
  white-space: nowrap;
}

/* ---------- Clickable stat cards ---------- */
.stat-clickable {
  cursor: pointer;
}

.stat-clickable:hover {
  border-color: var(--color-primary);
}

.stat-hint {
  font-size: var(--font-size-xs);
  color: var(--text-gray);
  margin-top: var(--space-2);
  opacity: 0;
  transition: var(--transition-base);
}

.stat-clickable:hover .stat-hint {
  opacity: 1;
  color: var(--color-primary);
}

/* ---------- Global search results dropdown ---------- */
.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: 420px;
  overflow-y: auto;
  z-index: 1200;
}

.search-results.open {
  display: block;
}

.search-group {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semi);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-gray);
  background: var(--bg-primary);
  position: sticky;
  top: 0;
}

.search-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border-light);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover {
  background-color: var(--color-primary-light);
}

.search-result-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.search-result-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.search-result-label {
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-sub {
  font-size: var(--font-size-xs);
  color: var(--text-gray);
  text-transform: capitalize;
}

.search-empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--text-gray);
  font-size: var(--font-size-sm);
}

/* ---------- Notification bell panel ---------- */
.notif-wrap {
  position: relative;
}

.notif-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1200;
}

.notif-panel.open {
  display: block;
}

.notif-panel-header {
  padding: var(--space-3) var(--space-4);
  font-weight: var(--font-weight-semi);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

.notif-item {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

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

.notif-msg {
  font-size: var(--font-size-sm);
  color: var(--text-dark);
}

.notif-time {
  font-size: var(--font-size-xs);
  color: var(--text-gray);
  margin-top: 2px;
}

.notif-empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

/* ---------- Client profile page ---------- */
.client-profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.contact-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--font-size-base);
}

.contact-row a {
  color: var(--color-primary);
  text-decoration: none;
}

.contact-row a:hover {
  text-decoration: underline;
}

.contact-icon {
  flex-shrink: 0;
}

.client-summary {
  display: flex;
  flex-direction: column;
  margin-top: var(--space-3);
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--font-size-base);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row span {
  color: var(--text-secondary);
}

.text-danger {
  color: var(--color-danger) !important;
}

/* ---------- Login screen ---------- */
.login-box {
  background: var(--bg-card);
  padding: 40px;
  border-radius: var(--radius-xl);
  width: 340px;
  max-width: calc(100vw - 40px);
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.login-box h2 {
  margin: 0 0 4px 0;
  color: var(--text-dark);
  font-size: var(--font-size-xl);
}

.login-subtitle {
  color: var(--text-gray);
  font-size: var(--font-size-sm);
  margin: 0 0 var(--space-5) 0;
}

.login-box input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-sizing: border-box;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  transition: var(--transition-base);
}

.login-box input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

.login-box button {
  width: 100%;
  padding: 12px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semi);
  transition: var(--transition-base);
}

.login-box button:hover {
  background: var(--color-primary-hover);
}

.login-box button:disabled {
  opacity: 0.7;
  cursor: default;
}

.login-error {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: var(--font-size-sm);
  margin-bottom: 12px;
  text-align: left;
}

/* ---------- Responsive tweaks for new components ---------- */
@media (max-width: 768px) {
  .client-profile-grid {
    grid-template-columns: 1fr;
  }

  .notif-panel {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    width: auto;
  }
}
