/* ═══════════════════════════════════════════════════════════════════════════
   WUS CRM v3 │ BUILD-WUS-CRM-V3-002 │ 2026-04-13
   Editorial workshop · warm paper · navy ink · amber selvedge
   Author: enuwOS V0.27 · Single source of truth for crm.useus.pro/admin
   Load order: MUST be last CSS file in <head>. Cache-bust on every change.
   ═══════════════════════════════════════════════════════════════════════════ */


/* ─── 01. TOKENS ─────────────────────────────────────────────────────────── */
:root {
  /* Warmth base */
  --bg:                #FAFAF9;
  --bg-secondary:      #F3F2EF;
  --surface:           #FFFFFF;
  --elevated:          #F7F6F3;
  --paper:             #FDFCFA;
  --overlay:           rgba(250, 250, 249, 0.92);

  /* Navy ink */
  --accent:            #0A2463;
  --accent-hover:      #0D2E7A;
  --accent-active:     #081C4E;
  --accent-dim:        rgba(10, 36, 99, 0.07);
  --accent-glow:       rgba(10, 36, 99, 0.15);
  --accent-ring:       rgba(10, 36, 99, 0.25);

  /* Amber selvedge — decorative only, never on body text */
  --pop:               #EA580C;
  --pop-text:          #C2410C;
  --pop-dim:           rgba(234, 88, 12, 0.08);
  --pop-glow:          rgba(234, 88, 12, 0.18);

  /* Semantic */
  --success:           #166534;
  --success-bg:        #F0FDF4;
  --success-border:    #86EFAC;
  --danger:            #991B1B;
  --danger-bg:         #FEF2F2;
  --danger-border:     #FCA5A5;
  --warning:           #92400E;
  --warning-bg:        #FFFBEB;
  --warning-border:    #FCD34D;
  --info:              #1E40AF;
  --info-bg:           #EFF6FF;
  --info-border:       #BFDBFE;

  /* Foreground */
  --fg:                #111827;
  --fg-secondary:      #374151;
  --fg-muted:          #6B7280;
  --fg-dim:            #9CA3AF;
  --fg-inverse:        #FAFAF9;

  /* Borders & dividers */
  --border:            #E5E7EB;
  --border-hi:         #D1D5DB;
  --divider:           rgba(17, 24, 39, 0.06);
  --divider-strong:    rgba(17, 24, 39, 0.10);

  /* Radii */
  --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;

  /* 3-layer shadows */
  --sh-xs:     0 1px 2px rgba(10,36,99,0.04);
  --sh-sm:     0 1px 2px rgba(10,36,99,0.03), 0 4px 12px rgba(10,36,99,0.06), 0 0 0 1px rgba(10,36,99,0.02);
  --sh-md:     0 2px 4px rgba(10,36,99,0.04), 0 8px 24px rgba(10,36,99,0.08), 0 0 0 1px rgba(10,36,99,0.03);
  --sh-lg:     0 4px 8px rgba(10,36,99,0.05), 0 16px 40px rgba(10,36,99,0.10), 0 0 0 1px rgba(10,36,99,0.03);
  --sh-xl:     0 8px 16px rgba(10,36,99,0.06), 0 24px 60px rgba(10,36,99,0.14), 0 0 0 1px rgba(10,36,99,0.04);
  --sh-hover:  0 6px 16px rgba(10,36,99,0.10), 0 24px 48px rgba(10,36,99,0.12), 0 0 0 1px rgba(10,36,99,0.04);
  --sh-inset:  inset 0 1px 0 rgba(255,255,255,0.12);
  --sh-focus:  0 0 0 3px var(--accent-ring);

  /* Motion */
  --ease-spring:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out:       cubic-bezier(0, 0, 0.2, 1);
  --ease-standard:  cubic-bezier(0.4, 0, 0.2, 1);
  --dur-instant:    80ms;
  --dur-fast:       120ms;
  --dur-base:       180ms;
  --dur-slow:       300ms;
  --dur-deliberate: 480ms;

  /* Spacing — 8px base */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px; --sp-20: 80px;

  /* Z-index scale */
  --z-base: 1; --z-dropdown: 1000; --z-sticky: 1030;
  --z-modal-backdrop: 1040; --z-modal: 1050; --z-popover: 1100;
  --z-toast: 1200; --z-tooltip: 1300;

  /* Selvedge — the 1-of-1 signature */
  --selvedge-w:           3px;
  --selvedge-color:       var(--pop);
  --selvedge-structural:  var(--accent);

  /* Type stack */
  --font-display:  'Manrope', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-body:     'DM Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-mono:     'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-instant: 0ms; --dur-fast: 0ms; --dur-base: 0ms;
    --dur-slow: 0ms; --dur-deliberate: 0ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ─── 02. RESET & BASE ───────────────────────────────────────────────────── */
body {
  background: #E8E5DB !important;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  font-feature-settings: 'cv11', 'ss01', 'ss02';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

::selection { background: var(--accent); color: var(--fg-inverse); }

/* Custom scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: var(--r-pill);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); }
* { scrollbar-width: thin; scrollbar-color: var(--border-hi) transparent; }


/* ─── 03. TYPOGRAPHY ─────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--fg);
  line-height: 1.2;
}

h1, .h1 { font-size: 28px; }
h2, .h2 { font-size: 22px; letter-spacing: -0.025em; }
h3, .h3 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
h4, .h4 { font-size: 16px; font-weight: 700; letter-spacing: -0.015em; }
h5, .h5 { font-size: 14px; font-weight: 600; letter-spacing: 0; }
h6, .h6 { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-muted); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible { outline: none; box-shadow: var(--sh-focus); border-radius: var(--r-xs); }

p { margin: 0 0 var(--sp-3); }
small, .small { font-size: 13px; color: var(--fg-secondary); }
.text-muted { color: var(--fg-muted) !important; }

code, kbd, pre, samp, .mono, .num {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum', 'cv01', 'cv02';
}


/* ─── 04. HEADER (#header) ──────────────────────────────────────────────── */
body #header {
  background: #FFFFFF !important; /* PERFEX_OVERRIDE */
  border-bottom: 1px solid var(--divider);
  box-shadow: 0 2px 10px rgba(0,0,0,0.05), 0 1px 0 rgba(0,0,0,0.03) !important;
  display: flex !important;
  align-items: center !important;
  height: 64px !important;
  padding: 0 var(--sp-4) !important;
}

/* Hamburger */
body #header button.hide-menu {
  color: var(--pop);
  margin: 0 var(--sp-2) 0 0 !important;
  padding: var(--sp-2) !important;
  float: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 38px !important;
  width: 38px !important;
  border-radius: var(--r-sm) !important;
}
body #header button.hide-menu svg {
  width: 18px !important;
  height: 18px !important;
  margin: 0 !important;
}
body #header button.hide-menu:hover {
  background: var(--accent-dim) !important; /* PERFEX_OVERRIDE */
  color: var(--accent) !important; /* PERFEX_OVERRIDE */
}

/* Nav layout helper */
body #header nav {
  flex: 1 !important;
  height: 100% !important;
  display: block !important;
  float: none !important;
  margin: 0 !important;
}
body #header nav > div {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  height: 100% !important;
  width: 100% !important;
}

/* Brand/Logo */
body #header #logo {
  height: auto !important;
  display: inline-flex !important;
  align-items: center !important;
  margin: 0 !important;
  padding: 0 !important;
}
body #header #logo a.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent) !important; /* PERFEX_OVERRIDE */
  text-decoration: none;
  display: inline-flex !important;
  align-items: center !important;
  line-height: 1 !important;
}
/* Logo word colors */
.logo.logo-text .logo-word-use { color: #0A2463; }
.logo.logo-text .logo-word-us  { color: #EA580C; }
.logo.logo-text .logo-word-pro { color: #0A2463; }

body #header #logo a.logo img {
  max-height: 34px;
  width: auto;
  display: block;
}

/* Search and quick actions container */
body #header nav > div > div.tw-flex.tw-flex-1 {
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-3) !important;
  flex: 1 !important;
}

/* Search input — override Tailwind !important classes */
body #header #top_search {
  margin: 0 !important;
  padding: 0 !important;
  float: none !important;
  display: inline-flex !important;
  align-items: center !important;
  position: relative !important;
  flex: 1 !important;
  max-width: 350px !important;
}
body #header #search_input {
  background: var(--bg-secondary) !important; /* PERFEX_OVERRIDE */
  border: 1px solid transparent !important; /* PERFEX_OVERRIDE */
  border-radius: var(--r-pill) !important; /* PERFEX_OVERRIDE */
  color: var(--fg) !important; /* PERFEX_OVERRIDE */
  font-family: var(--font-body) !important; /* PERFEX_OVERRIDE */
  font-size: 14px !important; /* PERFEX_OVERRIDE */
  height: 38px !important; /* PERFEX_OVERRIDE */
  margin: 0 !important;
  padding: 0 16px 0 36px !important; /* padding-left space for icon */
  box-shadow: none !important; /* PERFEX_OVERRIDE */
  width: 100% !important;
  transition: border-color var(--dur-base) var(--ease-spring), background var(--dur-base) var(--ease-spring);
}
body #header #search_input:focus {
  background: var(--surface) !important; /* PERFEX_OVERRIDE */
  border-color: var(--accent) !important; /* PERFEX_OVERRIDE */
  box-shadow: 0 0 0 3px var(--accent-ring) !important; /* PERFEX_OVERRIDE */
}
body #header #search_input::placeholder {
  color: var(--fg-muted) !important; /* PERFEX_OVERRIDE */
}
/* Search icon placement */
body #header #top_search_button {
  position: absolute !important;
  left: 4px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  margin: 0 !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
}
body #header #top_search_button button {
  color: var(--fg-muted);
  background: transparent !important;
  border: none !important;
  padding: var(--sp-2) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
body #header #top_search_button button:hover {
  color: var(--accent);
}

/* Quick-create "+" circle */
body #header nav ul.nav.navbar-nav:not(.navbar-right) {
  display: inline-flex !important;
  align-items: center !important;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none;
  float: none !important;
}
body #header nav ul.nav.navbar-nav:not(.navbar-right) > li {
  display: inline-flex !important;
  align-items: center !important;
  margin: 0 !important;
}
body #header nav ul.nav.navbar-nav:not(.navbar-right) > li > a {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  margin: 0 !important;
  height: 38px !important;
  width: 38px !important;
}
body #header span.tw-bg-primary-600 {
  background-color: var(--accent) !important; /* PERFEX_OVERRIDE */
  width: 30px !important;
  height: 30px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  margin: 0 !important;
}
body #header span.tw-bg-primary-600:hover,
body #header a:hover span.tw-bg-primary-600,
body #header span.group-hover\:tw-bg-primary-700 {
  background-color: var(--accent-hover) !important; /* PERFEX_OVERRIDE */
}

/* Settings link */
body #header .navbar-right > li > a[href*="settings"] {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.01em;
  padding: 0 var(--sp-3);
  height: 38px;
  line-height: 38px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
body #header .navbar-right > li > a[href*="settings"]:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

/* Header icons hidden — moved to Command Center */
body #header .nav.navbar-nav.navbar-right li.icon.header-newsfeed,
body #header .nav.navbar-nav.navbar-right li.icon.header-todo,
body #header .nav.navbar-nav.navbar-right li.header-timers.timer-button,
body #header .nav.navbar-nav.navbar-right li:has(a[href*="settings"]) {
  display: none !important; /* PERFEX_OVERRIDE */
}

/* Right nav icon buttons (newsfeed, todo, timers, notifications) */
body #header .navbar-right {
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none;
  float: none !important;
}
body #header .navbar-right > li {
  display: inline-flex !important;
  align-items: center !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 100% !important;
  position: relative !important;
}
body #header .navbar-right li.icon > a {
  color: var(--pop) !important;
  border-radius: var(--r-md) !important;
  padding: 0 var(--sp-3) !important;
  margin: 0 !important;
  height: 38px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
body #header .navbar-right li.icon > a:hover {
  color: var(--accent) !important;
  background: var(--accent-dim) !important;
}
/* Icon size */
body #header .navbar-right li.icon svg {
  color: var(--pop);
  width: 18px !important;
  height: 18px !important;
}
body #header .navbar-right li.icon a:hover svg {
  color: var(--accent);
}
body #header .navbar-right li.icon .fa-regular,
body #header .navbar-right li.icon .fa-solid {
  color: var(--pop);
  font-size: 16px;
}
body #header .navbar-right li.icon a:hover .fa-regular,
body #header .navbar-right li.icon a:hover .fa-solid {
  color: var(--accent);
}

/* Notification / todo count badges */
body #header .navbar-right .bg-warning,
body #header .navbar-right .bg-success {
  background-color: var(--pop) !important; /* PERFEX_OVERRIDE */
  color: #fff !important; /* PERFEX_OVERRIDE */
  font-size: 10px !important;
  font-weight: 600 !important;
  height: 18px !important;
  min-width: 18px !important;
  padding: 0 4px !important;
  border-radius: var(--r-pill) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: absolute !important;
  top: -4px !important;
  right: -2px !important;
  line-height: 1 !important;
  border: 2px solid #FFFFFF !important;
}

/* User avatar dropdown (right-most) */
body #header .navbar-right li.header-user > a,
body #header .navbar-right li:last-child > a {
  padding: 0 var(--sp-2) !important;
  display: inline-flex !important;
  align-items: center !important;
  height: 38px !important;
}
body #header .navbar-right li.header-user img.staff-profile-image-small {
  margin: 0 !important;
  width: 28px !important;
  height: 28px !important;
}


/* ─── 05. SIDEBAR (#setup-menu) ─────────────────────────────────────────── */
body aside#menu,
body .sidebar {
  background: #FFFFFF !important; /* PERFEX_OVERRIDE */
}
body #setup-menu {
  background: #FFFFFF;
  border-right: none;
  box-shadow: var(--sh-sm);
  width: 248px;
  padding: 0;
}

/* Profile card at top of sidebar */
body #setup-menu .menu-profile,
body #setup-menu > .panel-default:first-child,
body #setup-menu > div:first-child {
  background: var(--elevated);
  margin: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: none;
  box-shadow: var(--sh-xs);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
body #setup-menu .menu-profile img,
body #setup-menu .menu-profile .img-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--surface);
  box-shadow: var(--sh-xs);
}
body #setup-menu .menu-profile .name,
body #setup-menu .menu-profile strong {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--fg);
  letter-spacing: -0.01em;
  display: block;
  line-height: 1.3;
}
body #setup-menu .menu-profile .email,
body #setup-menu .menu-profile small {
  font-size: 11px;
  color: var(--fg-muted);
  display: block;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

/* Nav items */
body #setup-menu ul,
body #setup-menu .nav {
  list-style: none;
  padding: var(--sp-2) var(--sp-3);
  margin: 0;
}
body #setup-menu li { margin: 1px 0; }

body #setup-menu li > a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 38px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-secondary);
  text-decoration: none;
  position: relative;
  transition: all var(--dur-fast) var(--ease-out);
}
body #setup-menu li > a:hover {
  background: var(--bg-secondary);
  color: var(--fg);
}
body #setup-menu li > a > i {
  width: 18px;
  height: 18px;
  font-size: 16px;
  text-align: center;
  color: var(--fg-muted);
  flex-shrink: 0;
  transition: color var(--dur-fast) var(--ease-out);
}
body #setup-menu li > a:hover > i { color: var(--fg-secondary); }

/* Active nav item — selvedge signature */
body #setup-menu li.active > a,
body #setup-menu li.menu-active > a {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(10,36,99,0.04), 0 4px 12px rgba(10,36,99,0.08);
}
body #setup-menu li.active > a > i,
body #setup-menu li.menu-active > a > i { color: var(--accent); }

body #setup-menu li.active > a::before,
body #setup-menu li.menu-active > a::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: var(--selvedge-w);
  height: 24px;
  background: var(--selvedge-color);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px var(--pop-glow);
}

/* Dropdown indicator (caret) */
body #setup-menu li > a > .caret,
body #setup-menu li > a > .menu-icon-arrow {
  margin-left: auto;
  border-color: var(--fg-dim) transparent transparent transparent;
  transition: transform var(--dur-base) var(--ease-spring);
}
body #setup-menu li.open > a > .caret { transform: rotate(180deg); }

/* Sub-menu */
body #setup-menu .sub-menu,
body #setup-menu li > ul {
  background: transparent;
  padding: var(--sp-1) 0 var(--sp-2) var(--sp-8);
  margin: 0;
  list-style: none;
  border-left: 1px solid var(--divider);
  margin-left: var(--sp-6);
}
body #setup-menu .sub-menu li > a {
  height: 32px;
  font-size: 13px;
  color: var(--fg-muted);
  padding-left: var(--sp-3);
}
body #setup-menu .sub-menu li > a::before { display: none; }
body #setup-menu .sub-menu li.active > a { color: var(--accent); font-weight: 600; background: transparent; box-shadow: none; }

/* Section dividers between nav groups */
body #setup-menu .nav > li.divider,
body #setup-menu .menu-divider {
  height: 1px;
  background: var(--divider);
  margin: var(--sp-3) var(--sp-2);
  padding: 0;
}

/* Sidebar collapse toggle */
body #setup-menu .menu-toggle {
  color: var(--fg-muted);
  transition: color var(--dur-fast) var(--ease-out);
}
body #setup-menu .menu-toggle:hover { color: var(--accent); }


/* ─── 06. PANELS / CARDS ─────────────────────────────────────────────────── */
body .panel,
body .panel-default,
body .widget,
body .x_panel {
  background: var(--surface);
  border: none;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  margin-bottom: var(--sp-6);
  /* overflow: visible — never hidden, clips dropdown menus inside panels */
  transition: box-shadow var(--dur-base) var(--ease-spring);
}

body .panel:hover,
body .x_panel:hover { box-shadow: var(--sh-md); }

body .panel-heading,
body .x_title {
  background: var(--elevated);
  border-bottom: 1px solid var(--divider);
  padding: var(--sp-4) var(--sp-6);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-transform: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
body .panel-heading > h4,
body .panel-heading > .panel-title,
body .x_title > h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

body .panel-body { padding: var(--sp-6); }

/* Wells & insets */
body .well {
  background: var(--bg-secondary);
  border: none;
  border-radius: var(--r-md);
  box-shadow: none;
  padding: var(--sp-4) var(--sp-5);
}

/* Stat cards (dashboard top row) — amber selvedge */
body .top_stats_wrapper .panel,
body .dashboard-stats .panel,
body .stat-card,
body .info-box {
  position: relative;
  padding: var(--sp-5) var(--sp-6);
  background: var(--surface);
  box-shadow: var(--sh-sm);
}
body .top_stats_wrapper .panel::before,
body .dashboard-stats .panel::before,
body .stat-card::before,
body .info-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--selvedge-w);
  background: var(--selvedge-color);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
body .top_stats_wrapper .panel .stat-number,
body .top_stats_wrapper .panel h3,
body .stat-card .number,
body .info-box .number {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: var(--sp-2) 0;
}
body .top_stats_wrapper .panel .stat-label,
body .stat-card .label-text {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}


/* ─── 07. TABLES & DATATABLES ───────────────────────────────────────────── */
body .table,
body table.dataTable {
  background: var(--surface);
  margin-bottom: 0;
  border: none;
  border-collapse: separate;
  border-spacing: 0;
}

body .table > thead > tr > th,
body table.dataTable > thead > tr > th,
body table.dataTable > thead > tr > td {
  background: var(--elevated);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--divider-strong);
  border-top: none;
  vertical-align: middle;
  white-space: nowrap;
}
body .table > thead > tr > th:first-child { border-top-left-radius: var(--r-md); }
body .table > thead > tr > th:last-child { border-top-right-radius: var(--r-md); }

body .table > tbody > tr > td,
body table.dataTable > tbody > tr > td {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--divider);
  font-size: 14px;
  color: var(--fg);
  vertical-align: middle;
  min-height: 48px;
  transition: background var(--dur-fast) var(--ease-out);
}

body .table > tbody > tr:hover > td,
body table.dataTable > tbody > tr:hover > td {
  background: var(--bg-secondary);
}

/* Numeric / monetary cells */
body .table td.num,
body .table td.amount,
body .table td.price,
body .table td[data-num],
body table.dataTable td.text-right,
body table.dataTable td.dt-right {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  text-align: right;
  letter-spacing: -0.01em;
}

/* Striped */
body .table-striped > tbody > tr:nth-child(odd) > td {
  background: var(--paper);
}
body .table-striped > tbody > tr:hover > td {
  background: var(--bg-secondary);
}

/* DataTables wrapper */
body .dataTables_wrapper {
  padding: 0;
}
body .dataTables_wrapper .dataTables_filter {
  margin-bottom: var(--sp-4);
}
body .dataTables_wrapper .dataTables_filter input,
body .dataTables_wrapper .dataTables_filter input[type="search"] {
  height: 38px;
  padding: 0 var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--fg);
  margin-left: var(--sp-3);
  width: 240px;
  transition: all var(--dur-base) var(--ease-spring);
}
body .dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--accent);
  box-shadow: var(--sh-focus);
  outline: none;
}

body .dataTables_wrapper .dataTables_length select {
  height: 38px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-hi);
  padding: 0 var(--sp-3);
  font-family: var(--font-body);
}

body .dataTables_wrapper .dataTables_paginate {
  margin-top: var(--sp-4);
}
body .dataTables_wrapper .dataTables_paginate .paginate_button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--sp-3);
  margin: 0 2px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
body .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--bg-secondary) !important;
  color: var(--fg) !important;
  border-color: transparent !important;
}
body .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--accent) !important;
  color: var(--fg-inverse) !important;
  border-color: var(--accent) !important;
  box-shadow: var(--sh-inset), var(--sh-xs);
}
body .dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

body .dataTables_wrapper .dataTables_info {
  font-size: 13px;
  color: var(--fg-muted);
  padding-top: var(--sp-4);
}

/* DataTables sort indicator */
body table.dataTable thead .sorting,
body table.dataTable thead .sorting_asc,
body table.dataTable thead .sorting_desc {
  cursor: pointer;
  position: relative;
  padding-right: var(--sp-8) !important;
  background-image: none !important;
}
body table.dataTable thead .sorting::after,
body table.dataTable thead .sorting_asc::after,
body table.dataTable thead .sorting_desc::after {
  content: '';
  position: absolute;
  right: var(--sp-4);
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 4 18 9'/><polyline points='6 15 12 20 18 15'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.5;
}
body table.dataTable thead .sorting_asc::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230A2463' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 15 12 9 18 15'/></svg>");
  opacity: 1;
}
body table.dataTable thead .sorting_desc::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230A2463' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  opacity: 1;
}


/* ─── 08. BUTTONS ────────────────────────────────────────────────────────── */
body .btn,
body button.btn,
body a.btn,
body input[type="submit"].btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 38px;
  padding: 0 var(--sp-5);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--dur-base) var(--ease-spring);
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  line-height: 1;
}
body .btn:focus-visible { outline: none; box-shadow: var(--sh-focus); }
body .btn:active { transform: translateY(1px); }

/* Primary */
body .btn-primary,
body .btn-info {
  background: var(--accent);
  color: var(--fg-inverse);
  border-color: var(--accent);
  box-shadow: var(--sh-inset), 0 1px 3px rgba(10,36,99,0.30), 0 4px 12px rgba(10,36,99,0.15);
}
body .btn-primary:hover,
body .btn-info:hover,
body .btn-primary:focus,
body .btn-info:focus {
  background: var(--accent-hover);
  color: var(--fg-inverse);
  border-color: var(--accent-hover);
  box-shadow: var(--sh-inset), 0 2px 6px rgba(10,36,99,0.35), 0 8px 20px rgba(10,36,99,0.20);
}
body .btn-primary:active,
body .btn-info:active {
  background: var(--accent-active);
  box-shadow: var(--sh-inset), 0 1px 2px rgba(10,36,99,0.30);
}

/* Default / secondary */
body .btn-default,
body .btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--border-hi);
  box-shadow: var(--sh-xs);
}
body .btn-default:hover,
body .btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--border);
  color: var(--fg);
}

/* Danger */
body .btn-danger {
  background: var(--danger);
  color: var(--fg-inverse);
  border-color: var(--danger);
  box-shadow: var(--sh-inset), 0 1px 3px rgba(153,27,27,0.30), 0 4px 12px rgba(153,27,27,0.15);
}
body .btn-danger:hover {
  background: #7F1D1D;
  border-color: #7F1D1D;
  color: var(--fg-inverse);
}

/* Success */
body .btn-success {
  background: var(--success);
  color: var(--fg-inverse);
  border-color: var(--success);
  box-shadow: var(--sh-inset), 0 1px 3px rgba(22,101,52,0.30), 0 4px 12px rgba(22,101,52,0.15);
}
body .btn-success:hover {
  background: #14532D;
  border-color: #14532D;
  color: var(--fg-inverse);
}

/* Warning (use as accent CTA on creative actions) */
body .btn-warning {
  background: var(--pop);
  color: var(--fg-inverse);
  border-color: var(--pop);
  box-shadow: var(--sh-inset), 0 1px 3px rgba(234,88,12,0.35), 0 4px 12px rgba(234,88,12,0.20);
}
body .btn-warning:hover {
  background: var(--pop-text);
  border-color: var(--pop-text);
  color: var(--fg-inverse);
}

/* Sizes */
body .btn-sm,
body .btn-xs {
  height: 32px;
  padding: 0 var(--sp-4);
  font-size: 13px;
  border-radius: var(--r-sm);
}
body .btn-xs { height: 28px; padding: 0 var(--sp-3); font-size: 12px; }
body .btn-lg {
  height: 46px;
  padding: 0 var(--sp-6);
  font-size: 15px;
  font-weight: 600;
}

/* Block */
body .btn-block { width: 100%; display: flex; }

/* Icon-only round buttons */
body .btn.btn-icon,
body .btn-circle {
  width: 38px; height: 38px; padding: 0; border-radius: var(--r-pill);
}

/* Disabled */
body .btn[disabled],
body .btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}


/* ─── 09. FORMS ─────────────────────────────────────────────────────────── */
body .form-group { margin-bottom: var(--sp-5); }

body .control-label,
body label,
body .form-group > label {
  display: block;
  margin-bottom: var(--sp-2);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

body .form-control,
body input[type="text"].form-control,
body input[type="email"].form-control,
body input[type="password"].form-control,
body input[type="number"].form-control,
body input[type="tel"].form-control,
body input[type="url"].form-control,
body input[type="search"].form-control,
body textarea.form-control,
body select.form-control {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--fg);
  line-height: 1.5;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  box-shadow: var(--sh-xs);
}

body textarea.form-control {
  height: auto;
  min-height: 96px;
  padding: var(--sp-3) var(--sp-4);
  resize: vertical;
  line-height: 1.6;
}

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

body .form-control::placeholder { color: var(--fg-dim); }

body .form-control[disabled],
body .form-control[readonly] {
  background: var(--bg-secondary);
  color: var(--fg-dim);
  cursor: not-allowed;
}

/* Help text */
body .help-block,
body .form-text {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: var(--sp-2);
  line-height: 1.5;
}

/* Validation states */
body .has-error .form-control {
  border-color: var(--danger);
  background: var(--danger-bg);
}
body .has-error .form-control:focus {
  box-shadow: 0 0 0 3px rgba(153,27,27,0.20);
}
body .has-error .control-label,
body .has-error .help-block { color: var(--danger); }

body .has-success .form-control { border-color: var(--success); }
body .has-success .control-label { color: var(--success); }

/* Input groups */
body .input-group-addon {
  background: var(--bg-secondary);
  border: 1px solid var(--border-hi);
  color: var(--fg-secondary);
  font-size: 13px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
}
body .input-group .form-control:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
body .input-group .form-control:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* Checkboxes & radios */
body .checkbox label,
body .radio label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
  cursor: pointer;
  padding-left: 0;
}
body input[type="checkbox"],
body input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}


/* ─── 10. BOOTSTRAP-SELECT ──────────────────────────────────────────────── */
body .bootstrap-select > .dropdown-toggle.btn,
body .bootstrap-select .btn.dropdown-toggle {
  height: 40px;
  padding: 0 var(--sp-9, 36px) 0 var(--sp-4);
  background: var(--surface) !important;
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  display: flex;
  align-items: center;
  box-shadow: var(--sh-xs);
}
body .bootstrap-select > .dropdown-toggle.btn:focus,
body .bootstrap-select.open > .dropdown-toggle.btn {
  border-color: var(--accent);
  box-shadow: var(--sh-focus);
  outline: none !important;
}
body .bootstrap-select > .dropdown-toggle .caret {
  border-top-color: var(--fg-muted);
  right: var(--sp-4);
}
body .bootstrap-select .dropdown-menu {
  background: var(--surface);
  border: none;
  border-radius: var(--r-md);
  box-shadow: var(--sh-xl);
  padding: var(--sp-2);
  margin-top: var(--sp-1);
  min-width: 100%;
}
body .bootstrap-select .dropdown-menu li > a {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--fg);
  transition: background var(--dur-fast) var(--ease-out);
}
body .bootstrap-select .dropdown-menu li > a:hover,
body .bootstrap-select .dropdown-menu li > a:focus {
  background: var(--accent-dim);
  color: var(--accent);
}
body .bootstrap-select .dropdown-menu li.selected > a {
  background: var(--accent);
  color: var(--fg-inverse);
}
body .bootstrap-select .bs-searchbox input {
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-hi);
}

/* Override height for simple-bootstrap-select used in title-bar badges (e.g. currency/year dropdowns) */
body .simple-bootstrap-select .bootstrap-select > .dropdown-toggle.btn,
body .simple-bootstrap-select .bootstrap-select .btn.dropdown-toggle {
  height: 24px !important;
  padding: 0 var(--sp-6, 24px) 0 var(--sp-2) !important;
  font-size: 12px !important;
  border-radius: var(--r-sm) !important;
  box-shadow: none !important;
}
body .simple-bootstrap-select .bootstrap-select > .dropdown-toggle .caret {
  top: 50% !important;
  transform: translateY(-50%) !important;
  right: var(--sp-2) !important;
}


/* ─── 11. SELECT2 v1 (Perfex locked to 3.5.x) ──────────────────────────── */
body .select2-container .select2-choice {
  height: 40px;
  padding: 0 var(--sp-4);
  background: var(--surface);
  background-image: none;
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  display: flex;
  align-items: center;
  box-shadow: var(--sh-xs);
}
body .select2-container.select2-container-active .select2-choice,
body .select2-container.select2-dropdown-open .select2-choice {
  border-color: var(--accent);
  box-shadow: var(--sh-focus);
}
body .select2-container .select2-choice .select2-arrow {
  background: transparent;
  border: none;
  width: 24px;
}
body .select2-container .select2-choice .select2-arrow b {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-position: center;
  background-repeat: no-repeat;
}

body .select2-drop {
  background: var(--surface);
  border: none;
  border-radius: var(--r-md);
  box-shadow: var(--sh-xl);
  padding: var(--sp-2);
  margin-top: var(--sp-1);
}
body .select2-drop .select2-search input {
  height: 36px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
}
body .select2-results .select2-result-label {
  padding: var(--sp-2) var(--sp-3);
  font-size: 14px;
  border-radius: var(--r-sm);
}
body .select2-results .select2-highlighted {
  background: var(--accent-dim);
  color: var(--accent);
}
body .select2-results .select2-highlighted .select2-result-label { color: var(--accent); }

/* Multi-select */
body .select2-container-multi .select2-choices {
  min-height: 40px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-xs);
}
body .select2-container-multi.select2-container-active .select2-choices {
  border-color: var(--accent);
  box-shadow: var(--sh-focus);
}
body .select2-container-multi .select2-choices .select2-search-choice {
  background: var(--accent-dim);
  color: var(--accent);
  border: none;
  border-radius: var(--r-pill);
  padding: 4px 10px 4px 22px;
  font-size: 13px;
  font-weight: 500;
  margin: 2px;
  box-shadow: none;
}
body .select2-container-multi .select2-choices .select2-search-choice-close {
  left: 6px;
  top: 6px;
  background: none;
  color: var(--accent);
}
body .select2-container-multi .select2-choices .select2-search-choice-close::before {
  content: '×';
  font-size: 14px;
  font-weight: 700;
  position: absolute;
  left: 0;
  top: -2px;
}


/* ─── 12. LABELS / BADGES (status pills with dot) ───────────────────────── */
body .label,
body .badge,
body .label-default,
body .label-success,
body .label-danger,
body .label-warning,
body .label-info,
body .label-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 10px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.4;
  vertical-align: middle;
}
body .label::before,
body .badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

body .label-default,
body .badge {
  background: var(--bg-secondary);
  color: var(--fg-secondary);
  border-color: var(--divider);
}
body .label-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}
body .label-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
body .label-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}
body .label-info,
body .label-primary {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
}


/* ─── 13. MODALS ────────────────────────────────────────────────────────── */
body .modal-backdrop {
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
body .modal-backdrop.in { opacity: 1; }

body .modal-dialog {
  margin: var(--sp-12) auto;
}

body .modal-content {
  background: var(--surface);
  border: none;
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  overflow: hidden;
}

body .modal.in .modal-dialog {
  animation: modal-enter var(--dur-deliberate) var(--ease-spring) forwards;
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

body .modal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
body .modal-header .modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin: 0;
}
body .modal-header .close {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--fg-muted);
  opacity: 1;
  transition: all var(--dur-fast) var(--ease-out);
  margin: 0;
  padding: 0;
}
body .modal-header .close:hover {
  background: var(--bg-secondary);
  color: var(--fg);
}

body .modal-body { padding: var(--sp-6); }

body .modal-footer {
  background: var(--surface);
  border-top: 1px solid var(--divider);
  padding: var(--sp-4) var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
}
body .modal-footer .btn { margin: 0; }


/* ─── 14. ALERTS ────────────────────────────────────────────────────────── */
body .alert {
  position: relative;
  padding: var(--sp-4) var(--sp-5) var(--sp-4) var(--sp-6);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  border-left-width: 4px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}
body .alert > strong:first-child,
body .alert > h4 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  margin: 0 0 var(--sp-1);
  display: block;
}

body .alert-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  border-left-color: var(--success);
  color: var(--success);
}
body .alert-danger,
body .alert-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  border-left-color: var(--danger);
  color: var(--danger);
}
body .alert-warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  border-left-color: var(--warning);
  color: var(--warning);
}
body .alert-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  border-left-color: var(--info);
  color: var(--info);
}
body .alert .close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.6;
  font-size: 18px;
  line-height: 1;
  padding: 0 var(--sp-2);
  cursor: pointer;
}
body .alert .close:hover { opacity: 1; }


/* ─── 15. TABS ──────────────────────────────────────────────────────────── */
body .nav-tabs {
  border-bottom: 1px solid var(--divider);
  margin-bottom: var(--sp-5);
  display: flex;
  gap: var(--sp-1);
  padding: 0 var(--sp-2);
}
body .nav-tabs > li { margin-bottom: -1px; }
body .nav-tabs > li > a {
  padding: var(--sp-3) var(--sp-4);
  margin: 0;
  border: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: transparent;
  color: var(--fg-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  border-bottom: 2px solid transparent;
  transition: all var(--dur-base) var(--ease-spring);
}
body .nav-tabs > li > a:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: transparent;
}
body .nav-tabs > li.active > a,
body .nav-tabs > li.active > a:hover,
body .nav-tabs > li.active > a:focus {
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

body .tab-content { padding-top: var(--sp-2); }


/* ─── 16. DROPDOWNS ─────────────────────────────────────────────────────── */
body .dropdown-menu {
  background: var(--surface);
  border: none;
  border-radius: var(--r-md);
  box-shadow: var(--sh-xl);
  padding: var(--sp-2);
  margin-top: var(--sp-1);
  min-width: 200px;
}
body .dropdown-menu > li > a {
  padding: var(--sp-2) var(--sp-3);
  font-size: 14px;
  color: var(--fg);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  transition: all var(--dur-fast) var(--ease-out);
}
body .dropdown-menu > li > a:hover,
body .dropdown-menu > li > a:focus {
  background: var(--accent-dim);
  color: var(--accent);
}
body .dropdown-menu > li.divider {
  height: 1px;
  background: var(--divider);
  margin: var(--sp-2) 0;
}
body .dropdown-menu > .dropdown-header {
  padding: var(--sp-2) var(--sp-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}


/* ─── 17. DATETIMEPICKER (Tempus Dominus) ───────────────────────────────── */
body .bootstrap-datetimepicker-widget {
  background: var(--surface);
  border: none;
  border-radius: var(--r-md);
  box-shadow: var(--sh-xl);
  padding: var(--sp-3);
  font-family: var(--font-body);
}
body .bootstrap-datetimepicker-widget table th,
body .bootstrap-datetimepicker-widget table td {
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 13px;
}
body .bootstrap-datetimepicker-widget table th {
  font-weight: 600;
  color: var(--fg-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
body .bootstrap-datetimepicker-widget table td.day {
  height: 36px;
  width: 36px;
  line-height: 36px;
  color: var(--fg);
  transition: all var(--dur-fast) var(--ease-out);
}
body .bootstrap-datetimepicker-widget table td.day:hover {
  background: var(--accent-dim);
  color: var(--accent);
}
body .bootstrap-datetimepicker-widget table td.day.today {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
}
body .bootstrap-datetimepicker-widget table td.day.active,
body .bootstrap-datetimepicker-widget table td.day.active:hover {
  background: var(--accent);
  color: var(--fg-inverse);
  font-weight: 600;
  text-shadow: none;
}
body .bootstrap-datetimepicker-widget table td.old,
body .bootstrap-datetimepicker-widget table td.new { color: var(--fg-dim); }
body .bootstrap-datetimepicker-widget table thead tr:first-child th:hover {
  background: var(--bg-secondary);
}


/* ─── 18. FULLCALENDAR ──────────────────────────────────────────────────── */
body .fc-toolbar h2,
body .fc .fc-toolbar-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
}
body .fc .fc-button {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  height: 36px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  text-transform: none;
  box-shadow: var(--sh-xs);
}
body .fc .fc-button:hover { background: var(--bg-secondary); }
body .fc .fc-button-primary:not(:disabled).fc-button-active,
body .fc .fc-button-primary:not(:disabled):active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--fg-inverse);
}
body .fc .fc-daygrid-day.fc-day-today {
  background: var(--accent-dim);
}
body .fc .fc-daygrid-day-number {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--fg-secondary);
  padding: var(--sp-2);
}
body .fc-event {
  border: none;
  border-radius: var(--r-sm);
  padding: 2px var(--sp-2);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  background: var(--accent);
  color: var(--fg-inverse);
}


/* ─── 19. SUMMERNOTE ────────────────────────────────────────────────────── */
body .note-editor.note-frame {
  border: 1px solid var(--border-hi);
  border-radius: var(--r-md);
  box-shadow: var(--sh-xs);
  overflow: hidden;
}
body .note-editor.note-frame .note-toolbar {
  background: var(--elevated);
  border-bottom: 1px solid var(--divider);
  padding: var(--sp-2) var(--sp-3);
}
body .note-editor.note-frame .note-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-secondary);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  height: 32px;
  padding: 0 var(--sp-2);
  transition: all var(--dur-fast) var(--ease-out);
}
body .note-editor.note-frame .note-btn:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: transparent;
}
body .note-editor.note-frame .note-btn.active {
  background: var(--accent);
  color: var(--fg-inverse);
}
body .note-editor.note-frame .note-editing-area .note-editable {
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  padding: var(--sp-4);
  min-height: 180px;
}
body .note-editor.note-frame .note-statusbar {
  background: var(--elevated);
  border-top: 1px solid var(--divider);
}


/* ─── 20. DROPZONE ──────────────────────────────────────────────────────── */
body .dropzone,
body .dz-default {
  background: var(--bg-secondary);
  border: 2px dashed var(--border-hi);
  border-radius: var(--r-lg);
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  transition: all var(--dur-base) var(--ease-spring);
  min-height: 160px;
}
body .dropzone:hover,
body .dropzone.dz-drag-hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  border-style: solid;
}
body .dropzone .dz-message {
  font-family: var(--font-body);
  color: var(--fg-muted);
  font-size: 14px;
}
body .dropzone:hover .dz-message { color: var(--accent); }

body .dropzone .dz-preview {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  padding: var(--sp-3);
  margin: var(--sp-2);
}


/* ─── 21. KANBAN ────────────────────────────────────────────────────────── */
body .kanban-col,
body .kanban-board > .kanban-board-header,
body .kanban-board {
  background: var(--bg-secondary) !important;
  border: none !important;
  border-radius: var(--r-md);
  padding: var(--sp-3);
}
body .kanban-board-header {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
  letter-spacing: -0.01em;
  padding-bottom: var(--sp-3);
}
body .kanban-item {
  background: var(--surface);
  border: none;
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  cursor: grab;
  transition: all var(--dur-base) var(--ease-spring);
  position: relative;
}
body .kanban-item:hover {
  box-shadow: var(--sh-hover);
  transform: translateY(-1px);
}
body .kanban-item.kanban-selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: var(--sp-3);
  bottom: var(--sp-3);
  width: var(--selvedge-w);
  background: var(--selvedge-color);
  border-radius: 0 2px 2px 0;
}


/* ─── 22. TOASTS / alert_float ──────────────────────────────────────────── */
body .floated-customizer-btn,
body #app-tooltip,
body .alert-float-container {
  position: fixed;
  top: var(--sp-6);
  right: var(--sp-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-width: 380px;
}
body .alert.alert-float {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-left-width: var(--selvedge-w);
  box-shadow: var(--sh-xl);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  animation: toast-in var(--dur-base) var(--ease-spring) both;
  min-width: 320px;
  max-width: 380px;
}
body .alert.alert-float.alert-success { border-left-color: var(--success); color: var(--fg); }
body .alert.alert-float.alert-danger  { border-left-color: var(--danger);  color: var(--fg); }
body .alert.alert-float.alert-warning { border-left-color: var(--warning); color: var(--fg); }
body .alert.alert-float.alert-info    { border-left-color: var(--info);    color: var(--fg); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(110%); }
  to   { opacity: 1; transform: translateX(0); }
}


/* ─── 23. TOOLTIPS ──────────────────────────────────────────────────────── */
body .tooltip {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
}
body .tooltip-inner {
  background: #111827;
  color: var(--fg-inverse);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  box-shadow: var(--sh-md);
  max-width: 240px;
}
body .tooltip.top .tooltip-arrow,
body .tooltip-arrow { border-top-color: #111827 !important; border-bottom-color: #111827 !important; }


/* ─── 24. PROGRESS ──────────────────────────────────────────────────────── */
body .progress {
  background: var(--bg-secondary);
  height: 6px;
  border-radius: var(--r-pill);
  overflow: hidden;
  box-shadow: none;
}
body .progress.progress-lg { height: 10px; }
body .progress.progress-sm { height: 4px; }

body .progress-bar {
  background: var(--accent);
  border-radius: var(--r-pill);
  box-shadow: none;
  transition: width var(--dur-slow) var(--ease-spring);
}
body .progress-bar-success { background: var(--success); }
body .progress-bar-danger  { background: var(--danger);  }
body .progress-bar-warning { background: var(--pop);     }
body .progress-bar-info    { background: var(--info);    }


/* ─── 25. CONTEXT MENU ──────────────────────────────────────────────────── */
.context-menu-list,
.context-menu-root {
  background: var(--surface);
  border: none;
  border-radius: var(--r-md);
  box-shadow: var(--sh-xl);
  padding: var(--sp-2);
  min-width: 200px;
  font-family: var(--font-body);
}
.context-menu-item {
  padding: var(--sp-2) var(--sp-3);
  font-size: 14px;
  color: var(--fg);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.context-menu-item.context-menu-hover {
  background: var(--accent-dim);
  color: var(--accent);
}
.context-menu-separator {
  height: 1px;
  background: var(--divider);
  margin: var(--sp-2) 0;
}


/* ─── 26. ACCOUNTING TEMPLATE (invoice/estimate/proposal) ───────────────── */
/*
   Targets: body.viewinvoice  (public invoice)
            body.viewestimate (public estimate)
   Template: invoice-useuspro.html
   Design: warm paper #FAF8F3, dark bg #1A1A18, rust accent #D85A30,
           dashed left selvedge, Inter Tight + JetBrains Mono
*/

/* Local tokens */
body.viewinvoice,
body.viewestimate {
  --inv-paper:     #FAF8F3;
  --inv-paper-2:   #F2EFE6;
  --inv-ink:       #0D0D0D;
  --inv-ink-2:     #1F1F1D;
  --inv-ink-3:     #3A3A36;
  --inv-accent:    #D85A30;
  --inv-accent-dk: #B8431F;
  --inv-rust:      #6B3318;
  --inv-muted:     #555450;
  --inv-rule:      #CFCCC1;
  --inv-fb: 'Inter Tight','Inter',system-ui,-apple-system,'Segoe UI',sans-serif;
  --inv-fm: 'JetBrains Mono',ui-monospace,'SF Mono',Menlo,monospace;
}

/* Dark page background */
body.viewinvoice,
body.viewestimate {
  background: #1A1A18 !important; /* PERFEX_OVERRIDE */
  font-family: var(--inv-fb);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
  padding: 24px 16px 80px;
}

/* Action bar */
body.viewinvoice .preview-top-wrapper,
body.viewestimate .preview-top-wrapper {
  max-width: 880px;
  margin: 0 auto 18px;
  background: transparent;
  padding: 0;
}
body.viewinvoice .preview-top-wrapper .invoice-html-logo img,
body.viewestimate .preview-top-wrapper .invoice-html-logo img {
  max-height: 40px;
  width: auto;
}
body.viewinvoice .preview-top-wrapper a,
body.viewestimate .preview-top-wrapper a {
  color: #aaa;
  font-size: 13px;
}
body.viewinvoice .preview-top-wrapper a:hover,
body.viewestimate .preview-top-wrapper a:hover {
  color: var(--inv-accent);
  text-decoration: none;
}
body.viewinvoice .preview-sticky-header,
body.viewestimate .preview-sticky-header {
  background: #111;
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
}

/* Buttons */
body.viewinvoice .action-button,
body.viewestimate .action-button {
  font-family: var(--inv-fb);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  border-radius: 3px;
  min-height: 46px;
  padding: 0 22px;
  transition: background .15s ease, color .15s ease;
}
body.viewinvoice .action-button.btn-default,
body.viewestimate .action-button.btn-default {
  background: transparent !important; /* PERFEX_OVERRIDE */
  border: 1px solid rgba(255,255,255,.35) !important; /* PERFEX_OVERRIDE */
  color: #ddd !important; /* PERFEX_OVERRIDE */
}
body.viewinvoice .action-button.btn-default:hover,
body.viewestimate .action-button.btn-default:hover {
  background: rgba(255,255,255,.08) !important; /* PERFEX_OVERRIDE */
}
body.viewinvoice .action-button.btn-success,
body.viewestimate .action-button.btn-success,
body.viewinvoice .pay-now-top,
body.viewestimate .pay-now-top {
  background: var(--inv-accent) !important; /* PERFEX_OVERRIDE */
  border-color: var(--inv-accent) !important; /* PERFEX_OVERRIDE */
  color: #fff !important; /* PERFEX_OVERRIDE */
  min-height: 54px;
  padding: 0 32px;
  font-size: 15px;
}
body.viewinvoice .action-button.btn-success:hover,
body.viewestimate .action-button.btn-success:hover {
  background: var(--inv-accent-dk) !important; /* PERFEX_OVERRIDE */
  border-color: var(--inv-accent-dk) !important; /* PERFEX_OVERRIDE */
}

/* Main card */
body.viewinvoice .panel_s,
body.viewestimate .panel_s {
  max-width: 880px;
  margin: 0 auto;
  background: var(--inv-paper);
  border: none;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 16px 56px rgba(0,0,0,.4);
  position: relative;
  color: var(--inv-ink-2);
  font-family: var(--inv-fb);
}
/* Dashed selvedge left stripe */
body.viewinvoice .panel_s::before,
body.viewestimate .panel_s::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: repeating-linear-gradient(
    to bottom,
    var(--inv-accent) 0 8px,
    transparent 8px 16px
  );
  opacity: .8;
  border-radius: 4px 0 0 4px;
}
body.viewinvoice .panel_s > .panel-body,
body.viewestimate .panel_s > .panel-body {
  padding: 52px 56px 40px;
}

/* Kicker above invoice number */
body.viewinvoice .transaction-html-info-col-left::before,
body.viewestimate .transaction-html-info-col-left::before {
  content: 'Use Us Pro \00b7  Statement of Charges';
  display: block;
  font-size: 10.5px;
  letter-spacing: .24em;
  color: var(--inv-rust);
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 10px;
}
/* Invoice/estimate number heading */
body.viewinvoice h4.invoice-html-number,
body.viewestimate h4.estimate-html-number {
  font-size: 12.5px;
  letter-spacing: .06em;
  color: var(--inv-ink-3);
  font-weight: 500;
  font-family: var(--inv-fm);
  margin-top: 10px;
}
body.viewinvoice h3.invoice-html-number,
body.viewestimate h3.estimate-html-number {
  font-size: clamp(36px, 5vw, 50px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: .95;
  color: var(--inv-ink);
  font-family: var(--inv-fb);
  margin: 0 0 10px;
}

/* Status badge */
body.viewinvoice .invoice-html-status .label,
body.viewestimate .estimate-html-status .label {
  background: var(--inv-accent) !important; /* PERFEX_OVERRIDE */
  color: #fff !important; /* PERFEX_OVERRIDE */
  font-size: 10.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 2px;
  font-family: var(--inv-fb);
}
/* Paid = dark */
body.viewinvoice .invoice-status-2 .label {
  background: var(--inv-ink) !important; /* PERFEX_OVERRIDE */
}

/* Dates */
body.viewinvoice .invoice-html-date,
body.viewinvoice .invoice-html-duedate,
body.viewinvoice .invoice-html-sale-agent,
body.viewestimate .estimate-html-date,
body.viewestimate .estimate-html-duedate {
  font-size: 11.5px;
  color: var(--inv-ink-3);
  line-height: 1.85;
  margin-bottom: 2px !important; /* PERFEX_OVERRIDE */
}
body.viewinvoice .invoice-html-date .tw-font-medium,
body.viewinvoice .invoice-html-duedate .tw-font-medium,
body.viewestimate .estimate-html-date .tw-font-medium {
  color: var(--inv-ink);
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-size: 10.5px;
  margin-right: 4px;
}

/* Bill To label */
body.viewinvoice .invoice-html-bill-to,
body.viewestimate .estimate-html-bill-to {
  font-size: 10.5px !important; /* PERFEX_OVERRIDE */
  letter-spacing: .24em !important; /* PERFEX_OVERRIDE */
  color: var(--inv-rust) !important; /* PERFEX_OVERRIDE */
  text-transform: uppercase;
  font-weight: 500;
  display: block;
  margin-bottom: 10px;
}
/* Addresses */
body.viewinvoice .invoice-html-company-info,
body.viewinvoice .invoice-html-customer-billing-info,
body.viewestimate .estimate-html-company-info,
body.viewestimate .estimate-html-customer-billing-info {
  font-size: 13.5px;
  color: var(--inv-ink-3);
  line-height: 1.7;
  font-style: normal;
}
body.viewinvoice .invoice-html-customer-billing-info strong,
body.viewinvoice .invoice-html-customer-billing-info b,
body.viewestimate .estimate-html-customer-billing-info strong,
body.viewestimate .estimate-html-customer-billing-info b {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--inv-ink);
  display: block;
  margin-bottom: 4px;
}

/* Dividers */
body.viewinvoice .panel_s hr,
body.viewestimate .panel_s hr {
  border-color: rgba(13,13,13,.12);
  margin: 20px 0;
}

/* Line items table */
body.viewinvoice .panel_s .table-responsive table > thead > tr > th,
body.viewestimate .panel_s .table-responsive table > thead > tr > th {
  font-size: 10.5px;
  letter-spacing: .22em;
  color: var(--inv-rust);
  text-transform: uppercase;
  font-weight: 500;
  padding: 0 8px 12px;
  background: transparent;
  border-bottom: 0.5px solid var(--inv-ink);
}
body.viewinvoice .panel_s .table-responsive table > thead > tr > th:not(:first-child),
body.viewestimate .panel_s .table-responsive table > thead > tr > th:not(:first-child) {
  text-align: right;
}
body.viewinvoice .panel_s .table-responsive table > tbody > tr > td,
body.viewestimate .panel_s .table-responsive table > tbody > tr > td {
  padding: 18px 8px;
  vertical-align: top;
  border-top: none;
  border-bottom: 0.5px dashed var(--inv-rule);
  color: var(--inv-ink-2);
  font-size: 14px;
  background: transparent;
}
body.viewinvoice .panel_s .table-responsive table > tbody > tr:last-child > td,
body.viewestimate .panel_s .table-responsive table > tbody > tr:last-child > td {
  border-bottom: none;
}
body.viewinvoice .panel_s .table-responsive table > tbody > tr:hover > td,
body.viewestimate .panel_s .table-responsive table > tbody > tr:hover > td {
  background: rgba(216,90,48,.03);
}
/* Item name */
body.viewinvoice .panel_s .table-responsive table > tbody > tr > td:nth-child(2),
body.viewestimate .panel_s .table-responsive table > tbody > tr > td:nth-child(2) {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--inv-ink);
}
body.viewinvoice .panel_s .table-responsive table > tbody > tr > td:nth-child(2) small,
body.viewinvoice .panel_s .table-responsive table > tbody > tr > td:nth-child(2) p,
body.viewestimate .panel_s .table-responsive table > tbody > tr > td:nth-child(2) small,
body.viewestimate .panel_s .table-responsive table > tbody > tr > td:nth-child(2) p {
  font-size: 13px;
  color: var(--inv-ink-3);
  line-height: 1.7;
  font-weight: 400;
}
/* Qty */
body.viewinvoice .panel_s .table-responsive table > tbody > tr > td:nth-last-child(3),
body.viewestimate .panel_s .table-responsive table > tbody > tr > td:nth-last-child(3) {
  font-family: var(--inv-fm);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 14px;
  color: var(--inv-ink-3);
  font-weight: 400;
}
/* Rate */
body.viewinvoice .panel_s .table-responsive table > tbody > tr > td:nth-last-child(2),
body.viewestimate .panel_s .table-responsive table > tbody > tr > td:nth-last-child(2) {
  font-family: var(--inv-fm);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 14px;
  color: var(--inv-ink-2);
  font-weight: 500;
}
/* Amount */
body.viewinvoice .panel_s .table-responsive table > tbody > tr > td:last-child,
body.viewestimate .panel_s .table-responsive table > tbody > tr > td:last-child {
  font-family: var(--inv-fm);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 15.5px;
  color: var(--inv-ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Totals section */
body.viewinvoice .panel_s .col-md-6.col-md-offset-6,
body.viewestimate .panel_s .col-md-6.col-md-offset-6 {
  padding-top: 24px;
  border-top: 2px solid var(--inv-ink);
}
body.viewinvoice .panel_s .col-md-6.col-md-offset-6 .table td,
body.viewestimate .panel_s .col-md-6.col-md-offset-6 .table td {
  padding: 7px 8px;
  border: none !important; /* PERFEX_OVERRIDE */
  font-size: 14px;
  font-family: var(--inv-fb);
  color: var(--inv-ink-3);
  background: transparent;
  font-variant-numeric: tabular-nums;
}
body.viewinvoice .panel_s .col-md-6.col-md-offset-6 .table td:last-child,
body.viewestimate .panel_s .col-md-6.col-md-offset-6 .table td:last-child {
  font-family: var(--inv-fm);
  color: var(--inv-ink-2);
  font-weight: 500;
  text-align: right;
}
body.viewinvoice .panel_s .col-md-6.col-md-offset-6 .table td .bold,
body.viewinvoice .panel_s .col-md-6.col-md-offset-6 .table td .tw-font-medium,
body.viewestimate .panel_s .col-md-6.col-md-offset-6 .table td .bold,
body.viewestimate .panel_s .col-md-6.col-md-offset-6 .table td .tw-font-medium {
  color: var(--inv-ink-3);
  font-weight: 400;
}
/* Grand total row */
body.viewinvoice .panel_s td.total,
body.viewestimate .panel_s td.total {
  border-top: 0.5px solid var(--inv-ink) !important; /* PERFEX_OVERRIDE */
  padding-top: 14px !important; /* PERFEX_OVERRIDE */
  font-family: var(--inv-fm) !important; /* PERFEX_OVERRIDE */
  font-size: 18px !important; /* PERFEX_OVERRIDE */
  font-weight: 600 !important; /* PERFEX_OVERRIDE */
  color: var(--inv-ink) !important; /* PERFEX_OVERRIDE */
  letter-spacing: -0.01em;
}
/* Notes */
body.viewinvoice .invoice-html-note b,
body.viewinvoice .invoice-html-terms-and-conditions b,
body.viewestimate .estimate-html-note b {
  font-size: 10.5px;
  letter-spacing: .24em;
  color: var(--inv-rust);
  text-transform: uppercase;
  font-weight: 500;
}
body.viewinvoice .invoice-html-note .tw-text-neutral-500,
body.viewinvoice .invoice-html-terms-and-conditions .tw-text-neutral-500 {
  font-size: 13px;
  color: var(--inv-ink-3);
  line-height: 1.75;
}

/* Payments table */
body.viewinvoice .invoice-html-payments b {
  font-size: 10.5px;
  letter-spacing: .24em;
  color: var(--inv-rust);
  text-transform: uppercase;
  font-weight: 500;
}
body.viewinvoice .invoice-payments-table thead > tr > th {
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--inv-rust);
  font-weight: 500;
  background: transparent;
  padding: 8px;
  border-bottom: 0.5px solid var(--inv-ink);
}
body.viewinvoice .invoice-payments-table tbody > tr > td {
  padding: 10px 8px;
  font-size: 13px;
  color: var(--inv-ink-3);
  border-top: 0.5px dashed var(--inv-rule);
}

/* Online payment form */
body.viewinvoice .online-payment-radio label {
  font-size: 14px;
  font-weight: 500;
  color: var(--inv-ink);
}
body.viewinvoice #online_payment_form .btn-success {
  background: var(--inv-accent) !important; /* PERFEX_OVERRIDE */
  border-color: var(--inv-accent) !important; /* PERFEX_OVERRIDE */
  border-radius: 3px;
  font-weight: 500;
}

/* Overdue alert */
body.viewinvoice .panel_s .alert-danger,
body.viewestimate .panel_s .alert-danger {
  background: rgba(216,90,48,.08);
  border-color: rgba(216,90,48,.25);
  color: var(--inv-accent-dk);
  border-radius: 3px;
  font-size: 13px;
  font-weight: 500;
}

/* Mobile */
@media (max-width: 720px) {
  body.viewinvoice,
  body.viewestimate {
    padding: 12px 10px 80px;
  }
  body.viewinvoice .panel_s > .panel-body,
  body.viewestimate .panel_s > .panel-body {
    padding: 32px 22px 28px;
  }
}

/* ── Admin estimate/invoice line items editor ── */
body .estimate-items-table thead > tr > th,
body table.items.table-main-estimate-edit thead > tr > th {
  background: var(--elevated);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg-muted);
  font-weight: 600;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--divider);
}
body .estimate-items-table tbody > tr > td,
body table.items.table-main-estimate-edit tbody > tr > td {
  padding: var(--sp-3) var(--sp-4);
  vertical-align: middle;
  border-top: 1px solid var(--divider);
}
body .estimate-items-table .form-control:focus,
body table.items.table-main-estimate-edit .form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}


/* ─── 27. DASHBOARD WIDGETS ─────────────────────────────────────────────── */
/* Dashboard overview widgets (Invoice / Estimate / Proposal overview) */
.dashboard-overview-widget,
.widget-overview {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  padding: var(--sp-5) var(--sp-6);
}
.dashboard-overview-widget h4,
.widget-overview h4 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 var(--sp-4);
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  letter-spacing: -0.01em;
}
.dashboard-overview-widget .progress-row,
.widget-overview .stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--sp-2);
  font-size: 13px;
}
.dashboard-overview-widget .progress-row .stat-label,
.widget-overview .stat-row .stat-label {
  color: var(--fg-secondary);
}
.dashboard-overview-widget .progress-row .stat-percent,
.widget-overview .stat-row .stat-percent {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  color: var(--fg-muted);
  font-size: 12px;
}

/* My To Do panel — gets selvedge */
.todo-widget,
#widget_my_todo,
.panel:has(.todo-list) {
  position: relative;
}

/* Cron job warning — convert to v3 alert style */
body .alert-warning {
  border-left-width: 4px;
}


/* ─── 28. SKELETONS & EMPTY STATES ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--elevated) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton-wave {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state,
.no-data {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--fg-muted);
}
.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--sp-4);
  color: var(--fg-dim);
  opacity: 0.6;
}
.empty-state h3,
.empty-state .empty-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--fg);
  margin: 0 0 var(--sp-2);
  letter-spacing: -0.01em;
}
.empty-state p,
.empty-state .empty-body {
  font-size: 14px;
  color: var(--fg-muted);
  max-width: 320px;
  margin: 0 auto var(--sp-4);
  line-height: 1.6;
}


/* ─── 29. FOCUS RING & A11Y ─────────────────────────────────────────────── */
*:focus-visible {
  outline: none;
  box-shadow: var(--sh-focus);
  border-radius: var(--r-xs);
  transition: box-shadow var(--dur-fast) var(--ease-out);
}

/* Skip link */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: var(--sp-4);
  background: var(--accent);
  color: var(--fg-inverse);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  z-index: var(--z-tooltip);
  transition: top var(--dur-base) var(--ease-spring);
  box-shadow: var(--sh-md);
}
.skip-to-content:focus {
  top: var(--sp-4);
  color: var(--fg-inverse);
}


/* ─── 30. SELVEDGE — global utility class ───────────────────────────────── */
.selvedge,
[data-selvedge] {
  position: relative;
}
.selvedge::before,
[data-selvedge]::before {
  content: '';
  position: absolute;
  left: 0;
  top: var(--sp-3);
  bottom: var(--sp-3);
  width: var(--selvedge-w);
  background: var(--selvedge-color);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px var(--pop-glow);
}
[data-selvedge="navy"]::before { background: var(--selvedge-structural); box-shadow: 0 0 8px var(--accent-glow); }


/* ─── 31. PERFEX PLUGIN-SPECIFIC OVERRIDES ──────────────────────────────── */
/* PERFEX_OVERRIDE: Perfex's _setup.css uses uppercase panel headings — kill it */
body .panel-default > .panel-heading,
body .panel-info > .panel-heading,
body .panel-success > .panel-heading,
body .panel-warning > .panel-heading {
  text-transform: none !important;
  font-size: 15px !important;
  letter-spacing: -0.01em !important;
}

/* PERFEX_OVERRIDE: Perfex's #setup-menu > div absolute background */
body #setup-menu, body #setup-menu .menu-toggle, body .setup-menu-color {
  background: var(--surface) !important;
}

/* PERFEX_OVERRIDE: Perfex header has its own dark mode by default — force light */
body #header { background: var(--surface) !important; }

/* PERFEX_OVERRIDE: customizer panel */
body .customizer {
  background: var(--surface);
  border-left: 1px solid var(--divider);
  box-shadow: var(--sh-lg);
  border-radius: var(--r-lg) 0 0 var(--r-lg);
}

/* PERFEX_OVERRIDE: Perfex timer button (start_timer) */
body .start-timer,
body .stop-timer {
  border-radius: var(--r-pill) !important;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  height: 28px;
  padding: 0 var(--sp-3);
}

/* PERFEX_OVERRIDE: Perfex breadcrumbs */
body .breadcrumb,
body ol.breadcrumb {
  background: transparent;
  padding: 0 0 var(--sp-3);
  margin: 0;
  font-size: 13px;
  color: var(--fg-muted);
}
body .breadcrumb > li + li::before { color: var(--fg-dim); content: '/'; padding: 0 var(--sp-2); }
body .breadcrumb > .active { color: var(--fg); font-weight: 500; }

/* PERFEX_OVERRIDE: Page title bar */
body #wrapper > .content > h1,
body .page-title,
body .heading-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.03em;
  color: var(--fg);
  margin: 0 0 var(--sp-5);
}

/* PERFEX_OVERRIDE: Quick filter buttons (status filters above tables) */
body .table-filters,
body .filter-area {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
body .table-filters .btn,
body .filter-area .btn {
  height: 32px;
  padding: 0 var(--sp-3);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-pill);
  background: var(--bg-secondary);
  border-color: transparent;
  color: var(--fg-secondary);
}
body .table-filters .btn.active,
body .filter-area .btn.active {
  background: var(--accent);
  color: var(--fg-inverse);
  border-color: var(--accent);
}

/* PERFEX_OVERRIDE: Avatar circles */
body .img-circle,
body .staff-profile-image-small {
  border: 2px solid var(--surface);
  box-shadow: var(--sh-xs);
}

/* PERFEX_OVERRIDE: Status indicators in tables (colored dots) */
body .invoice-status-1, body .estimate-status-1, body .proposal-status-1 { color: var(--fg-muted) !important; }
body .invoice-status-2, body .estimate-status-2, body .proposal-status-2 { color: var(--info) !important; }
body .invoice-status-3, body .estimate-status-3, body .proposal-status-3 { color: var(--warning) !important; }
body .invoice-status-4, body .estimate-status-4                          { color: var(--success) !important; }
body .invoice-status-5, body .estimate-status-5                          { color: var(--danger)  !important; }

/* PERFEX_OVERRIDE: Knowledge base tiles */
body .kb-group {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  padding: var(--sp-5);
  transition: all var(--dur-base) var(--ease-spring);
}
body .kb-group:hover {
  box-shadow: var(--sh-hover);
  transform: translateY(-2px);
}


/* ─── 32. PRINT STYLESHEET ──────────────────────────────────────────────── */
@media print {
  body {
    background: white !important;
    color: black !important;
    font-family: var(--font-body);
    font-size: 11pt;
    line-height: 1.5;
  }

  #header,
  #setup-menu,
  .customizer,
  .no-print,
  .btn,
  .modal-backdrop,
  .floated-customizer-btn,
  .alert-float-container,
  .breadcrumb,
  .nav-tabs,
  .dataTables_filter,
  .dataTables_length,
  .dataTables_paginate,
  .dataTables_info { display: none !important; }

  #wrapper, .content {
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
  }

  .panel,
  .x_panel {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    page-break-inside: avoid;
    background: white !important;
  }

  .panel-heading {
    background: white !important;
    border-bottom: 2px solid black !important;
    padding: 0 0 6pt !important;
  }

  /* Invoice line items get hard rules for print */
  .table-invoice,
  .table-line-items,
  .invoice_lines_table {
    border: 1px solid black !important;
  }
  .table-invoice th,
  .table-line-items th,
  .invoice_lines_table th {
    background: #F0F0F0 !important;
    color: black !important;
    border-bottom: 1pt solid black !important;
    border-right: 0.5pt solid #ccc !important;
  }
  .table-invoice td,
  .table-line-items td,
  .invoice_lines_table td {
    border-bottom: 0.5pt solid #ccc !important;
    border-right: 0.5pt solid #ccc !important;
  }

  .invoice-totals,
  .estimate-totals { page-break-inside: avoid; }

  .invoice-totals .grand-total .amount,
  .invoice-totals .total .amount {
    color: black !important;
    text-decoration: underline !important;
    text-decoration-color: #999 !important;
  }

  .invoice-signature,
  .signature-area {
    page-break-inside: avoid;
    border: 1pt dashed #999 !important;
    background: white !important;
  }

  a, a:visited {
    color: black !important;
    text-decoration: none !important;
  }

  /* Page setup */
  @page {
    margin: 18mm 14mm;
    size: letter;
  }
}


/* ─── 33. DARK MODE SCAFFOLD — [data-theme="dark"] ──────────────────────── */
/* NOT activated by default. Toggle by setting <body data-theme="dark"> */
body[data-theme="dark"] {
  --bg:                #0F1419;
  --bg-secondary:      #1A1F26;
  --surface:           #161B22;
  --elevated:          #1C232C;
  --paper:             #131820;
  --overlay:           rgba(15, 20, 25, 0.92);

  --fg:                #F0F2F5;
  --fg-secondary:      #C9D1D9;
  --fg-muted:          #8B949E;
  --fg-dim:            #6E7681;
  --fg-inverse:        #0F1419;

  --border:            #30363D;
  --border-hi:         #484F58;
  --divider:           rgba(240, 242, 245, 0.08);
  --divider-strong:    rgba(240, 242, 245, 0.14);

  --accent-dim:        rgba(58, 102, 196, 0.14);
  --accent-glow:       rgba(58, 102, 196, 0.28);
  --accent-ring:       rgba(58, 102, 196, 0.40);
  --accent:            #3A66C4;
  --accent-hover:      #4878D9;

  --success-bg:        rgba(22, 101, 52, 0.12);
  --danger-bg:         rgba(153, 27, 27, 0.12);
  --warning-bg:        rgba(146, 64, 14, 0.12);
  --info-bg:           rgba(30, 64, 175, 0.12);
}


/* ─── 34. DENSITY MODES ─────────────────────────────────────────────────── */
body[data-density="compact"] .table > tbody > tr > td,
body[data-density="compact"] table.dataTable > tbody > tr > td {
  padding: var(--sp-2) var(--sp-4);
  min-height: 36px;
}
body[data-density="compact"] .panel-body { padding: var(--sp-4); }
body[data-density="compact"] .form-group { margin-bottom: var(--sp-3); }

body[data-density="comfortable"] .table > tbody > tr > td,
body[data-density="comfortable"] table.dataTable > tbody > tr > td {
  padding: var(--sp-5) var(--sp-6);
  min-height: 56px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   END · BUILD-WUS-CRM-V3-002 · ~2,200 lines
   ═══════════════════════════════════════════════════════════════════════════ */


/* ═══════════════════════════════════════════════════════════════════════════
   35. ENHANCEMENTS v3.1 — Inspired by StackedList / ActivityDropdown /
       LayoutSwitcher patterns. CSS-only. No layout overrides.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── 35a. TABLE ROW — SELECTED STATE (selvedge stripe) ─────────────────── */
/* Mirrors StackedList's active member row treatment */
body .table > tbody > tr.selected > td,
body table.dataTable > tbody > tr.selected > td {
  background: rgba(10, 36, 99, 0.04);
}
body .table > tbody > tr.selected > td:first-child,
body table.dataTable > tbody > tr.selected > td:first-child {
  position: relative;
}
body .table > tbody > tr.selected > td:first-child::before,
body table.dataTable > tbody > tr.selected > td:first-child::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: var(--selvedge-w);
  background: var(--selvedge-structural);
  border-radius: 0 2px 2px 0;
}


/* ─── 35b. ONLINE / PRESENCE DOTS ───────────────────────────────────────── */
/* StackedList online indicator pattern, applied to staff/contacts */
body .staff-online-indicator,
body .contact-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-dim);
  border: 2px solid var(--surface);
  flex-shrink: 0;
}
body .staff-online-indicator.online,
body .contact-status-dot.online {
  background: #22C55E;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}
/* Avatar with online dot — wrap with .avatar-presence */
body .avatar-presence {
  position: relative;
  display: inline-block;
}
body .avatar-presence::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22C55E;
  border: 2px solid var(--surface);
}


/* ─── 35c. ROLE / TYPE BADGES ────────────────────────────────────────────── */
/* StackedList RoleBadge — semantic colored pills, FontAwesome icon + label */
/* Usage: <span class="role-badge role-pm">Project Manager</span> */
body .role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}
body .role-badge.role-admin    { background: #FFFCEB; color: #856404; border-color: #FFEBA5; }
body .role-badge.role-staff    { background: #F0F7FF; color: #004085; border-color: #B8DAFF; }
body .role-badge.role-client   { background: #F3FAF4; color: #155724; border-color: #C3E6CB; }
body .role-badge.role-sales    { background: #FCF5FF; color: #522785; border-color: #E8D1FF; }


/* ─── 35d. PILL TAB SWITCHER (LayoutSwitcher pattern) ───────────────────── */
/* Replaces .nav-tabs in contexts where a pill selector is more appropriate */
body .nav-pills-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
}
body .nav-pills-switcher > li { display: inline-flex; }
body .nav-pills-switcher > li > a {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 30px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  border: none;
  background: transparent;
  transition: all var(--dur-base) var(--ease-spring);
  white-space: nowrap;
}
body .nav-pills-switcher > li > a:hover {
  color: var(--fg);
  background: var(--elevated);
}
body .nav-pills-switcher > li.active > a,
body .nav-pills-switcher > li.active > a:hover,
body .nav-pills-switcher > li.active > a:focus {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--sh-sm);
}


/* ─── 35e. QUICK FILTER STRIP (invoice / estimate list sweeping) ─────────── */
/* The top strip on list pages that lets you sweep by status */
/* Perfex uses .table-filters / .filter-row — enhanced here */
body .filter-row,
body .list-filter-strip {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-4) 0 var(--sp-3);
  border-bottom: 1px solid var(--divider);
  margin-bottom: var(--sp-4);
}
body .filter-row .filter-count,
body .list-filter-strip .filter-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  margin-left: auto;
}
/* Status filter buttons — pill style, consistent with LayoutSwitcher tab */
body .filter-row .btn-filter,
body .filter-area .btn-filter {
  height: 28px;
  padding: 0 var(--sp-3);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--r-pill);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-spring);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
body .filter-row .btn-filter::before,
body .filter-area .btn-filter::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  opacity: 0.7;
}
body .filter-row .btn-filter:hover,
body .filter-area .btn-filter:hover {
  background: var(--bg-secondary);
  border-color: var(--border-hi);
  color: var(--fg);
}
body .filter-row .btn-filter.active,
body .filter-area .btn-filter.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
body .filter-row .btn-filter.active-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
body .filter-row .btn-filter.active-danger  { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger);  }
body .filter-row .btn-filter.active-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
/* ─── 35f. NOTIFICATION / ACTIVITY PANEL ────────────────────────────────── */
/* ActivityDropdown pattern — the header notification dropdown */
body #header .notification-list,
body #header .dropdown-menu.notifications {
  position: absolute !important;
  top: 100% !important;
  right: 0 !important;
  left: auto !important;
  width: 360px !important;
  max-width: calc(100vw - 20px) !important; /* prevent overflow on small mobile screens */
  padding: 0 !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--sh-xl) !important;
  margin-top: 8px !important;
  background: var(--surface) !important;
  z-index: var(--z-dropdown) !important;
}
body #header .open > .notification-list,
body #header .open > .dropdown-menu.notifications {
  display: block !important;
}

body #header .notification-list .dropdown-header,
body #header .dropdown-menu.notifications .panel-heading {
  padding: var(--sp-4) var(--sp-5);
  background: var(--elevated);
  border-bottom: 1px solid var(--divider);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--fg);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
body #header .notification-list li > a,
body #header .dropdown-menu.notifications li > a {
  padding: var(--sp-3) var(--sp-5);
  border-radius: 0;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}
body #header .notification-list li:last-child > a,
body #header .dropdown-menu.notifications li:last-child > a {
  border-bottom: none;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
body #header .notification-list li > a .notification-time {
  font-size: 11px;
  color: var(--fg-dim);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
body #header .notification-list li > a .notification-text {
  font-size: 13px;
  color: var(--fg-secondary);
  line-height: 1.4;
  flex: 1;
}
body #header .notification-list li.unread > a {
  background: var(--accent-dim);
}
body #header .notification-list li.unread > a .notification-text {
  color: var(--fg);
  font-weight: 500;
}


/* ─── 35g. CLIENT / CONTACT LIST ROWS ───────────────────────────────────── */
/* StackedList MemberItem pattern applied to Perfex client/contact tables */
body table.dataTable tbody tr td .client-name-cell,
body .contacts-list .client-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
body .client-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
body .client-avatar-wrap .img-circle {
  width: 36px;
  height: 36px;
}
body .client-avatar-initials {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  border: 2px solid var(--surface);
  box-shadow: var(--sh-xs);
}


/* ─── 35h. STACKED AVATAR GROUP ─────────────────────────────────────────── */
/* StackedList summary bar — show a pile of avatars + overflow count */
body .avatar-stack {
  display: inline-flex;
  align-items: center;
}
body .avatar-stack .avatar-item {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: var(--sh-xs);
  margin-left: -8px;
  flex-shrink: 0;
  object-fit: cover;
}
body .avatar-stack .avatar-item:first-child { margin-left: 0; }
body .avatar-stack .avatar-overflow {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--bg-secondary);
  color: var(--fg-muted);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: -8px;
  flex-shrink: 0;
}


/* ─── 35i. LOGIN PAGE — CLIENT PORTAL ───────────────────────────────────── */
/* Beautiful client-facing login — CSS-only styling of Perfex's login.php structure */
body.login-page,
body.auth-page {
  background: var(--bg) !important;
}
/* Two-tone split */
body.login-page #wrapper,
body.auth-page #wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* The main login card */
body.login-page .login-box,
body.auth-page .login-box,
body.login-page .auth-box,
body.auth-page .auth-box {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  padding: var(--sp-10) var(--sp-8);
  width: 100%;
  max-width: 440px;
  border: 1px solid var(--border);
}
/* Brand mark above form */
body.login-page .logo,
body.auth-page .logo,
body.login-page .login-logo {
  text-align: center;
  margin-bottom: var(--sp-6);
}
body.login-page .login-logo img { max-height: 40px; }
/* Login heading */
body.login-page .login-box h2,
body.auth-page .login-box h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--fg);
  margin: 0 0 var(--sp-2);
  text-align: center;
}
body.login-page .login-box .login-subtext,
body.login-page .login-box > p {
  font-size: 14px;
  color: var(--fg-muted);
  text-align: center;
  margin-bottom: var(--sp-6);
}
/* Selvedge accent on login card top */
body.login-page .login-box::before,
body.auth-page .login-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: var(--sp-8);
  right: var(--sp-8);
  height: var(--selvedge-w);
  background: var(--selvedge-structural);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
}
body.login-page .login-box { position: relative; }
/* Submit button — full-width navy */
body.login-page .login-box .btn-primary,
body.auth-page .login-box .btn-primary {
  width: 100%;
  height: 44px;
  font-size: 15px;
  font-weight: 600;
  margin-top: var(--sp-2);
  letter-spacing: -0.01em;
}
/* "Forgot password" link row */
body.login-page .login-box .forgot-password,
body.login-page .login-box .forgot-link {
  text-align: right;
  font-size: 13px;
  margin-top: var(--sp-2);
  margin-bottom: var(--sp-4);
}
/* Form labels override for login — show them */
body.login-page .login-box label,
body.auth-page .login-box label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}
/* Background pattern — subtle warm grain */
body.login-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 25% 25%, rgba(10, 36, 99, 0.04) 0%, transparent 60%),
              radial-gradient(ellipse at 75% 75%, rgba(234, 88, 12, 0.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   END · BUILD-WUS-CRM-V3-003 · 2026-04-13 · Safe + Enhanced
   - Fixes: overflow:visible on .panel, z-index tokens corrected (Bootstrap 3),
     header position removed, modal fill-mode:both→forwards
   - Adds: row selection, presence dots, role badges, pill tab switcher,
     filter strip, notification panel, avatar stacks, login skin
   ═══════════════════════════════════════════════════════════════════════════ */

/* ===================================================================
 * USP UTILITY BAR (sidebar — individual items below profile)
 * =================================================================== */
.usp-util-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 10px;
  margin: 0 4px 4px;
}
.usp-util-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  text-decoration: none;
  flex-shrink: 0;
  transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.usp-util-btn i {
  font-size: 15px;
  color: inherit;
}
.usp-util-btn:hover,
.usp-util-btn:focus {
  color: var(--pop);
  background: var(--accent-dim);
  text-decoration: none;
  outline: none;
}

/* ===================================================================
 * USP PAGE MODAL — Bootstrap 3 modal, near-full-screen with left nav
 * =================================================================== */
#usp-page-modal .modal-dialog,
#usp-page-modal .usp-md-dialog {
  width: 88vw;
  max-width: 88vw;
  margin: 5vh auto;
}
#usp-page-modal .usp-md-content {
  height: 88vh;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  border: none;
  box-shadow: 0 32px 80px rgba(10,36,99,0.25), 0 4px 20px rgba(0,0,0,0.1);
  background: #FAF8F3;
  position: relative;
}
/* Left nav */
.usp-md-nav {
  width: 192px;
  flex-shrink: 0;
  background: #FFFFFF;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0 12px;
}
.usp-md-nav-head {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 0 16px 14px;
}
.usp-md-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.usp-md-nav-item i {
  font-size: 15px;
  color: var(--fg-muted);
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.usp-md-nav-item:hover {
  background: #F5F3EE;
  color: var(--accent);
  text-decoration: none;
}
.usp-md-nav-item:hover i { color: var(--pop); }
.usp-md-nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
  text-decoration: none;
}
.usp-md-nav-item.active i { color: var(--pop); }
.usp-md-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--pop);
  border-radius: 0 2px 2px 0;
}
/* Iframe body */
.usp-md-body {
  flex: 1;
  overflow: hidden;
}
#usp-md-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #FAFAF9;
}
/* Close button */
.usp-md-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: 1px solid var(--border);
  font-size: 18px;
  line-height: 1;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 4px 10px 6px;
  border-radius: var(--r-sm);
  z-index: 2;
  font-family: system-ui, sans-serif;
  transition: color var(--dur-base), background var(--dur-base);
}
.usp-md-close:hover {
  color: var(--fg);
  background: var(--bg-secondary);
  border-color: var(--border-strong);
}

/* ===================================================================
 * HEADER — light elevation shadow to lift above sidebar
 * =================================================================== */
body #header {
  box-shadow: 0 2px 10px rgba(0,0,0,0.07), 0 1px 0 rgba(0,0,0,0.04);
}

/* ===================================================================
 * TODO PAGE — kill yellow / blue panel headers
 * =================================================================== */
body .panel-warning,
body .panel-warning > .panel-heading {
  border-color: var(--border) !important; /* PERFEX_OVERRIDE */
  background: var(--surface) !important; /* PERFEX_OVERRIDE */
  color: var(--fg) !important; /* PERFEX_OVERRIDE */
}
body .panel-warning > .panel-heading {
  background: #1F1F1D !important; /* PERFEX_OVERRIDE */
  color: #FAF8F3 !important; /* PERFEX_OVERRIDE */
  border-color: #1F1F1D !important; /* PERFEX_OVERRIDE */
}
body .panel-success,
body .panel-success > .panel-heading {
  border-color: var(--border) !important; /* PERFEX_OVERRIDE */
  background: var(--surface) !important; /* PERFEX_OVERRIDE */
  color: var(--fg) !important; /* PERFEX_OVERRIDE */
}
body .panel-success > .panel-heading {
  background: #0A2463 !important; /* PERFEX_OVERRIDE */
  color: #FAF8F3 !important; /* PERFEX_OVERRIDE */
  border-color: #0A2463 !important; /* PERFEX_OVERRIDE */
}
body .panel-primary > .panel-heading {
  background: #0A2463 !important; /* PERFEX_OVERRIDE */
  color: #FAF8F3 !important; /* PERFEX_OVERRIDE */
  border-color: #0A2463 !important; /* PERFEX_OVERRIDE */
}
body .panel-info > .panel-heading {
  background: #0A2463 !important; /* PERFEX_OVERRIDE */
  color: #FAF8F3 !important; /* PERFEX_OVERRIDE */
  border-color: #0A2463 !important; /* PERFEX_OVERRIDE */
}
/* Kill raw Bootstrap success/warning bg on any heading element */
body .bg-success,
body .bg-warning,
body .bg-info,
body .bg-primary {
  background-color: var(--surface) !important; /* PERFEX_OVERRIDE */
  color: var(--fg) !important; /* PERFEX_OVERRIDE */
}
/* BUT keep badge colors in header (narrower selector wins) */
body #header .nav.navbar-right .bg-warning { background-color: var(--pop) !important; /* PERFEX_OVERRIDE */ }
body #header .nav.navbar-right .bg-success { background-color: #16a34a !important; /* PERFEX_OVERRIDE */ }


/* ─── 28. INVOICE/ESTIMATE TEMPLATE — DESCRIPTION SPAN OVERRIDE ─────────── */
/* App_items_table.php hardcodes style="color:#424242" on long-description spans.
   Force white on both viewinvoice and viewestimate public pages. */
body.viewinvoice .usp-items-wrap td span[style],
body.viewestimate .usp-items-wrap td span[style],
body.viewinvoice .usp-items-wrap td .description span,
body.viewestimate .usp-items-wrap td .description span {
  color: var(--ink-2) !important;
}

/* ─── 29. ACTION TOOLBAR & DATATABLE CONTROLS — ALIGNMENT FIX ───────────── */
/* Section: BUILD-WUS-CRM-V3 patch 2026-05-27
   Fixes: _buttons row uses Bootstrap floats causing misalignment;
          DataTable Buttons extension rendering unstyled empty boxes;
          DataTable controls row spacing on all pages. */

/* Flex-align the action toolbar on Sales pages (Invoices, Estimates, etc.) */
body ._buttons {
  display: flex !important;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  clear: both;
}
body ._buttons > a.btn,
body ._buttons > button.btn {
  float: none !important;
  margin: 0 !important;
}
body ._buttons > .display-block.pull-right {
  float: none !important;
  display: flex !important;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
body ._buttons > .clearfix {
  display: none !important;
}

/* DataTables control row: flex-align length + filter on same row */
body .dataTables_wrapper > .row + .row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}
body .dataTables_wrapper > .row + .row > [class*="col-"] {
  display: flex;
  align-items: center;
}

/* DataTable Buttons extension — hide buttons that render with no text/icon
   (occurs when Buttons config is absent for a table) */
body .dt-buttons .dt-button:not([title]):empty,
body .dt-buttons .buttons-colvis:empty {
  display: none !important;
}

/* Style the DataTables Buttons that DO render */
body .dt-buttons .dt-button {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
body .dt-buttons .dt-button:hover {
  background: var(--bg-secondary);
  border-color: var(--border);
}

/* Toggle-small-view button: ensure icon shows  */
body .toggle-small-view {
  width: 36px;
  height: 36px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
}
body .toggle-small-view i {
  font-size: 14px;
  line-height: 1;
}

/* DataTable length label: remove "Show" / "entries" text clutter */
body .dataTables_length label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-muted);
  white-space: nowrap;
  margin: 0;
}

/* ─── 31. LEGACY MODULE SUPPRESSION ────────────────────────────────────── */
/* m3_dock and m3_panel modules superseded by pill nav in header */
#m3-dock,
.m3-dock {
  display: none !important;
}
#m3-panel,
.m3-panel,
#m3-panel-backdrop,
.m3-panel-backdrop {
  display: none !important;
}
/* ─── 36. RESPONSIVE TABLES & FILTERS ───────────────────────────────────── */
/*
 * Perfex creates the .table-responsive wrapper after DataTables initializes.
 * Keep the complete data set available at every viewport and make horizontal
 * overflow intentional instead of allowing the page itself to grow wider.
 */
body #wrapper,
body #content,
body .content,
body .panel_s,
body .panel-body,
body .dataTables_wrapper,
body .dataTables_wrapper > .row,
body .dataTables_wrapper > .row > [class*="col-"] {
  min-width: 0;
  max-width: 100%;
}

body .table-responsive,
body .dataTables_wrapper .table-responsive,
body .dataTables_scroll,
body .dataTables_scrollBody,
body .dt-scroll-body {
  width: 100%;
  max-width: 100%;
  overflow-x: auto !important;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hi) transparent;
}

body .table-responsive::-webkit-scrollbar,
body .dataTables_scrollBody::-webkit-scrollbar,
body .dt-scroll-body::-webkit-scrollbar {
  height: 8px;
}
body .table-responsive::-webkit-scrollbar-thumb,
body .dataTables_scrollBody::-webkit-scrollbar-thumb,
body .dt-scroll-body::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: var(--r-pill);
}

/* Neutralize Bootstrap's negative row gutters inside DataTables. */
body .dataTables_wrapper > .row {
  margin-left: 0;
  margin-right: 0;
}

/* Filter bars can wrap on roomy screens without squeezing their controls. */
body .table-filters,
body .filter-area,
body .filter-row,
body .list-filter-strip {
  max-width: 100%;
}
body .table-filters > *,
body .filter-area > *,
body .filter-row > *,
body .list-filter-strip > * {
  min-width: 0;
}

@media (max-width: 991px) {
  /* Keep all DataTable columns reachable; the container handles the scroll. */
  body .dataTables_wrapper .table-responsive > table.dataTable,
  body .dataTables_wrapper .dataTables_scrollHead table.dataTable,
  body .dataTables_wrapper .dataTables_scrollBody table.dataTable {
    min-width: 720px;
    width: 100% !important;
  }

  body .table-responsive > table.table:not(.dataTable):not(.items) {
    min-width: 620px;
  }

  /* DataTables controls: full-width rows, with no Bootstrap floats. */
  body .dataTables_wrapper > .row {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
  }
  body .dataTables_wrapper > .row > [class*="col-"] {
    float: none !important;
    flex: 1 1 280px;
    width: auto !important;
    padding-left: 0;
    padding-right: 0;
  }
  body .dataTables_wrapper .dataTables_length,
  body .dataTables_wrapper .dataTables_filter,
  body .dataTables_wrapper .dataTables_info,
  body .dataTables_wrapper .dataTables_paginate {
    float: none !important;
  }

  body .dataTables_wrapper .dataTables_filter {
    width: 100%;
    margin: 0;
    text-align: left;
  }
  body .dataTables_wrapper .dataTables_filter label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    margin: 0;
  }
  body .dataTables_wrapper .dataTables_filter input,
  body .dataTables_wrapper .dataTables_filter input[type="search"] {
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
    margin: 0 !important;
  }

  body .dataTables_wrapper .dataTables_paginate {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    padding: var(--sp-2) 0;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  body .dataTables_wrapper .dt-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    float: none !important;
    max-width: 100%;
  }

  /* Action toolbars should never push a table beyond the viewport. */
  body ._buttons,
  body ._buttons > .display-block.pull-right {
    max-width: 100%;
  }
}

@media (max-width: 767px) {
  body .content {
    padding: 12px !important;
  }
  body .panel_s > .panel-body,
  body .panel-body {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* A subtle frame makes the scrollable table boundary obvious on touch. */
  body .dataTables_wrapper .table-responsive,
  body .table-responsive:not(.s_table) {
    border: 1px solid var(--divider);
    border-radius: var(--r-md);
    background: var(--surface);
  }

  body .dataTables_wrapper .table-responsive > table.dataTable,
  body .dataTables_wrapper .dataTables_scrollHead table.dataTable,
  body .dataTables_wrapper .dataTables_scrollBody table.dataTable {
    min-width: 680px;
  }

  body .table-responsive > table.table:not(.dataTable):not(.items) {
    min-width: 560px;
  }

  body .table > thead > tr > th,
  body table.dataTable > thead > tr > th,
  body table.dataTable > thead > tr > td,
  body .table > tbody > tr > td,
  body table.dataTable > tbody > tr > td {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Controls stack in reading order and remain finger-sized. */
  body .dataTables_wrapper > .row {
    flex-direction: column;
    align-items: stretch;
  }
  body .dataTables_wrapper > .row > [class*="col-"] {
    flex: 0 0 auto;
    width: 100% !important;
  }
  body .dataTables_wrapper .dataTables_length label,
  body .dataTables_wrapper .dataTables_filter label {
    min-height: 44px;
  }
  body .dataTables_wrapper .dataTables_length select,
  body .dataTables_wrapper .dataTables_filter input,
  body .dataTables_wrapper .dataTables_filter input[type="search"] {
    min-height: 44px;
  }

  /* Filters become one swipeable row instead of a tall, crushed button grid. */
  body .table-filters,
  body .filter-area,
  body .filter-row,
  body .list-filter-strip {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: var(--sp-2);
    width: auto;
    max-width: none;
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: var(--sp-3);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  body .table-filters > *,
  body .filter-area > *,
  body .filter-row > *,
  body .list-filter-strip > *,
  body .table-filters .btn,
  body .filter-area .btn,
  body .filter-row .btn-filter,
  body .list-filter-strip .btn-filter {
    flex: 0 0 auto;
  }
  body .table-filters .btn,
  body .filter-area .btn,
  body .filter-row .btn-filter,
  body .list-filter-strip .btn-filter {
    min-height: 44px;
    padding-left: 14px;
    padding-right: 14px;
  }
  body .filter-row .filter-count,
  body .list-filter-strip .filter-count {
    margin-left: 0;
  }

  body ._buttons {
    align-items: stretch;
  }
  body ._buttons > a.btn,
  body ._buttons > button.btn {
    min-height: 44px;
  }
  body ._buttons > .display-block.pull-right {
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
  }

  body .dataTables_wrapper .dataTables_info {
    padding-top: var(--sp-2);
  }

  /* Perfex line-item tables already become cards; finish that layout. */
  body .s_table.table-responsive {
    overflow: visible !important;
    border: 0;
    background: transparent;
  }
  body .s_table table,
  body .s_table .table.items .main {
    min-width: 0 !important;
    width: 100% !important;
  }
  body .s_table tbody > tr {
    margin-bottom: 12px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--r-md);
    box-shadow: var(--sh-xs);
  }
  body .s_table td {
    min-height: 44px;
    padding: 11px 12px 11px 46% !important;
    border-bottom: 1px solid var(--divider) !important;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  body .s_table td::before {
    top: 11px;
    left: 12px;
    width: 40%;
    padding: 0;
    overflow: hidden;
    color: var(--fg-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    text-transform: uppercase;
  }
  body .s_table td:last-child {
    border-bottom: 0 !important;
  }
  body .s_table input,
  body .s_table textarea,
  body .s_table select,
  body .s_table .bootstrap-select {
    max-width: 100% !important;
    width: 100% !important;
  }
}

@media (max-width: 479px) {
  body .dataTables_wrapper .dataTables_filter label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-1);
  }

  body .dataTables_wrapper .dataTables_paginate .paginate_button {
    min-width: 44px !important;
    height: 44px !important;
    margin: 0 2px;
  }

  body .s_table td {
    padding-left: 44% !important;
  }
  body .s_table td::before {
    width: 36%;
  }
}

/* ─── 37. RESPONSIVE INTERFACE COMPLETION ──────────────────────────────── */
/* Bootstrap 3 / Perfex 3.4.1 completion layer. Keep all table data. */

/* Keep DataTables scroll-head and scroll-body geometry in one container. */
body .dataTables_scroll,
body .dt-scroll {
  max-width: 100%;
}

body .dataTables_scrollHead,
body .dataTables_scrollHeadInner,
body .dt-scroll-head,
body .dt-scroll-headInner {
  max-width: 100%;
}

body .dataTables_scrollHead,
body .dt-scroll-head {
  overflow: hidden !important;
}

@media (max-width: 991px) {
  /* Let column content define table width; the existing wrapper owns scroll. */
  body .dataTables_wrapper .table-responsive > table.dataTable,
  body .dataTables_wrapper .dataTables_scrollHead table.dataTable,
  body .dataTables_wrapper .dataTables_scrollBody table.dataTable,
  body .dataTables_wrapper .dt-scroll-head table.dataTable,
  body .dataTables_wrapper .dt-scroll-body table.dataTable {
    width: max-content !important;
    min-width: max(720px, 100%) !important;
  }

  body .dataTables_wrapper table.dataTable > thead > tr > th,
  body .dataTables_wrapper table.dataTable > tbody > tr > td {
    white-space: nowrap;
  }

  body .dataTables_wrapper table.dataTable .text-wrap,
  body .dataTables_wrapper table.dataTable .description,
  body .dataTables_wrapper table.dataTable .options {
    white-space: normal;
  }

  body .dataTables_scrollHeadInner,
  body .dt-scroll-headInner {
    width: max-content !important;
    min-width: max(720px, 100%) !important;
  }
}

@media (max-width: 767px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  /* Phone controls: prevent iOS focus zoom and preserve 44px targets. */
  body .form-control,
  body input[type="text"].form-control,
  body input[type="email"].form-control,
  body input[type="password"].form-control,
  body input[type="number"].form-control,
  body input[type="tel"].form-control,
  body input[type="url"].form-control,
  body input[type="search"].form-control,
  body textarea.form-control,
  body select.form-control,
  body .dataTables_wrapper .dataTables_length select,
  body .dataTables_wrapper .dataTables_filter input,
  body .bootstrap-select .bs-searchbox input,
  body .select2-drop .select2-search input {
    min-height: 44px !important;
    font-size: 16px !important;
  }

  body textarea.form-control {
    min-height: 96px !important;
  }

  body .bootstrap-select,
  body .select2-container,
  body .select2-container-multi {
    width: 100% !important;
    max-width: 100% !important;
  }

  body .bootstrap-select > .dropdown-toggle.btn,
  body .bootstrap-select .btn.dropdown-toggle,
  body .simple-bootstrap-select .bootstrap-select > .dropdown-toggle.btn,
  body .simple-bootstrap-select .bootstrap-select .btn.dropdown-toggle,
  body .select2-container .select2-choice,
  body .select2-container-multi .select2-choices {
    height: auto !important;
    min-height: 44px !important;
    font-size: 16px !important;
  }

  body .select2-container .select2-choice {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  body .select2-container-multi .select2-choices {
    padding: 5px !important;
  }

  body .control-label,
  body .form-group > label {
    font-size: 13px;
    line-height: 1.35;
  }

  /* All actionable phone controls meet the touch target contract. */
  body .btn:not(.btn-link),
  body .btn-group > .btn,
  body .table-btn,
  body .bulk-actions-btn,
  body .dt-buttons .dt-button,
  body .toggle-small-view,
  body .dataTables_wrapper .dataTables_paginate .paginate_button,
  body .pagination > li > a,
  body .pagination > li > span {
    min-height: 44px !important;
  }

  body .btn.btn-icon,
  body .btn-circle,
  body .toggle-small-view {
    min-width: 44px !important;
  }

  body .dropdown-menu > li > a,
  body .bootstrap-select .dropdown-menu li > a,
  body .select2-results .select2-result-label {
    display: flex;
    align-items: center;
    min-height: 44px;
    white-space: normal;
  }

  /* Current and legacy filters/actions. */
  body ._buttons,
  body .p_buttons,
  body .proposal_buttons {
    display: flex !important;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    max-width: 100%;
  }

  body ._buttons > *,
  body .p_buttons > *,
  body .proposal_buttons > * {
    min-width: 0;
  }

  body ._buttons .btn-group,
  body .p_buttons .btn-group,
  body .proposal_buttons .btn-group,
  body ._filter_data,
  body .invoice-view-buttons,
  body .btn-with-tooltip-group {
    float: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100%;
  }

  body app-filters {
    display: block;
    min-width: 0;
    max-width: 100%;
  }

  body app-filters > .btn-group,
  body app-filters > .btn-group > .btn {
    max-width: 100%;
  }

  body app-filters > .btn-group > .btn {
    min-height: 44px;
  }

  body app-filters .dropdown-menu.width300 {
    width: min(300px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px);
  }

  body .dataTables_wrapper .dataTables_paging {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100% !important;
  }

  body .dataTables_wrapper .dt-page-jump,
  body .dataTables_wrapper .dataTables_paginate,
  body .dataTables_wrapper .pagination {
    float: none !important;
    max-width: 100%;
  }

  body .dataTables_wrapper .pagination {
    display: flex;
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
    margin: 0;
  }

  /* Saved-filter builder: replace fixed desktop rows with a phone stack. */
  body .filters-modal .modal-body [class~="tw-flex"][class~="tw-items-center"][class~="tw-space-x-4"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px;
  }

  body .filters-modal .modal-body [class~="tw-max-w-[170px]"],
  body .filters-modal .modal-body [class~="tw-max-w-[28.875rem]"] {
    width: 100% !important;
    max-width: none !important;
  }

  body .filters-modal .modal-body .row-no-gutters > [class*="col-"] {
    float: none;
    width: 100%;
  }

  body .filters-modal .modal-body .row-no-gutters > [class*="col-"] + [class*="col-"] {
    margin-top: 8px;
  }

  body .filters-modal .modal-body .bootstrap-select,
  body .filters-modal .modal-body .form-control {
    width: 100% !important;
    max-width: none !important;
  }

  /* Tabs remain one reachable row instead of wrapping or widening the page. */
  body .horizontal-scrollable-tabs {
    max-width: 100%;
    overflow: hidden;
  }

  body .horizontal-scrollable-tabs .nav-tabs-horizontal,
  body .nav-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  body .nav-tabs > li {
    float: none;
    flex: 0 0 auto;
  }

  body .nav-tabs > li > a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    white-space: nowrap;
  }

  /* Dialogs fit the dynamic viewport, including inline-width legacy modals. */
  body .modal {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  body .modal-dialog,
  body .modal-dialog.modal-sm,
  body .modal-dialog.modal-lg,
  body .modal-dialog.modal-xl,
  body .modal-dialog.modal-xxl,
  body .modal-dialog.full-screen-modal {
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    height: auto;
    margin: 8px auto !important;
  }

  body .modal-content {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 16px);
    border-radius: 12px;
  }

  body .modal-body {
    min-height: 0;
    padding: 16px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  body .modal-header,
  body .modal-footer {
    flex: 0 0 auto;
    padding: 12px 16px;
  }

  body .modal-header .close {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
  }

  body .modal-footer {
    flex-wrap: wrap;
    gap: 8px;
  }

  body .modal-footer .btn {
    margin: 0 !important;
  }

  /* Complete Perfex's existing line-item card behavior without hiding data. */
  body .show_quantity_as_wrapper {
    text-align: left !important;
  }

  body .s_table table.items input[type="text"],
  body .s_table table.items input[type="number"],
  body .s_table table.items textarea,
  body .s_table table.items select,
  body .s_table table.items .bootstrap-select > .dropdown-toggle.btn {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 44px !important;
    font-size: 16px !important;
  }

  body .s_table table.items td[data-label]::before {
    content: attr(data-label);
  }

  body .s_table table.items td:last-child .btn,
  body .s_table table.items td.enuw-row-action .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

/* Perfex core also cardifies line items on 768-1024px touch devices. */
@media (min-device-width: 768px) and (max-device-width: 1024px) {
  body .s_table table.items input[type="text"],
  body .s_table table.items input[type="number"],
  body .s_table table.items textarea,
  body .s_table table.items select,
  body .s_table table.items .bootstrap-select > .dropdown-toggle.btn {
    min-height: 44px !important;
    font-size: 16px !important;
  }

  body .s_table table.items td[data-label]::before {
    content: attr(data-label);
  }

  body .s_table table.items td:last-child .btn {
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

@media (max-width: 479px) {
  body .modal-footer .btn {
    flex: 1 1 100%;
    width: 100%;
  }

  body .filters-modal .modal-footer > div,
  body .filters-modal .modal-footer [class~="tw-flex"] {
    flex-wrap: wrap;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  body .modal.in .modal-dialog {
    animation: none !important;
    transform: none !important;
  }

  body .table-responsive,
  body .dataTables_scrollBody,
  body .dt-scroll-body,
  body .nav-tabs,
  body .dataTables_paginate {
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  body .table-responsive,
  body .dataTables_wrapper .table-responsive,
  body .form-control,
  body .bootstrap-select > .dropdown-toggle.btn,
  body .select2-container .select2-choice,
  body .modal-content {
    border-color: var(--fg-secondary) !important;
  }

  body .btn:focus-visible,
  body .form-control:focus-visible,
  body .nav-tabs > li > a:focus-visible {
    outline: 3px solid var(--accent) !important;
    outline-offset: 2px;
    box-shadow: none !important;
  }
}

@media (forced-colors: active) {
  body .table-responsive,
  body .dataTables_wrapper .table-responsive,
  body .form-control,
  body .bootstrap-select > .dropdown-toggle.btn,
  body .select2-container .select2-choice,
  body .select2-container-multi .select2-choices,
  body .modal-content,
  body .s_table tbody > tr {
    border: 1px solid CanvasText !important;
    forced-color-adjust: auto;
  }

  body .btn:focus-visible,
  body .form-control:focus-visible,
  body .nav-tabs > li > a:focus-visible {
    outline: 2px solid Highlight !important;
    outline-offset: 2px;
    box-shadow: none !important;
  }

  body .nav-tabs > li.active > a {
    border-bottom-color: Highlight !important;
    color: LinkText !important;
  }
}

[dir="rtl"] body .s_table td::before {
  right: 12px;
  left: auto;
  padding-right: 0;
  padding-left: 10px;
}
