/* 
 * Zenith-inspired Premium Dashboard Design System
 * Pure Vanilla CSS - Clean, Modular, and Responsive
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* Display face reserved for the dashboard greeting lead-in, so the welcome
     line reads as a designed kicker instead of body copy. */
  --font-display: 'Plus Jakarta Sans', 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --app-header-h: 70px;
  
  /* Light Theme Palette (Shadcn Zinc Clean) */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #090d16;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
  --bg-sidebar-active: #2563eb;
  --text-sidebar: #94a3b8;
  --text-sidebar-bright: #ffffff;
  
  --border-subtle: #e2e8f0;
  --border-muted: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: #eff6ff;
  --primary-text: #1e40af;

  --success: #10b981;
  --success-subtle: #ecfdf5;
  --success-text: #065f46;

  --warning: #f59e0b;
  --warning-subtle: #fffbeb;
  --warning-text: #92400e;

  --danger: #ef4444;
  --danger-subtle: #fef2f2;
  --danger-text: #991b1b;

  --info: #06b6d4;
  --info-subtle: #ecfeff;
  --info-text: #155e75;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  
  /* Compatibility aliases for modals & cards */
  --bg-card: var(--bg-surface);
  --border-color: var(--border-subtle);
  --shadow-modal: 0 25px 50px -12px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 23, 42, 0.05);
}

/* Dark Theme Overrides */
[data-theme="dark"] {
  --bg-app: #090d16;
  --bg-surface: #111827;
  --bg-card: #111827;
  --bg-sidebar: #070a10;
  --border-subtle: #1f2937;
  --border-muted: #374151;
  --border-color: #1f2937;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-soft: #6b7280;

  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);

  --primary-subtle: rgba(37, 99, 235, 0.15);
  --primary-text: #93c5fd;

  --success-subtle: rgba(16, 185, 129, 0.15);
  --success-text: #6ee7b7;

  --warning-subtle: rgba(245, 158, 11, 0.15);
  --warning-text: #fcd34d;

  --danger-subtle: rgba(239, 68, 68, 0.15);
  --danger-text: #fca5a5;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

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

html, body {
  /* clip (not hidden) so it still prevents horizontal page scroll but does not
     become a scroll container that would trap sticky table headers. */
  overflow-x: clip;
  max-width: 100vw;
  width: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* App Shell Structure */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
  position: relative;
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(9, 13, 22, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

body.sidebar-open {
  overflow: hidden;
}

/* Sidebar Styling */
.app-sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-close-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

.brand-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.brand-logo-icon {
  display: block;
  width: 100%;
  line-height: 0;
}

.brand-logo-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72px;
  object-fit: contain;
  object-position: left center;
}

.sidebar-nav-container {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

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

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

.sidebar-nav-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

.sidebar-nav-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

.nav-section-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #64748b;
  padding: 10px 10px 4px;
  margin-top: 4px;
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  line-height: 1.3;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.nav-link:hover {
  background-color: var(--bg-sidebar-hover);
  color: var(--text-sidebar-bright);
  transform: translateX(3px);
}

.nav-link:hover svg {
  transform: translateX(2px);
}

.nav-link.active {
  background-color: var(--bg-sidebar-active);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background-color: rgba(255, 255, 255, 0.03);
}

.user-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #ffffff;
  font-size: 0.85rem;
}

/* Main Content Area */
.app-main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  margin-left: 270px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: clip;
}

/* Header Bar */
.app-header {
  height: 70px;
  background-color: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .app-header {
  background-color: rgba(17, 24, 39, 0.88);
}

/* ── Company brand: logo + company name on the header line ────── */
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-right: 14px;
  padding-right: 16px;
  border-right: 1px solid var(--border-subtle);
}

.header-brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  line-height: 1.25;
}

.header-brand-name {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--text-main);
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-brand-sep {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--border-muted);
  flex-shrink: 0;
}

.header-brand-division {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Action Icons */
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background-color: var(--bg-app);
  color: var(--text-main);
  border-color: var(--border-muted);
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  cursor: pointer;
  transition: all 0.15s ease;
}

.user-menu-trigger:hover {
  border-color: var(--border-muted);
  background-color: var(--bg-app);
}

/* Header Notification Dropdown */
.notif-dropdown-container {
  position: relative;
}

.notif-btn {
  position: relative;
}

.notif-badge-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: #ef4444;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
}

.notif-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-width: 90vw;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  display: none;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  animation: notifDropIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.notif-dropdown-menu.active {
  display: flex;
}

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

.notif-dropdown-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
}

.notif-dropdown-body {
  max-height: 380px;
  overflow-y: auto;
}

.notif-item {
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.15s ease;
  text-decoration: none;
  color: inherit;
}

.notif-item:hover {
  background-color: var(--bg-app);
}

.notif-item.unread {
  background-color: rgba(37, 99, 235, 0.04);
}

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

.notif-item-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notif-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notif-item-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 2px;
}

.notif-item-time {
  font-size: 0.7rem;
  color: var(--text-soft);
  margin-top: 4px;
}

.notif-dropdown-footer {
  padding: 10px 16px;
  background-color: var(--bg-app);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}

.notif-dropdown-footer a {
  font-size: 0.82rem;
  color: var(--primary);
  font-weight: 600;
}

/* Dashboard Alerts Popup Banner */
.dash-notification-banner {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.04) 0%, rgba(245, 158, 11, 0.06) 100%);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px -2px rgba(37, 99, 235, 0.08);
}

.dash-notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 12px;
}

.dash-notif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.dash-notif-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dash-notif-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.04);
}

/* Page Body Container */
.page-container {
  padding: 24px clamp(16px, 2.2vw, 30px);
  flex: 1;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}

/* Flash Messages */
.flash-stack {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideDown 0.2s ease-out;
}

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

.alert-success {
  background-color: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert-error {
  background-color: var(--danger-subtle);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Cards & Panels */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  /* clip keeps rounded-corner clipping without becoming a scroll container. */
  overflow: clip;
  margin-bottom: 24px;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.card-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  background-color: rgba(0, 0, 0, 0.01);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* KPI Statistics Grid */
.stats-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)) !important;
  gap: 16px !important;
  margin-bottom: 24px !important;
}

/* Specific Dashboard 5-Card Grid: Perfectly fits in 1 row on Desktop (No lonely/orphaned cards!) */
.dashboard-stats-grid {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 14px !important;
  margin-bottom: 24px !important;
}

.dashboard-stats-grid .stat-card {
  padding: 18px 18px !important;
  min-width: 0 !important;
}

.dashboard-stats-grid .stat-header {
  margin-bottom: 8px !important;
  gap: 8px !important;
}

.dashboard-stats-grid .stat-icon {
  width: 38px !important;
  height: 38px !important;
}

.dashboard-stats-grid .stat-icon svg {
  width: 19px !important;
  height: 19px !important;
}

.dashboard-stats-grid .stat-value {
  font-size: clamp(1.15rem, 1.35vw, 1.55rem) !important;
  margin: 2px 0 4px 0 !important;
}

.dashboard-stats-grid .stat-title {
  font-size: 0.74rem !important;
  line-height: 1.3 !important;
}

.dashboard-stats-grid .stat-desc {
  font-size: 0.78rem !important;
  line-height: 1.35 !important;
  gap: 4px !important;
}

/* Tablet / Medium Screens: Balanced 3 cards on Row 1, 2 cards on Row 2 (No orphaned single cards!) */
@media (max-width: 1120px) and (min-width: 681px) {
  .dashboard-stats-grid {
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 14px !important;
  }
  .dashboard-stats-grid .stat-card:nth-child(1),
  .dashboard-stats-grid .stat-card:nth-child(2),
  .dashboard-stats-grid .stat-card:nth-child(3) {
    grid-column: span 2 !important;
  }
  .dashboard-stats-grid .stat-card:nth-child(4),
  .dashboard-stats-grid .stat-card:nth-child(5) {
    grid-column: span 3 !important;
  }
}

/* Small Tablet / Large Mobile: Revenue card full width banner, remaining in 2x2 grid */
@media (max-width: 680px) and (min-width: 481px) {
  .dashboard-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  .dashboard-stats-grid .stat-card:nth-child(1) {
    grid-column: span 2 !important;
  }
  .dashboard-stats-grid .stat-card:nth-child(2),
  .dashboard-stats-grid .stat-card:nth-child(3),
  .dashboard-stats-grid .stat-card:nth-child(4),
  .dashboard-stats-grid .stat-card:nth-child(5) {
    grid-column: span 1 !important;
  }
}

/* Mobile Screens: Single-column clean stack */
@media (max-width: 480px) {
  .dashboard-stats-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .dashboard-stats-grid .stat-card {
    padding: 14px 14px !important;
  }
}

/* Quick Metrics Strip */
.quick-metrics-strip {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 12px !important;
  padding: 14px 20px !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}

@media (max-width: 900px) and (min-width: 501px) {
  .quick-metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 500px) {
  .quick-metrics-strip {
    grid-template-columns: 1fr !important;
    padding: 12px 14px !important;
  }
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  border-color: rgba(37, 99, 235, 0.25);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #8b5cf6);
  opacity: 0;
  transition: opacity 0.25s ease;
}

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

.stat-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  margin-bottom: 12px !important;
  gap: 12px !important;
}

.stat-title,
.stat-label {
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  color: var(--text-muted) !important;
  line-height: 1.35 !important;
  margin: 0 !important;
  flex: 1;
}

.stat-value {
  font-size: clamp(1.18rem, 1.55vw, 1.62rem) !important;
  font-weight: 800 !important;
  color: var(--text-main);
  letter-spacing: -0.025em !important;
  line-height: 1.25 !important;
  margin: 2px 0 6px 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: block !important;
  width: 100% !important;
}

.stat-desc,
.stat-subtext {
  font-size: 0.82rem !important;
  color: var(--text-muted) !important;
  font-weight: 500 !important;
  line-height: 1.4 !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-wrap: wrap !important;
  margin: 0 !important;
}

.stat-icon {
  width: 44px !important;
  height: 44px !important;
  border-radius: var(--radius-md) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.stat-card:hover .stat-icon {
  transform: scale(1.06);
}

.stat-icon svg {
  width: 22px !important;
  height: 22px !important;
}

.stat-icon.primary { background: var(--primary-subtle); color: var(--primary); }
.stat-icon.success { background: var(--success-subtle); color: var(--success); }
.stat-icon.warning { background: var(--warning-subtle); color: var(--warning); }
.stat-icon.info    { background: var(--info-subtle); color: var(--info); }
.stat-icon.danger  { background: var(--danger-subtle); color: var(--danger); }

/* Support for row cards like in dashboard where children are <div> and <div class="stat-icon"> */
.stat-card:has(> .stat-icon) {
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
}

.stat-card:has(> .stat-icon) > div:first-child {
  flex: 1 1 auto !important;
  min-width: 0 !important;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  line-height: 1.25;
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

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

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-subtle);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-secondary:hover {
  background-color: var(--bg-app);
  border-color: var(--border-muted);
  transform: translateY(-1px);
}

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

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-muted);
}

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

/* Tables */
.table-container {
  width: 100%;
  max-width: 100%;
  /* Wide tables scroll horizontally here. When a table actually fits its
     container, JS adds .table-fit which switches overflow-x to clip so the
     sticky <thead> can pin to the viewport instead of being trapped in a box. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  position: relative;
}

/* Fitting tables need no horizontal scroll, so clip (which is NOT a scroll
   container) lets the frozen header resolve against the viewport. */
.table-container.table-fit {
  overflow-x: clip;
}

.table-container::-webkit-scrollbar {
  height: 5px;
}

.table-container::-webkit-scrollbar-track {
  background: transparent;
}

.table-container::-webkit-scrollbar-thumb {
  background: var(--border-muted);
  border-radius: 4px;
}

/* ── List toolbar (Print / Export) ─────────────────────────────────────
   Rendered by tt_toolbar() inside .card-header, right-aligned. */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.table-toolbar .btn svg {
  flex-shrink: 0;
}

/* ── Export (CSV) dropdown — All / Visible / Fill ─────────────────────
   Rendered by tt_export_dropdown() inside .table-toolbar. */
.export-dropdown {
  position: relative;
  display: inline-flex;
}

.export-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  padding: 5px;
  z-index: 40;
  text-align: left;
}

.export-menu.show {
  display: block;
  animation: actionMenuFadeIn 0.15s ease-out;
}

.export-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  text-decoration: none;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
  text-align: left;
  transition: all 0.12s ease;
}

.export-item:hover {
  background-color: var(--bg-app);
  color: var(--primary);
}

.export-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

[data-theme="dark"] .export-menu {
  background-color: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .export-item:hover {
  background-color: #334155;
  color: #60a5fa;
}

/* ── Bulk selection bar ────────────────────────────────────────────────
   Rendered by tt_bulk_bar() between the toolbar and .table-container. */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin: 0 0 12px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.bulk-bar .bulk-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.bulk-bar .bulk-count strong {
  color: var(--text-main);
  font-weight: 700;
}

.bulk-bar .bulk-action-select {
  max-width: 220px;
}

.bulk-bar [data-bulk-apply]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Selection checkbox column. Kept narrow so it never steals width from the
   data columns, and centered so it reads as a control, not content. */
.data-table th.bulk-check-col,
.data-table td.bulk-check-col {
  width: 38px;
  text-align: center;
  padding-left: 12px;
  padding-right: 4px;
}

.data-table .bulk-check {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary);
  vertical-align: middle;
}

/* Serial number column injected by the app.js serial controller on every
   list table. Narrow, centered and muted so it reads as a counter. */
.data-table th.serial-col,
.data-table td.serial-col {
  width: 46px;
  text-align: center;
  padding-left: 6px;
  padding-right: 6px;
  white-space: nowrap;
  color: var(--text-muted);
  font-weight: 600;
}

/* Report title that only exists in the printed/PDF rendering of a list. */
.table-print-head {
  display: none;
}

.data-table {
  width: 100%;
  min-width: 620px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
  text-align: left;
}

/* Tabs Navigation Utility */
.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
  padding-bottom: 2px;
}

.tabs-nav::-webkit-scrollbar {
  display: none;
}

.tab-link {
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.tab-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.data-table th {
  padding: 13px 18px;
  background-color: var(--bg-app);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* Freeze the header row: it stays pinned to the top of the scroll region
   while long table lists are scrolled. */
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 1px 0 var(--border-subtle);
}

/* Viewport-frozen tables pin the header just below the sticky app header so it
   never hides behind it while the list scrolls. */
.table-container.table-fit .data-table thead th {
  top: var(--app-header-h, 70px);
}

/* Wide (horizontally scrollable) tables cannot resolve position:sticky against
   the viewport because their .table-container is a scroll container. For those,
   app.js builds a fixed .frozen-header-clone mirroring the header row and
   syncs cell widths plus horizontal offset while the real header is out of view. */
.frozen-header-clone {
  position: fixed;
  z-index: 29;
  /* width is set inline by JS to match the visible container */
  box-sizing: border-box;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 1px 0 var(--border-subtle), 0 2px 6px -3px rgba(15, 23, 42, 0.15);
  overflow: hidden;
  pointer-events: none;
}

.frozen-header-clone table {
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  text-align: left;
  table-layout: fixed;
}

.frozen-header-clone th {
  padding: 13px 18px;
  background-color: var(--bg-app);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Keep the frozen-header offset in sync with the shrinking app header. */
@media (max-width: 768px) {
  :root {
    --app-header-h: 62px;
  }
}

@media (max-width: 640px) {
  :root {
    --app-header-h: 58px;
  }
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
  font-size: 0.85rem;
  line-height: 1.35;
  text-align: left;
}

/* --- Table typography: global medium baseline ---------------------------- */
/* List pages sprinkle one-off inline font sizes (0.76rem to 1.3rem) and their
   own cell classes (.lead-name, .meta-stack, .contact-email …) at tiny sizes,
   which is what makes rows read unevenly. Inside a table cell every element
   snaps to the medium baseline; badges stay a compact step smaller. */
.data-table td [style*="font-size"] {
  font-size: inherit !important;
}

.data-table td div,
.data-table td span,
.data-table td a,
.data-table td p,
.data-table td strong,
.data-table td b,
.data-table td label {
  font-size: inherit;
}

.data-table td small {
  font-size: 0.76rem;
  line-height: 1.3;
}

.data-table td .badge,
.data-table td .code-badge {
  font-size: 0.78rem;
}

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

.data-table tbody tr {
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
  background-color: rgba(37, 99, 235, 0.035);
}

/* Three-Dot Action Dropdown System */
.action-dropdown {
  position: relative;
  display: inline-flex;
  justify-content: flex-end;
}

.action-dots-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.action-dots-btn:hover,
.action-dots-btn.active,
.action-dots-btn:focus-visible {
  background-color: var(--bg-app);
  color: var(--primary);
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.action-menu {
  display: none;
  min-width: 190px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  padding: 5px;
  text-align: left;
}

[data-theme="dark"] .action-menu {
  background-color: #1e293b;
  border-color: #334155;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

.action-menu.show {
  display: block !important;
  animation: actionMenuFadeIn 0.15s ease-out;
}

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

.action-item {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  width: 100% !important;
  padding: 8px 12px !important;
  font-size: 0.82rem !important;
  font-weight: 500 !important;
  color: var(--text-main) !important;
  text-decoration: none !important;
  border-radius: var(--radius-sm) !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  transition: all 0.12s ease !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
  text-align: left !important;
}

.action-item:hover {
  background-color: var(--bg-app) !important;
  color: var(--primary) !important;
}

[data-theme="dark"] .action-item:hover {
  background-color: #334155 !important;
  color: #60a5fa !important;
}

.action-item.danger {
  color: #ef4444 !important;
}

.action-item.danger:hover {
  background-color: rgba(239, 68, 68, 0.1) !important;
  color: #dc2626 !important;
}

.action-item svg {
  width: 15px !important;
  height: 15px !important;
  flex-shrink: 0 !important;
  color: currentColor !important;
}

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

[data-theme="dark"] .action-divider {
  background-color: #334155;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.badge-primary { background-color: var(--primary-subtle); color: var(--primary); border: 1px solid rgba(37, 99, 235, 0.2); }
.badge-success { background-color: var(--success-subtle); color: var(--success-text); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-warning { background-color: var(--warning-subtle); color: var(--warning-text); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-danger  { background-color: var(--danger-subtle); color: var(--danger-text); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-info    { background-color: var(--info-subtle); color: var(--info-text); border: 1px solid rgba(6, 182, 212, 0.2); }
.badge-neutral { background-color: var(--bg-app); color: var(--text-muted); border: 1px solid var(--border-subtle); }
.badge-purple  { background-color: rgba(139, 92, 246, 0.1); color: #8b5cf6; border: 1px solid rgba(139, 92, 246, 0.25); }

/* Layout Utilities */
.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}

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

/* Page Intro & Header Actions */
.page-intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-intro-header {
  flex: 1;
  min-width: 260px;
}

.page-intro-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

/* Normalize oversized inline page titles to a medium, consistent size. */
.page-container h1 {
  font-size: 1.35rem !important;
}

.page-intro-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
  line-height: 1.45;
}

.page-intro-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.quick-metrics-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

/* Form Controls */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-label .req {
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.92rem;
  transition: all 0.15s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

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

.form-help {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Filters & Search Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

.search-box {
  position: relative;
  min-width: 280px;
}

.search-box input {
  padding-left: 38px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  background-color: var(--bg-surface);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-subtle);
  transform: scale(0.95);
  transition: transform 0.2s ease;
  overflow: hidden;
}

.modal-backdrop.active .modal-window {
  transform: scale(1);
}

/* Auth Pages (Login) */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 20%, #1e3a8a 0%, #090d16 80%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 14px;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

/* ==========================================================================
   Comprehensive Responsive Media Queries
   Mobile-first adjustments, fluid typography, card padding, and touch UX
   ========================================================================== */

/* Tablet Breakpoint (max-width: 1024px) */
@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: min(290px, 85vw);
    z-index: 50;
  }

  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  }

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

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

  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .grid-2-1 {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)) !important;
    gap: 16px !important;
  }

  .page-container {
    padding: 24px 20px;
  }
}

/* Medium Mobile / Small Tablet Breakpoint (max-width: 768px) */
@media (max-width: 768px) {
  /* Prevent iOS Safari input auto-zoom */
  input, select, textarea, .form-control {
    font-size: 16px !important;
  }

  /* Header adjustments */
  .app-header {
    height: 62px;
    padding: 0 16px;
  }

  .header-brand {
    gap: 10px;
    margin-right: 10px;
    padding-right: 12px;
  }

  .header-brand-division {
    display: none;
  }

  .header-left {
    gap: 10px;
    min-width: 0;
  }

  .header-right {
    gap: 8px;
  }

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

  .user-menu-trigger {
    padding: 3px !important;
    border-radius: 50% !important;
    border-color: transparent !important;
    background: transparent !important;
  }

  .user-menu-trigger:hover {
    background-color: var(--bg-app) !important;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  /* Full-width responsive Notification Dropdown on mobile */
  .notif-dropdown-menu {
    position: fixed !important;
    top: 64px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100vh - 80px) !important;
    z-index: 1000 !important;
  }

  /* Page Intro Banner */
  .page-intro {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
  }

  .page-intro-header {
    width: 100%;
    min-width: 0;
  }

  .page-intro-title {
    font-size: 1.35rem;
  }

  .page-intro-sub {
    font-size: 0.85rem;
  }

  .page-intro-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
  }

  .page-intro-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 9px 12px;
    font-size: 0.84rem;
  }

  /* Toolbars, Search and Filter Bars */
  .toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .toolbar > *,
  .search-box {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .card-body form[method="GET"],
  .page-container form[method="GET"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .card-body form[method="GET"] > div,
  .page-container form[method="GET"] > div {
    width: 100% !important;
    min-width: 0 !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .card-body form[method="GET"] select,
  .card-body form[method="GET"] input,
  .card-body form[method="GET"] .search-box,
  .card-body form[method="GET"] .btn,
  .page-container form[method="GET"] select,
  .page-container form[method="GET"] input,
  .page-container form[method="GET"] .search-box,
  .page-container form[method="GET"] .btn {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Cards & Panels */
  .card {
    margin-bottom: 18px;
  }

  .card-header {
    padding: 14px 18px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .card-header > div:first-child {
    width: 100%;
  }

  .card-header a.btn,
  .card-header button.btn {
    align-self: flex-start;
  }

  .card-body {
    padding: 18px 16px;
  }

  .card-footer {
    padding: 14px 16px;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    text-align: center;
  }

  /* Form Layout */
  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .form-group {
    margin-bottom: 14px;
  }

  /* Notification Alerts Banner */
  .dash-notification-banner {
    padding: 14px 16px;
    margin-bottom: 20px;
  }

  .dash-notification-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .dash-notif-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  /* Quick Metrics Strip */
  .quick-metrics-strip {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    padding: 12px 16px !important;
  }
}

/* Mobile Phone Breakpoint (max-width: 640px) */
@media (max-width: 640px) {
  .page-container {
    padding: 14px 12px;
  }

  .app-header {
    padding: 0 12px;
    height: 58px;
  }

  .header-brand {
    gap: 8px;
    margin-right: 8px;
    padding-right: 10px;
  }

  .header-left {
    gap: 8px;
  }

  .header-right {
    gap: 6px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .mobile-toggle {
    padding: 6px;
  }

  /* KPI Cards */
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    margin-bottom: 18px !important;
  }

  .stat-card {
    padding: 16px 16px !important;
    border-radius: var(--radius-md) !important;
  }

  .stat-value {
    font-size: 1.45rem !important;
  }

  .stat-title {
    font-size: 0.76rem !important;
  }

  .stat-desc,
  .stat-subtext {
    font-size: 0.78rem !important;
  }

  /* Card and Content Sizing */
  .card {
    margin-bottom: 14px;
    border-radius: var(--radius-md);
  }

  .card-header {
    padding: 12px 14px;
    gap: 10px;
  }

  .card-title {
    font-size: 1rem;
  }

  .card-description {
    font-size: 0.8rem;
  }

  .card-body {
    padding: 14px 12px;
  }

  .card-footer {
    padding: 12px;
  }

  /* Tables in cards and views */
  .table-container {
    margin-bottom: 0;
  }

  .data-table th {
    padding: 10px 12px;
    font-size: 0.72rem;
  }

  .data-table td {
    padding: 11px 12px;
    font-size: 0.78rem;
  }

  /* Navigation Tabs */
  .tabs-nav {
    gap: 4px;
    margin-bottom: 16px;
  }

  .tab-link {
    padding: 8px 12px;
    font-size: 0.82rem;
    gap: 6px;
  }

  /* Modals */
  .modal-backdrop {
    padding: 10px;
  }

  .modal-window,
  .modal-box,
  .modal-v2 {
    width: 100% !important;
    max-width: calc(100vw - 20px) !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    border-radius: var(--radius-lg) !important;
  }

  /* Auth / Login */
  .auth-wrapper {
    padding: 16px 12px;
  }

  .auth-card {
    padding: 24px 18px;
    border-radius: var(--radius-lg);
  }

  .auth-header h1 {
    font-size: 1.3rem;
  }

  .auth-header p {
    font-size: 0.82rem;
  }

  /* Alerts */
  .alert {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
}

/* Extra Small Phones (max-width: 380px) */
@media (max-width: 380px) {
  .page-container {
    padding: 10px 8px;
  }

  .app-header {
    padding: 0 8px;
  }

  .header-brand {
    display: none;
  }

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

  .page-intro-actions {
    grid-template-columns: 1fr;
  }

  .quick-metrics-strip {
    grid-template-columns: 1fr !important;
  }

  .stat-card {
    padding: 14px 12px !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   PHASE 14 — Reusable UI partials (includes/ui.php)
   Every class below is consumed by ui_pagination, ui_empty_state, ui_status_badge,
   ui_chip, ui_avatar, ui_error_list, ui_breadcrumbs, ui_filter_bar, ui_tab_nav,
   ui_skeleton_table and ui_spinner. All colours derive from the brand tokens
   declared in :root, so the palette stays consistent with the existing app.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Pagination ───────────────────────────────────────────────────────── */
.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card, #fff);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.pagination-bar--single { justify-content: flex-end; }
.pagination-info { font-size: 0.82rem; color: var(--text-muted); }
.pagination { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.pagination-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card, #fff);
  color: var(--text-main);
  font-size: 0.82rem; font-weight: 600; text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.pagination-btn:hover { background: var(--primary-subtle); color: var(--primary-text); border-color: var(--primary); }
.pagination-btn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-btn.is-disabled { opacity: 0.45; pointer-events: none; }
.pagination-ellipsis { padding: 0 6px; color: var(--text-muted); align-self: center; }

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty-state {
  padding: 60px 24px; text-align: center; color: var(--text-muted);
  background: var(--bg-card, #fff);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
}
.empty-state-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; margin-bottom: 14px;
  border-radius: 50%;
  background: var(--primary-subtle); color: var(--primary);
}
.empty-state-icon svg { width: 26px; height: 26px; }
.empty-state-title { font-size: 1rem; font-weight: 700; color: var(--text-main); margin-bottom: 6px; }
.empty-state-desc { font-size: 0.85rem; max-width: 460px; margin: 0 auto; }

/* ── Skeleton / loading ───────────────────────────────────────────────── */
.skeleton-table { padding: 12px 0; }
.skeleton-row {
  display: grid; gap: 12px; padding: 12px 18px;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  border-bottom: 1px solid var(--border-subtle);
}
.skeleton-line {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-app) 25%, rgba(255,255,255,0.5) 50%, var(--bg-app) 75%);
  background-size: 200% 100%;
  animation: ui-shimmer 1.4s infinite ease-in-out;
}
@keyframes ui-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.spinner-wrap { display: inline-flex; align-items: center; gap: 10px; padding: 12px; color: var(--text-muted); }
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--primary-subtle); border-top-color: var(--primary);
  animation: ui-spin 0.7s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }
.spinner-label { font-size: 0.82rem; }

/* ── Status badge dot ─────────────────────────────────────────────────── */
.badge .badge-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.7; margin-right: 6px; vertical-align: middle;
}

/* ── Chips ───────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; line-height: 1;
  border: 1px solid var(--border-subtle); background: var(--bg-app); color: var(--text-main);
}
.chip-neutral { background: var(--bg-app); }
.chip-primary { background: var(--primary-subtle); color: var(--primary-text); border-color: rgba(37,99,235,0.25); }
.chip-success { background: var(--success-subtle); color: var(--success-text); border-color: rgba(16,185,129,0.25); }
.chip-warning { background: var(--warning-subtle); color: var(--warning-text); border-color: rgba(245,158,11,0.25); }
.chip-danger  { background: var(--danger-subtle);  color: var(--danger-text);  border-color: rgba(239,68,68,0.25); }
.chip-x { color: inherit; text-decoration: none; opacity: 0.6; font-weight: 700; }
.chip-x:hover { opacity: 1; }

/* ── Avatar ──────────────────────────────────────────────────────────── */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 700; letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

/* ── Error list (server-side validation) ─────────────────────────────── */
.error-list {
  background: var(--danger-subtle);
  border: 1px solid rgba(239,68,68,0.25);
  color: var(--danger-text);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.error-list-title { font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.error-list ul { margin: 0; padding-left: 20px; }
.error-list li { font-size: 0.85rem; margin-bottom: 2px; }

/* ── Additional alert variants ───────────────────────────────────────── */
.alert-warning { background: var(--warning-subtle); color: var(--warning-text); border-left: 4px solid var(--warning); }
.alert-info    { background: var(--info-subtle);    color: var(--info-text);    border-left: 4px solid var(--info, #06b6d4); }

/* ── Breadcrumbs ─────────────────────────────────────────────────────── */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 10px; }
.breadcrumb-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-sep { opacity: 0.5; }
.breadcrumb-current { color: var(--text-main); font-weight: 600; }

/* ── Tab navigation ──────────────────────────────────────────────────── */
.tab-nav { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 16px; }
.tab-link {
  padding: 10px 14px; font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab-link:hover { color: var(--primary); }
.tab-link.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: 999px; background: var(--bg-app); color: var(--text-muted);
  font-size: 0.7rem; font-weight: 700;
}
.tab-link.is-active .tab-count { background: var(--primary-subtle); color: var(--primary-text); }

/* ── Filter bar ──────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px 14px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.filter-bar .filter-input, .filter-bar .filter-select { min-width: 160px; flex: 1 1 160px; }
.filter-bar .btn { flex: 0 0 auto; }

/* ── Dark theme adjustments for new classes ─────────────────────────── */
[data-theme="dark"] .pagination-bar { background: #0f172a; }
[data-theme="dark"] .pagination-btn { background: #0f172a; color: #e2e8f0; border-color: #1e293b; }
[data-theme="dark"] .empty-state { background: #0f172a; border-color: #1e293b; }
[data-theme="dark"] .filter-bar { background: #0f172a; border-color: #1e293b; }
[data-theme="dark"] .chip { background: #1e293b; color: #e2e8f0; border-color: #334155; }
[data-theme="dark"] .tab-count { background: #1e293b; color: #cbd5f5; }
[data-theme="dark"] .skeleton-line { background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%); background-size: 200% 100%; animation: ui-shimmer 1.4s infinite ease-in-out; }


/* ── Sidebar collapsible nav groups ─────────────────────────────── */
.nav-group {
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
}

.nav-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #64748b;
  user-select: none;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::marker { content: ""; }

.nav-group > summary:hover {
  color: var(--text-sidebar-bright);
  background-color: rgba(255, 255, 255, 0.03);
}

.nav-group[open] > summary { color: var(--text-sidebar-bright); }

.nav-group-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.7;
}

.nav-group[open] > summary .nav-group-chevron { transform: rotate(90deg); }

.nav-group .sidebar-nav {
  padding-left: 2px;
  margin-bottom: 6px;
}

/* Flat groups (navigation.php 'flat' => true) have no summary row, so the link
   list needs back the vertical spacing the collapsible header used to provide. */
.nav-group-flat .sidebar-nav {
  padding-top: 6px;
}

/* Flat groups carry no [open] attribute, so their entrance needs the same
   animation the collapsible groups get while open. */
.nav-group-flat > .sidebar-nav {
  animation: nav-group-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-group-flat > .sidebar-nav > li {
  animation: nav-item-in 0.32s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.nav-group[open] > .sidebar-nav {
  animation: nav-group-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-group[open] > .sidebar-nav > li {
  animation: nav-item-in 0.32s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.nav-group[open] > .sidebar-nav > li:nth-child(1) { animation-delay: 0.02s; }
.nav-group[open] > .sidebar-nav > li:nth-child(2) { animation-delay: 0.06s; }
.nav-group[open] > .sidebar-nav > li:nth-child(3) { animation-delay: 0.10s; }
.nav-group[open] > .sidebar-nav > li:nth-child(4) { animation-delay: 0.14s; }
.nav-group[open] > .sidebar-nav > li:nth-child(5) { animation-delay: 0.18s; }
.nav-group[open] > .sidebar-nav > li:nth-child(6) { animation-delay: 0.22s; }
.nav-group[open] > .sidebar-nav > li:nth-child(7) { animation-delay: 0.26s; }
.nav-group[open] > .sidebar-nav > li:nth-child(n+8) { animation-delay: 0.30s; }

@keyframes nav-group-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes nav-item-in {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .nav-group[open] > .sidebar-nav,
  .nav-group[open] > .sidebar-nav > li,
  .nav-group-flat > .sidebar-nav,
  .nav-group-flat > .sidebar-nav > li {
    animation: none;
  }

  .nav-link:hover {
    transform: none;
  }
}

.nav-badge {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  line-height: 1.4;
}

.sidebar-user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.74rem;
  color: #94a3b8;
}

.sidebar-signout {
  color: #ef4444;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
}

.sidebar-signout:hover { background-color: rgba(239, 68, 68, 0.12); }

.user-avatar-sm {
  background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
}

/* ============================================================
   Print / Save-as-PDF stylesheet (applies to every module page)
   ============================================================ */
@media print {
  /* Hide all application chrome, controls and transient UI */
  .app-sidebar,
  .app-header,
  .sidebar-backdrop,
  .mobile-toggle,
  .notif-dropdown-container,
  #theme-toggle-btn,
  .user-menu-trigger,
  .flash-stack,
  .tabs-nav,
  .modal-backdrop,
  .modal,
  form[method="GET"],
  .search-box,
  .no-print,
  button,
  .btn,
  a.btn {
    display: none !important;
  }

  /* Only show elements explicitly marked as print-only */
  .print-only {
    display: block !important;
  }

  /* tt_print_head(): report title for the printed/PDF copy of a list. */
  .table-print-head {
    display: block !important;
    margin-bottom: 14px !important;
  }

  .table-print-head h1 {
    margin: 0 0 4px !important;
    font-size: 1.25rem !important;
    color: #000000 !important;
  }

  .table-print-head p {
    margin: 0 !important;
    font-size: 0.8rem !important;
    color: #475569 !important;
  }

  /* Row action menus are interactive chrome. Pages tag their action cell with
     .action-col so the whole column can disappear from the printed list. */
  .action-dropdown,
  .action-menu {
    display: none !important;
  }

  th.action-col,
  td.action-col {
    display: none !important;
  }

  /* Collapse the shell so content uses the full page width */
  html,
  body {
    background: #ffffff !important;
    color: #000000 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  .app-shell {
    display: block !important;
    overflow: visible !important;
  }

  .app-main {
    margin-left: 0 !important;
    max-width: 100% !important;
    overflow: visible !important;
  }

  .page-container {
    padding: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  /* Cards and panels: flat, bordered, never split awkwardly */
  .card,
  .stat-card {
    box-shadow: none !important;
    border: 1px solid #d5d9e0 !important;
    background: #ffffff !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .card-header {
    border-bottom: 1px solid #e2e6ec !important;
    padding: 10px 14px !important;
  }

  /* Keep the KPI grid compact and legible on paper */
  .stats-grid,
  .dashboard-stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
  }

  .stat-card {
    padding: 10px 12px !important;
  }

  .stat-icon {
    display: none !important;
  }

  /* Tables: full width, no horizontal scroll clipping, repeat headers */
  .app-main,
  .card {
    overflow: visible !important;
  }

  .table-container {
    overflow: visible !important;
    max-height: none !important;
    max-width: 100% !important;
    border-radius: 0 !important;
  }

  .data-table thead th {
    position: static !important;
    box-shadow: none !important;
  }

  .frozen-header-clone {
    display: none !important;
  }

  .data-table {
    width: 100% !important;
    min-width: 0 !important;
    font-size: 10.5pt !important;
    border-collapse: collapse !important;
  }

  .data-table thead {
    display: table-header-group;
  }

  .data-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .data-table th,
  .data-table td {
    padding: 6px 9px !important;
    border: 1px solid #d5d9e0 !important;
    color: #000000 !important;
    background: #ffffff !important;
    white-space: normal !important;
  }

  .data-table th {
    background: #f1f3f7 !important;
    font-weight: 700 !important;
  }

  /* Preserve badge semantics without relying on background color printing */
  .badge {
    border: 1px solid #94a3b8 !important;
    background: #ffffff !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Force accurate rendering of any intentionally colored figures */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

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

@page {
  margin: 14mm;
}

/* ============================================================
   Field Visits Filter Card Component (Desktop & Base)
   ============================================================ */
.field-visits-filter-body {
  padding: 12px 18px !important;
  display: flex !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: space-between !important;
}

.field-visits-pills-row {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: wrap !important;
}

.field-visits-filter-label {
  font-size: 0.78rem !important;
  font-weight: 700 !important;
  color: var(--text-muted) !important;
  letter-spacing: 0.04em !important;
  flex-shrink: 0 !important;
}

.field-visits-pills-scroll {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-wrap: wrap !important;
}

.field-visits-pill {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 4px 12px !important;
  border-radius: var(--radius-sm, 6px) !important;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  line-height: 1.35 !important;
  text-decoration: none !important;
  background: var(--bg-surface, #ffffff) !important;
  border: 1px solid var(--border-subtle, #e2e8f0) !important;
  color: var(--text-muted, #64748b) !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  transition: all 0.15s ease !important;
}

.field-visits-pill:hover {
  background: var(--bg-hover, #f8fafc) !important;
  color: var(--text-main, #0f172a) !important;
  border-color: var(--border-muted, #cbd5e1) !important;
}

.field-visits-pill.is-active {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.22) !important;
}

.field-visits-form {
  display: flex !important;
  gap: 8px !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  margin-left: auto !important;
}

.field-visits-search-wrapper input {
  width: 180px !important;
  padding: 5px 10px !important;
  font-size: 0.8rem !important;
  height: 32px !important;
}

.field-visits-dates-wrapper {
  display: flex !important;
  gap: 6px !important;
  align-items: center !important;
}

.field-visits-dates-wrapper input {
  width: auto !important;
  padding: 5px 8px !important;
  font-size: 0.8rem !important;
  height: 32px !important;
}

.field-visits-btns-wrapper {
  display: flex !important;
  gap: 6px !important;
  align-items: center !important;
}

.field-visits-btns-wrapper .btn {
  padding: 5px 12px !important;
  font-size: 0.78rem !important;
  height: 32px !important;
}

/* ============================================================
   Mobile layout alignments (Page Headers, Toolbars, Filter Bars)
   ============================================================ */
@media screen and (max-width: 768px) {
  /* Full-width header blocks: stack heading and action buttons */
  .page-container > div[style*="justify-content: space-between"],
  .leads-hero,
  .clients-hero,
  .tickets-page__hero {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  /* Slightly smaller page title on mobile so headings wrap cleanly */
  .page-container > div[style*="justify-content: space-between"] h1,
  .leads-hero h1,
  .clients-hero h1,
  .tickets-page__hero h1 {
    font-size: 1.35rem !important;
    line-height: 1.25 !important;
  }

  /* Universal page-header action buttons: clean 2-up responsive layout */
  .page-header-actions,
  .leads-hero__actions,
  .clients-hero__actions,
  .tickets-page__hero .hero-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
  }

  /* Flatten the shared toolbar so Print / Export / Bulk Import join the same 2-column grid */
  .page-header-actions .table-toolbar,
  .leads-hero__actions .table-toolbar,
  .clients-hero__actions .table-toolbar,
  .tickets-page__hero .hero-actions .table-toolbar {
    display: contents !important;
  }

  /* Every secondary button and export dropdown shares 50% width cleanly */
  .page-header-actions .btn,
  .page-header-actions .export-dropdown,
  .leads-hero__actions .btn,
  .leads-hero__actions .export-dropdown,
  .clients-hero__actions .btn,
  .clients-hero__actions .export-dropdown,
  .tickets-page__hero .hero-actions .btn,
  .tickets-page__hero .hero-actions .export-dropdown {
    flex: 1 1 calc(50% - 4px) !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    box-sizing: border-box !important;
  }

  .page-header-actions .export-dropdown .btn,
  .leads-hero__actions .export-dropdown .btn,
  .clients-hero__actions .export-dropdown .btn,
  .tickets-page__hero .hero-actions .export-dropdown .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Primary CTA spans 100% on top */
  .page-header-actions .btn-primary,
  .leads-hero__actions .btn-primary,
  .clients-hero__actions .btn-primary,
  .tickets-page__hero .hero-actions .btn-primary {
    flex: 1 1 100% !important;
    order: -1 !important;
    padding: 10px 16px !important;
    font-weight: 700 !important;
    width: 100% !important;
  }

  /* Two-up KPI cards on phones for a tighter, less sparse grid */
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .stat-card {
    padding: 14px !important;
  }

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

  /* Field Visits filter card mobile view */
  .field-visits-filter-body {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 12px 14px !important;
  }

  .field-visits-pills-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .field-visits-filter-label {
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    color: var(--text-muted) !important;
  }

  .field-visits-pills-scroll {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    width: 100% !important;
    gap: 6px !important;
    padding-bottom: 3px !important;
    order: 0 !important;
  }

  .field-visits-pills-scroll::-webkit-scrollbar {
    display: none !important;
  }

  .field-visits-pill {
    flex: 0 0 auto !important;
    padding: 6px 14px !important;
    font-size: 0.8rem !important;
    order: 0 !important;
    width: auto !important;
    white-space: nowrap !important;
  }

  .field-visits-form {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    margin-left: 0 !important;
    gap: 8px !important;
  }

  .field-visits-search-wrapper {
    width: 100% !important;
  }

  .field-visits-search-wrapper input {
    width: 100% !important;
    height: 38px !important;
    font-size: 0.88rem !important;
    box-sizing: border-box !important;
  }

  .field-visits-dates-wrapper {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .field-visits-dates-wrapper input {
    flex: 1 1 calc(50% - 4px) !important;
    min-width: 0 !important;
    width: 100% !important;
    height: 38px !important;
    font-size: 0.85rem !important;
    box-sizing: border-box !important;
  }

  .field-visits-btns-wrapper {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .field-visits-btns-wrapper .btn,
  .field-visits-apply-btn,
  .field-visits-clear-btn {
    flex: 1 1 0 !important;
    height: 38px !important;
    font-size: 0.86rem !important;
    justify-content: center !important;
    align-items: center !important;
    box-sizing: border-box !important;
  }

  /* Incentives quick action (Generate from warranties) */
  .incentive-quick-action {
    width: 100% !important;
    margin-bottom: 18px !important;
  }

  .incentive-quick-action form {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .incentive-quick-action form label {
    width: 100% !important;
    font-size: 0.82rem !important;
    line-height: 1.35 !important;
  }

  .incentive-quick-action form button {
    width: 100% !important;
    justify-content: center !important;
    padding: 10px 14px !important;
    font-size: 0.84rem !important;
  }

  /* Filters stack cleanly full width across list pages */
  .card-header form[method="GET"],
  .card-body form[method="GET"] {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    margin-left: 0 !important;
  }

  .card-header form[method="GET"] select,
  .card-header form[method="GET"] input,
  .card-header form[method="GET"] .search-box,
  .card-body form[method="GET"] select,
  .card-body form[method="GET"] input,
  .card-body form[method="GET"] .search-box {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .card-header form[method="GET"] .btn,
  .card-body form[method="GET"] .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Apply / Reset span the whole filter grid and split it evenly, instead of
     hugging a single column under the fields. */
  .filter-grid .filter-actions {
    grid-column: 1 / -1 !important;
    flex-direction: row !important;
    align-items: stretch;
    gap: 8px !important;
  }

  .filter-grid .filter-actions .btn {
    flex: 1 1 0;
    width: auto !important;
    min-width: 0;
    justify-content: center !important;
  }
}

/* ============================================================
   Mobile refinements — list-page controls (whole ERP)
   Additive only: pagination bar, bulk-action bar, and the table
   width floor are tuned for phones without touching the shared
   sticky/clone table-header system used by wide scrolling tables.
   ============================================================ */
@media screen and (max-width: 640px) {
  /* Pagination: stack so the count text and page buttons never collide */
  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .pagination-bar--single {
    justify-content: center;
  }

  .pagination-info {
    text-align: center;
    font-size: 0.78rem;
  }

  /* Keep page buttons on one scrollable strip instead of wrapping tall */
  .pagination {
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .pagination::-webkit-scrollbar {
    display: none;
  }

  .pagination-btn {
    min-width: 36px;
    height: 36px;
    flex: 0 0 auto;
  }

  /* Bulk-action bar: full-width select + comfortable tap targets */
  .bulk-bar {
    gap: 8px;
    padding: 10px 12px;
  }

  .bulk-bar .bulk-count {
    flex: 1 1 100%;
  }

  .bulk-bar .bulk-action-select {
    max-width: none;
    flex: 1 1 140px;
  }

  .bulk-bar [data-bulk-apply],
  .bulk-bar .bulk-clear,
  .bulk-bar .btn {
    flex: 0 0 auto;
  }

  /* Let genuinely small tables fit the phone width instead of scrolling */
  .data-table {
    min-width: 0;
  }
}

/* ============================================================
   Invoice Sheet Module Responsiveness
   ============================================================ */
.invoice-wrapper {
  max-width: 960px;
  margin: 0 auto;
}

.invoice-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.pipeline-scroll-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

.pipeline-stepper {
  display: flex;
  align-items: flex-start;
  min-width: 520px;
}

.invoice-sheet-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.invoice-sheet-body {
  padding: 36px 32px;
}

.invoice-header-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 20px;
}

.invoice-client-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.invoice-info-block {
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.invoice-info-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.invoice-items-desktop {
  display: block;
}

.invoice-items-mobile,
.invoice-totals-mobile {
  display: none;
}

.mobile-line-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.mobile-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.mobile-item-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.35;
}

.mobile-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.mobile-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px dashed var(--border-subtle);
  margin-top: 2px;
}

.mobile-item-qtyprice {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.mobile-item-total {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.mobile-totals-box {
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.mobile-total-row.grand-total {
  border-top: 2px solid var(--border-subtle);
  padding-top: 10px;
  margin-top: 4px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.mobile-total-row.grand-total .val {
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 800;
}

@media (max-width: 768px) {
  .invoice-sheet-body {
    padding: 18px 14px;
  }
  .invoice-client-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .invoice-header-grid {
    flex-direction: column;
    gap: 16px;
  }
  .invoice-header-meta {
    text-align: left !important;
  }
}

@media (max-width: 640px) {
  .invoice-items-desktop {
    display: none !important;
  }
  .invoice-items-mobile {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
  }
  .invoice-totals-mobile {
    display: block !important;
    margin-bottom: 24px;
  }
}

/* ==========================================================================
   Account Editor — shared shell for user-add.php / user-edit.php
   Two-column layout: form sections left, live account summary rail right.
   ========================================================================== */

/* The section stepper and the summary rail are both sticky, which only works
   while no ancestor turns into a scroll container. The global chrome uses
   `overflow-x: hidden` to clip sideways overflow, and `overflow-x: clip` guards
   the same axis without creating a scrollport. Scoped to this shell so no other
   page's layout changes. */
html:has(.acct-page),
body:has(.acct-page),
body:has(.acct-page) .app-shell,
body:has(.acct-page) .app-main {
  overflow-x: clip;
}

.acct-page {
  /* Fluid: never wider than the space the fixed sidebar leaves behind.
     A `vw` unit here would ignore `.app-main`'s 270px offset and push the
     right column outside `overflow-x: clip`, which clips instead of scrolling. */
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding-bottom: 28px;
  /* Sticky offsets must clear the 70px app header. */
  --acct-sticky-top: 82px;
  --acct-scroll-margin: 132px;
}

/* The add wizard has no summary rail, so its shell narrows to a single-column
   reading measure instead of the width the two-column editor needs. */
.acct-page-wizard {
  max-width: 960px;
}

.acct-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.acct-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.acct-eyebrow-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border-muted);
}

.acct-title {
  font-size: clamp(1.35rem, 2vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-top: 8px;
}

.acct-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 4px;
  max-width: 620px;
}

.acct-layout {
  display: grid;
  /* Fractional 73/27 split instead of a fixed rail: the ratio holds at every
     container width and `minmax(0, …)` lets both columns shrink below their
     content size, so a long value can never force sideways overflow. */
  grid-template-columns: minmax(0, 73fr) minmax(0, 27fr);
  gap: 24px;
  align-items: start;
}

/* The add wizard has no summary rail, so its single column fills the shell. */
.acct-layout-single {
  grid-template-columns: minmax(0, 1fr);
}

.acct-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.acct-side {
  position: sticky;
  top: var(--acct-sticky-top, 82px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* --- Section stepper ------------------------------------------------------- */
.acct-stepper {
  position: sticky;
  top: var(--acct-sticky-top, 82px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  margin-bottom: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  scrollbar-width: none;
}

.acct-stepper::-webkit-scrollbar {
  display: none;
}

.acct-stepper-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-muted);
  white-space: nowrap;
  text-decoration: none;
  /* Steps are real <button>s on the wizard, so the UA button chrome (border,
     grey background, fixed height) has to be reset for the pill to line up
     with the anchor-styled stepper on user-edit.php. */
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.acct-stepper-item:hover {
  background: var(--bg-app);
  color: var(--text-main);
}

/* Steps beyond the furthest one reached are not navigable yet. */
.acct-stepper-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.acct-stepper-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acct-stepper-item .acct-stepper-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  border-radius: 50%;
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--text-soft);
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  transition: all 0.15s ease;
}

.acct-stepper-item.is-current {
  background: var(--primary-subtle);
  color: var(--primary-text);
}

.acct-stepper-item.is-current .acct-stepper-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.acct-stepper-item.is-done .acct-stepper-num {
  background: var(--success-subtle);
  border-color: rgba(16, 185, 129, 0.35);
  color: var(--success-text);
}

.acct-stepper-item.is-done .acct-stepper-digit {
  display: none;
}

.acct-stepper-item.is-done .acct-stepper-num svg {
  display: block;
}

.acct-stepper-item .acct-stepper-num svg {
  display: none;
}

/* --- Section card ---------------------------------------------------------- */
.acct-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  scroll-margin-top: var(--acct-scroll-margin, 132px);
}

.acct-card-head {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 11px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.045), transparent);
}

.acct-optional {
  flex: 0 0 auto;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 2px 8px;
}

/* Three-up field row (city / state / zipcode). */
.form-grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

/* Required-field marker, usable outside .form-label too. */
.req {
  color: var(--danger);
}

/* Numbered section badge. `acct-step` is the spelling user-edit.php uses and
   `acct-step-badge` the one the wizard uses; both share this rule. */
.acct-step,
.acct-step-badge {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-subtle);
}

.acct-card-head h2 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.acct-card-head p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.acct-card-body {
  padding: 16px;
}

.acct-card-body > .form-grid:first-child,
.acct-card-body > .form-group:first-child {
  margin-top: 0;
}

/* --- Account type picker --------------------------------------------------- */
.acct-type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* Lone options (Direct Customers) fill the row as one horizontal card and
   trios (Partner Network) stay on a single row, so no card floats stranded. */
.acct-type-grid.is-single {
  grid-template-columns: 1fr;
}

.acct-type-grid.is-single .acct-type {
  align-items: center;
}

.acct-type-grid.is-single .acct-type-body {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 10px;
}

.acct-type-grid.is-single .acct-type-body small,
.acct-type-grid.is-single .acct-type-flag {
  margin-top: 0;
}

.acct-type-grid.is-single .acct-type-mark {
  top: 50%;
  transform: translateY(-50%);
}

.acct-type-grid.is-trio {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.acct-type {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 68px;
  padding: 10px 30px 10px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.acct-type:hover {
  border-color: var(--border-muted);
  background: var(--bg-app);
}

.acct-type:has(input:focus-visible) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.acct-type input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.acct-type-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tint-bg, var(--bg-app));
  color: var(--tint, var(--text-muted));
  transition: background 0.15s ease, color 0.15s ease;
}

.acct-type-body {
  min-width: 0;
}

.acct-type-body strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.acct-type-body small {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 1px;
}

.acct-type-flag {
  display: inline-block;
  margin-top: 5px;
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--warning-text);
  background: var(--warning-subtle);
  border-radius: 999px;
  padding: 1px 7px;
}

.acct-type-mark {
  position: absolute;
  top: 10px;
  right: 11px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.15s ease;
}

.acct-type:hover .acct-type-icon {
  transform: scale(1.06);
}

.acct-type.is-active {
  border-color: var(--tint, var(--primary));
  background: var(--tint-bg, var(--primary-subtle));
  box-shadow: 0 0 0 3px var(--tint-ring, rgba(37, 99, 235, 0.12));
}

.acct-type.is-active .acct-type-icon {
  background: var(--tint, var(--primary));
  color: #fff;
}

.acct-type.is-active .acct-type-mark {
  background: var(--tint, var(--primary));
  border-color: var(--tint, var(--primary));
  color: #fff;
}

/* --- Type picker grouping -------------------------------------------------- */
.acct-type-group + .acct-type-group {
  margin-top: 12px;
}

.acct-type-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.acct-type-group-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* --- Two-up field row ------------------------------------------------------ */
.acct-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.acct-split > .form-group {
  margin-bottom: 0;
}

/* --- Toggle switch (status on/off) ----------------------------------------- */
.acct-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.acct-toggle:hover {
  border-color: var(--border-muted);
}

.acct-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.acct-toggle:has(input:focus-visible) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.acct-toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.15s ease;
}

[data-theme="dark"] .acct-toggle-track {
  background: #475569;
}

.acct-toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.acct-toggle:has(input:checked) .acct-toggle-track {
  background: var(--success);
}

.acct-toggle:has(input:checked) .acct-toggle-track::after {
  transform: translateX(18px);
}

.acct-toggle-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.acct-toggle:has(input:checked) .acct-toggle-text {
  color: var(--text-main);
}

/* --- Password field with inline reveal ------------------------------------- */
.acct-pass {
  position: relative;
}

.acct-pass .form-control {
  padding-right: 66px;
}

.acct-pass-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: var(--bg-app);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.acct-pass-btn:hover {
  color: var(--primary);
  background: var(--primary-subtle);
}

/* --- Password strength meter ------------------------------------------------ */
.acct-strength {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.acct-strength-seg {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--border-subtle);
  transition: background 0.2s ease;
}

.acct-strength[data-score="1"] .acct-strength-seg:nth-child(1) { background: var(--danger); }
.acct-strength[data-score="2"] .acct-strength-seg:nth-child(-n+2) { background: var(--warning); }
.acct-strength[data-score="3"] .acct-strength-seg:nth-child(-n+3) { background: #65a30d; }
.acct-strength[data-score="4"] .acct-strength-seg { background: var(--success); }

.acct-strength-text {
  display: block;
  margin-top: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.acct-strength[data-score="1"] ~ .acct-strength-text { color: var(--danger-text); }
.acct-strength[data-score="2"] ~ .acct-strength-text { color: var(--warning-text); }
.acct-strength[data-score="3"] ~ .acct-strength-text { color: var(--success-text); }
.acct-strength[data-score="4"] ~ .acct-strength-text { color: var(--success-text); }

/* --- Field rhythm ----------------------------------------------------------- */
/* Replaces the per-row inline margin-top used across the account editor. */
.acct-fields > * + * {
  margin-top: 11px;
}

.acct-fields .form-group {
  margin-bottom: 0;
}

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

.form-control:hover:not(:focus):not(:disabled) {
  border-color: var(--border-muted);
}

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

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

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

/* --- Permission matrix ----------------------------------------------------- */
.acct-perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 7px;
}

.acct-perm {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  row-gap: 4px;
  padding: 9px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

/* Module name owns the flexible column so long labels wrap in place
   instead of pushing the "role default" pill off the card edge. */
.acct-perm > span:not(.acct-perm-box):not(.acct-perm-default) {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  line-height: 1.25;
}

.acct-perm:hover {
  border-color: var(--border-muted);
  color: var(--text-main);
}

.acct-perm input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.acct-perm:has(input:checked) {
  border-color: rgba(37, 99, 235, 0.45);
  background: var(--primary-subtle);
  color: var(--primary-text);
}

.acct-perm .acct-perm-box {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 5px;
  border: 1.5px solid var(--border-muted);
  color: transparent;
  transition: all 0.15s ease;
}

.acct-perm:has(input:checked) .acct-perm-box {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.acct-perm:has(input:checked) .acct-perm-box svg {
  display: block;
}

.acct-perm .acct-perm-box svg {
  display: none;
}

/* The custom box replaces the native control entirely. */
.acct-perm:has(.acct-perm-box) input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.acct-perm:has(input:focus-visible) {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.acct-perm-default {
  grid-column: 2;
  grid-row: 2;
  justify-self: start;
  align-self: center;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 1px 7px;
}

.acct-perm:has(input:checked) .acct-perm-default {
  color: var(--primary-text);
  background: var(--bg-surface);
  border-color: rgba(37, 99, 235, 0.25);
}

.acct-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary-text);
  background: var(--primary-subtle);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 999px;
  padding: 2px 9px;
}

/* --- Live summary rail ----------------------------------------------------- */
.acct-summary {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.acct-summary-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(124, 58, 237, 0.06));
}

.acct-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.acct-summary-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  overflow-wrap: anywhere;
}

.acct-summary-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.acct-summary-body {
  padding: 12px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.acct-summary-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
}

.acct-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.79rem;
}

.acct-row dt {
  color: var(--text-muted);
  flex: 0 0 auto;
}

.acct-row dd {
  color: var(--text-main);
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.acct-chain {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed var(--border-subtle);
  margin-top: 2px;
}

.acct-chain-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.acct-chain-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.79rem;
  color: var(--text-muted);
}

.acct-chain-step.is-self {
  color: var(--text-main);
  font-weight: 600;
}

.acct-chain-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-muted);
  flex: 0 0 auto;
}

.acct-chain-step.is-self .acct-chain-bullet {
  background: var(--primary);
}

.acct-summary-actions {
  padding: 12px 15px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.015);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

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

.acct-note {
  font-size: 0.71rem;
  line-height: 1.45;
  color: var(--text-soft);
}

/* --- Stacked field help text ------------------------------------------------ */
.acct-help {
  display: block;
  margin-top: 5px;
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--text-muted);
}

/* --- Wizard step panels ----------------------------------------------------- */
/* Every panel stays in the DOM so field values are never lost between steps;
   only the active one is laid out. The class is deliberately `acct-step-panel`
   and not `acct-step`, which is the numbered badge user-edit.php relies on. */
.acct-step-panel {
  display: none;
}

.acct-step-panel.is-active {
  display: block;
  animation: acct-step-in 0.18s ease-out;
}

@keyframes acct-step-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* --- Step progress rail under the page header ------------------------------- */
.acct-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--border-subtle);
  overflow: hidden;
  margin: -2px 0 14px;
}

.acct-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  transition: width 0.25s ease;
}

/* --- Login ID availability chip --------------------------------------------- */
.acct-check {
  position: relative;
}

.acct-check .form-control {
  padding-right: 104px;
}

.acct-check-state {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 4px;
  max-width: 92px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.acct-check-state:not(:empty) {
  display: inline-flex;
}

.acct-check-state.is-ok {
  color: var(--success-text);
  background: var(--success-subtle);
}

.acct-check-state.is-bad {
  color: var(--danger-text);
  background: var(--danger-subtle);
}

.acct-check-state.is-pending {
  color: var(--text-muted);
  background: var(--bg-app);
}

/* --- Per-field validation note ---------------------------------------------- */
.acct-field-error {
  display: block;
  margin-top: 5px;
  font-size: 0.73rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--danger-text);
}

/* --- Review step ------------------------------------------------------------- */
.acct-review {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.acct-review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 12px;
}

.acct-review-card {
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-app);
  padding: 12px 14px;
}

.acct-review-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.acct-review-card-head h3 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-soft);
  min-width: 0;
  overflow-wrap: anywhere;
}

.acct-review-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
}

.acct-review-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.78rem;
}

.acct-review-row dt {
  flex: 0 0 auto;
  color: var(--text-muted);
}

.acct-review-row dd {
  min-width: 0;
  text-align: right;
  font-weight: 600;
  color: var(--text-main);
  overflow-wrap: anywhere;
}

.acct-confirm {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--primary-subtle);
  font-size: 0.8rem;
  color: var(--text-main);
  cursor: pointer;
}

.acct-confirm input {
  flex: 0 0 auto;
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* --- Wizard footer navigation ------------------------------------------------ */
/* Sticky (not fixed): the bar keeps its own slot in the flow, so it can never
   cover the last card, and the page keeps a single scrollbar. */
.acct-wizard-nav {
  position: sticky;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 12px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 -8px 22px -14px rgba(15, 23, 42, 0.35);
}

.acct-wizard-nav-spacer {
  flex: 1 1 auto;
  min-width: 0;
}

.acct-wizard-hint {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Temporary notice used by saveDraft()/submitForm() validation feedback. */
.acct-wizard-hint.is-flash {
  color: var(--danger-text);
}

.acct-wizard-nav .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* --- Mobile docked actions --------------------------------------------------- */
/* The rail becomes static below 1080px, so the submit control is docked to the
   bottom of the viewport instead of leaving it a long scroll away. */
.acct-dock {
  display: none;
}

@media (max-width: 1080px) {
  .acct-dock {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 -6px 18px -8px rgba(15, 23, 42, 0.22);
  }

  .acct-dock-progress {
    flex: 1;
    min-width: 0;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .acct-dock .btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .acct-summary-actions {
    display: none;
  }

  .acct-page {
    padding-bottom: 88px;
  }
}

[data-theme="dark"] .acct-summary-actions {
  background: rgba(255, 255, 255, 0.015);
}

/* --- Reduced motion --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .acct-stepper,
  .acct-progress-bar,
  .acct-type,
  .acct-type-icon,
  .acct-type-mark,
  .acct-perm {
    transition: none;
    scroll-behavior: auto;
  }

  .acct-step-panel.is-active {
    animation: none;
  }
}

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 1080px) {
  .acct-page {
    --acct-sticky-top: 76px;
    --acct-scroll-margin: 126px;
  }
  .acct-layout {
    grid-template-columns: 1fr;
  }
  .acct-side {
    position: static;
  }
  .acct-review-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .acct-page {
    --acct-sticky-top: 66px;
    --acct-scroll-margin: 116px;
  }
  /* Wrapping beats a sideways scroller here: every step stays reachable. */
  .acct-stepper {
    flex-wrap: wrap;
    border-radius: var(--radius-lg);
    overflow: visible;
  }
  .acct-stepper-item {
    font-size: 0.72rem;
  }
  .acct-type-grid,
  .acct-type-grid.is-trio {
    grid-template-columns: 1fr;
  }
  .acct-card-body,
  .acct-summary-body {
    padding: 14px;
  }
  .acct-toggle {
    width: 100%;
    justify-content: center;
  }
  .acct-wizard-nav {
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-radius: var(--radius-md);
  }
  .acct-wizard-hint {
    /* Hint shares the row with the spacer instead of squeezing the buttons. */
    order: -1;
    width: 100%;
    white-space: normal;
  }
  .acct-wizard-nav-spacer {
    display: none;
  }
  .acct-wizard-nav .btn {
    flex: 1 1 auto;
  }
}

/* ==========================================================================
   DASHBOARD — premium KPI cards, revenue chart, mini KPIs, network table
   Every colour comes from the inline --tint / --tint-bg / --tint-ring tokens
   that ui_tint_style() writes in includes/ui.php, so a card never needs a
   per-metric class and the palette stays in one place (the PHP definition).
   ========================================================================== */

/* --- Dashboard Hero Banner & Greeting (page-intro) --------------------- */
.dashboard-intro.dashboard-hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px -4px rgba(15, 23, 42, 0.05), 0 1px 3px 0 rgba(15, 23, 42, 0.03);
  display: block;
}

/* Top continuous gradient hairline */
.dashboard-intro.dashboard-hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb 0%, #7c3aed 35%, #06b6d4 70%, #10b981 100%);
  z-index: 3;
}

/* Subtle corner ambient mesh light */
.dashboard-intro.dashboard-hero-card::after {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.06) 0%, rgba(124, 58, 237, 0.03) 45%, transparent 70%);
  pointer-events: none;
  z-index: 1;
}

[data-theme="dark"] .dashboard-intro.dashboard-hero-card {
  background: #111827;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 24px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .dashboard-intro.dashboard-hero-card::after {
  background: radial-gradient(circle, rgba(37, 99, 235, 0.12) 0%, rgba(124, 58, 237, 0.05) 50%, transparent 70%);
}

.dashboard-hero-body {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  padding: 22px 26px;
  flex-wrap: wrap;
}

.dashboard-hero-content {
  flex: 1 1 480px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Meta Chips Row (Date, Live status, Role) */
.hero-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.73rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.hero-date-pill {
  background: rgba(37, 99, 235, 0.06);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.hero-date-pill svg {
  color: #2563eb;
  flex-shrink: 0;
}

/* Full date on desktop; short date only on small screens (see @media max-width:768px) */
.hero-date-full {
  display: inline;
}

.hero-date-short {
  display: none;
}

[data-theme="dark"] .hero-date-pill {
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.25);
}

.status-pill--clear {
  background: rgba(16, 185, 129, 0.08);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.22);
}

[data-theme="dark"] .status-pill--clear {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}

.status-pill--pending {
  background: rgba(245, 158, 11, 0.08);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

[data-theme="dark"] .status-pill--pending {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.3);
}

.hero-role-pill {
  background: rgba(100, 116, 139, 0.07);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-clear {
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.dot-pending {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

.pulse-dot-anim {
  animation: pulseDot 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.9); }
}

/* Title & typography */
/* Eyebrow Label */
.hero-eyebrow-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2563eb;
  margin-bottom: 4px;
  display: inline-block;
  line-height: 1.2;
}

[data-theme="dark"] .hero-eyebrow-label {
  color: #60a5fa;
}

/* Title & typography - Corporate SaaS */
.dashboard-intro .dashboard-hero-title,
.dashboard-intro .page-intro-title {
  font-family: var(--font-sans) !important;
  font-size: 24px !important;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 0 0 4px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 6px;
}

.dashboard-intro .hero-lead,
.dashboard-intro .intro-lead {
  font-family: var(--font-sans) !important;
  font-size: inherit;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: #0f172a !important;
  display: inline;
  vertical-align: baseline;
}

[data-theme="dark"] .dashboard-intro .hero-lead,
[data-theme="dark"] .dashboard-intro .intro-lead {
  color: #f1f5f9 !important;
}

.dashboard-intro .hero-company,
.dashboard-intro .intro-company {
  font-family: var(--font-sans) !important;
  font-size: inherit;
  font-weight: 700;
  color: #2563eb !important;
  background: none !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  -webkit-text-fill-color: initial !important;
  display: inline;
  vertical-align: baseline;
  translate: none !important;
  filter: none !important;
  transition: none !important;
}

[data-theme="dark"] .dashboard-intro .hero-company,
[data-theme="dark"] .dashboard-intro .intro-company {
  color: #60a5fa !important;
  background: none !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  -webkit-text-fill-color: initial !important;
}

.dashboard-intro .hero-company:hover,
.dashboard-intro .intro-company:hover {
  translate: none !important;
  filter: none !important;
}

/* Subtitle - Corporate SaaS */
.dashboard-intro .dashboard-hero-sub,
.dashboard-intro .page-intro-sub {
  font-family: var(--font-sans) !important;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px !important;
  color: #64748b !important;
  line-height: 1.45;
  margin: 0;
  font-weight: 400;
}

[data-theme="dark"] .dashboard-intro .dashboard-hero-sub,
[data-theme="dark"] .dashboard-intro .page-intro-sub {
  color: #94a3b8 !important;
}

.dashboard-intro .dashboard-hero-sub strong,
.dashboard-intro .page-intro-sub strong {
  color: var(--text-main);
  font-weight: 600;
}

.hero-sub-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hero-sub-icon.icon-success {
  color: #10b981;
}

.hero-sub-icon.icon-warning {
  color: #f59e0b;
}

/* Action Buttons Container */
.dashboard-hero-actions,
.dashboard-intro .page-intro-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Modern .dash-btn system */
.dash-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  line-height: 1;
}

.btn-text-short {
  display: none;
}

.btn-text-full {
  display: inline;
}

.dash-btn svg {
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.dash-btn:hover svg {
  transform: scale(1.06);
}

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

/* Primary CTA Button */
.dash-btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.28);
}

.dash-btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.38);
  transform: translateY(-1.5px);
}

/* Secondary Button */
.dash-btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main) !important;
  border-color: var(--border-subtle);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.dash-btn-secondary:hover {
  background: var(--bg-app);
  border-color: var(--border-muted);
  color: var(--text-main) !important;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  transform: translateY(-1.5px);
}

/* Success / Active verification button */
.dash-btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.28);
}

.dash-btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.38);
  transform: translateY(-1.5px);
}

/* Pill counters inside buttons */
.dash-btn-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.dash-counter-zero {
  background: rgba(100, 116, 139, 0.1);
  color: var(--text-muted);
}

.dash-counter-active {
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.dash-btn-secondary .dash-counter-active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: none;
}

.dash-counter-active.pulse {
  animation: counterPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* --- Greeting entrance animation --------------------------------------- */
.dashboard-intro.intro-anim .hero-eyebrow-label {
  animation: introRiseIn 0.45s ease-out both;
}

.dashboard-intro.intro-anim .hero-lead,
.dashboard-intro.intro-anim .intro-lead {
  display: inline;
  animation: introRiseIn 0.5s ease-out both;
}

.dashboard-intro.intro-anim .hero-company,
.dashboard-intro.intro-anim .intro-company {
  display: inline;
  animation: introRiseIn 0.55s ease-out 0.06s both;
}

.dashboard-intro.intro-anim .dashboard-hero-sub,
.dashboard-intro.intro-anim .page-intro-sub {
  animation: introFadeIn 0.5s ease-out 0.18s both;
}

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

@keyframes introSlideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

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

@media (prefers-reduced-motion: reduce) {
  .dashboard-intro.intro-anim .hero-eyebrow-label,
  .dashboard-intro.intro-anim .hero-lead,
  .dashboard-intro.intro-anim .intro-lead,
  .dashboard-intro.intro-anim .hero-company,
  .dashboard-intro.intro-anim .intro-company,
  .dashboard-intro.intro-anim .dashboard-hero-sub,
  .dashboard-intro.intro-anim .page-intro-sub {
    animation: none;
  }

  .dashboard-intro .hero-company,
  .dashboard-intro .intro-company,
  .dashboard-intro .hero-company:hover,
  .dashboard-intro .intro-company:hover {
    translate: none;
    filter: none;
    transition: none;
  }
}

/* Responsive hero header rules */
@media (max-width: 991px) {
  .dashboard-hero-body {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
  }
  .dashboard-hero-content {
    flex: 0 0 auto;
    width: 100%;
  }
  .dashboard-hero-actions,
  .dashboard-intro .page-intro-actions {
    width: 100%;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .btn-text-full {
    display: none !important;
  }
  .btn-text-short {
    display: inline !important;
    white-space: nowrap !important;
  }

  .dashboard-intro.dashboard-hero-card {
    margin-bottom: 16px;
    border-radius: var(--radius-md);
  }

  .dashboard-hero-body {
    padding: 14px 14px !important;
    gap: 10px !important;
  }

  .dashboard-hero-content {
    flex: 0 0 auto;
    width: 100%;
    gap: 4px !important;
  }

  .hero-meta-row {
    gap: 5px !important;
    margin-bottom: 2px !important;
  }

  .hero-pill {
    padding: 3px 8px !important;
    font-size: 0.69rem !important;
    line-height: 1.2 !important;
  }

  .hero-date-full {
    display: none !important;
  }

  .hero-date-short {
    display: inline !important;
  }

  .hero-eyebrow-label {
    font-size: 10px !important;
    letter-spacing: 0.07em !important;
    margin-bottom: 2px !important;
  }

  .dashboard-intro .dashboard-hero-title,
  .dashboard-intro .page-intro-title {
    font-size: 20px !important;
    line-height: 1.3 !important;
    margin: 1px 0 !important;
  }

  .dashboard-intro .dashboard-hero-sub,
  .dashboard-intro .page-intro-sub {
    font-size: 13px !important;
    line-height: 1.4 !important;
    margin-bottom: 2px !important;
  }

  /* Single-line button row on mobile — proper equal distribution, zero overlap */
  .dashboard-hero-actions,
  .dashboard-intro .page-intro-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    width: 100% !important;
    gap: 6px !important;
    margin-top: 4px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  .dashboard-hero-actions::-webkit-scrollbar,
  .dashboard-intro .page-intro-actions::-webkit-scrollbar {
    display: none !important;
  }

  .dashboard-hero-actions .dash-btn,
  .dashboard-intro .page-intro-actions .dash-btn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 36px !important;
    padding: 0 6px !important;
    font-size: 0.76rem !important;
    font-weight: 600 !important;
    gap: 5px !important;
    justify-content: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    border-radius: var(--radius-sm) !important;
    box-sizing: border-box !important;
  }

  .dashboard-hero-actions .dash-btn span,
  .dashboard-intro .page-intro-actions .dash-btn span {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    min-width: 0 !important;
  }

  .dashboard-hero-actions .dash-btn svg,
  .dashboard-intro .page-intro-actions .dash-btn svg {
    width: 13px !important;
    height: 13px !important;
    flex-shrink: 0 !important;
  }

  .dashboard-hero-actions .dash-btn-counter,
  .dashboard-intro .page-intro-actions .dash-btn-counter {
    min-width: 18px !important;
    height: 18px !important;
    padding: 0 4px !important;
    font-size: 0.68rem !important;
    flex-shrink: 0 !important;
    margin-left: 1px !important;
  }

  .dashboard-hero-actions .dash-btn-primary,
  .dashboard-intro .page-intro-actions .dash-btn-primary {
    font-weight: 700 !important;
  }
}

/* --- KPI cards (dashboard.php) ------------------------------------------ */
.dashboard-stats-grid.kpi-grid {
  gap: 16px !important;
  margin-bottom: 26px !important;
}

.kpi-card {
  text-decoration: none;
  color: inherit;
  gap: 10px;
  padding: 18px 18px 16px !important;
  border-color: var(--tint-ring, var(--border-subtle)) !important;
  /* White card with a light tint wash in the corner instead of a flat fill. */
  background-image: linear-gradient(155deg, var(--tint-bg, transparent) 0%, rgba(255, 255, 255, 0) 42%) !important;
  box-shadow: var(--shadow-sm) !important;
}

a.kpi-card { cursor: pointer; }

.kpi-card:hover {
  transform: translateY(-3px);
  border-color: var(--tint, var(--primary)) !important;
  box-shadow: var(--shadow-lg) !important;
}

.kpi-card:focus-visible {
  outline: 2px solid var(--tint, var(--primary));
  outline-offset: 2px;
}

/* Accent rail re-uses the existing .stat-card::before, only recoloured. */
.dashboard-stats-grid .kpi-card::before {
  background: linear-gradient(90deg, var(--tint) 0%, var(--tint) 55%, var(--tint-bg) 100%);
  opacity: 0.5;
}

.kpi-card:hover::before { opacity: 1; }

.kpi-head {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-width: 0;
}

.kpi-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  /* Solid tint + a white sheen keeps the chip colourful without a second colour. */
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 62%), var(--tint);
  box-shadow: 0 6px 14px -5px var(--tint-ring), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-icon svg { width: 21px; height: 21px; }

.kpi-card:hover .kpi-icon { transform: scale(1.06); }

.kpi-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.005em;
  color: var(--text-main);
}

.kpi-go {
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--tint);
  background: var(--tint-bg);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.kpi-card:hover .kpi-go {
  opacity: 1;
  transform: translateX(0);
}

.kpi-value {
  display: block;
  width: 100%;
  font-size: clamp(1.5rem, 1.15rem + 1.4vw, 1.75rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-desc {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 0.755rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-muted);
}

.kpi-desc strong {
  color: var(--tint, var(--text-main));
  font-weight: 700;
}

/* --- Section headers with an icon chip ---------------------------------- */
.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.section-head-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tint, var(--primary));
  background: var(--tint-bg, var(--primary-subtle));
  border: 1px solid var(--tint-ring, var(--border-subtle));
}

.section-head-icon svg { width: 18px; height: 18px; }

.section-head-text { min-width: 0; }

.section-head-text .card-title { display: block; }

.section-eyebrow {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
}

/* --- Compact mini KPI cards (requisition / ledger strips) --------------- */
.mini-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-subtle);
}

/* Last child = the strip is the whole card body, so it must not draw a divider
   on top of the card's own bottom border. */
.mini-kpi-grid:last-child { border-bottom: none; }

.mini-kpi {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--tint-ring, var(--border-subtle));
  background: var(--bg-surface);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

a.mini-kpi { cursor: pointer; }

.mini-kpi:hover {
  transform: translateY(-2px);
  border-color: var(--tint, var(--primary));
  box-shadow: var(--shadow-md);
}

.mini-kpi-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 60%), var(--tint);
  box-shadow: 0 4px 9px -4px var(--tint-ring);
}

.mini-kpi-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.mini-kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-kpi-value {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-kpi-note {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Sales & Revenue Overview chart card -------------------------------- */
.chart-card { box-shadow: var(--shadow-md); }

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.legend-swatch {
  display: inline-block;
  border-radius: 3px;
}

.legend-swatch--bar {
  width: 11px;
  height: 11px;
  background: linear-gradient(180deg, #2563eb, #06b6d4);
}

.legend-swatch--line {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: #7c3aed;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.seg-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
}

.seg-tab {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.seg-tab:hover { color: var(--text-main); background: var(--bg-surface); }

.seg-tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 2px 7px rgba(37, 99, 235, 0.32);
}

.chart-custom {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.chart-date-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.chart-date-field .form-control {
  height: 32px;
  padding: 4px 9px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.chart-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.chart-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--tint-bg, var(--bg-app));
  border: 1px solid var(--tint-ring, var(--border-subtle));
}

.chart-stat > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.chart-stat-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tint, var(--text-muted));
  background: var(--bg-surface);
  border: 1px solid var(--tint-ring, var(--border-subtle));
}

.chart-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-stat-value {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-stat-value--muted { font-size: 0.8rem; font-weight: 600; color: var(--text-soft); }
.chart-stat-value.is-up { color: var(--success); }
.chart-stat-value.is-down { color: var(--danger); }

.chart-body {
  position: relative;
  padding: 18px 20px 12px;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-grid {
  stroke: var(--border-subtle);
  stroke-width: 1;
  stroke-dasharray: 3 5;
}

.chart-axis-x {
  fill: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.chart-axis-y {
  fill: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
}

.chart-axis-y--right {
  fill: #7c3aed;
  font-weight: 700;
}

.chart-bar {
  fill: url(#chartBar);
  transition: opacity 0.15s ease;
}

.chart-bar:hover,
.chart-bar.is-hot { opacity: 0.78; }

.chart-dot {
  fill: var(--bg-surface);
  stroke: #7c3aed;
  stroke-width: 2;
}

.chart-line {
  fill: none;
  stroke: #7c3aed;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-area { stroke: none; }

/* Transparent per-bucket strips that the tooltip script reads. `transparent`
   (not `none`) keeps them hit-testable. */
.chart-hit {
  fill: transparent;
  pointer-events: all;
  cursor: crosshair;
}

.chart-tip {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 11px;
  border-radius: 9px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  transform: translateX(-50%);
}

.chart-tip[hidden] { display: none; }

.chart-tip-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  opacity: 0.92;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot--bar { background: #2563eb; }
.legend-dot--line { background: #7c3aed; }

/* Empty period: nothing is laid over the plot. The frame below is the real chart
   for the selected range — gridlines, its dates and the zero baseline — and the
   first order created plots itself into those same buckets. */
.chart-grid--base {
  stroke: var(--border-muted);
  stroke-dasharray: none;
}

.chart-baseline {
  stroke: var(--text-soft);
  stroke-width: 2;
  stroke-dasharray: 6 6;
  opacity: 0.85;
}

.chart-dot.is-zero {
  stroke: var(--border-muted);
  stroke-width: 2;
  fill: var(--bg-surface);
}

.chart-svg--empty .chart-axis-x { fill: var(--text-soft); }

/* --- Recent products list ----------------------------------------------- */
.product-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.product-row:hover {
  border-color: rgba(6, 182, 212, 0.45);
  background: var(--info-subtle);
  box-shadow: var(--shadow-sm);
}

.product-thumb {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--info);
  background: var(--info-subtle);
  border: 1px solid var(--border-subtle);
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.product-row-name {
  font-size: 0.87rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-row-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-row-meta code {
  font-size: 0.72rem;
  color: var(--text-soft);
  background: var(--bg-app);
  padding: 1px 5px;
  border-radius: 4px;
}

.product-row-side {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  text-align: right;
}

.product-row-price {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.product-row-stock {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--success);
}

/* --- Team & Dealer network cells ---------------------------------------- */
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--tint, var(--text-main));
  background: var(--tint-bg, var(--bg-app));
  border: 1px solid var(--tint-ring, var(--border-subtle));
}

.status-flag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-flag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-flag.is-on { color: var(--success-text); }
.status-flag.is-on .status-flag-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
}

.status-flag.is-off { color: var(--text-muted); }
.status-flag.is-off .status-flag-dot {
  background: var(--text-soft);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

/* --- Dark theme --------------------------------------------------------- */
[data-theme="dark"] .kpi-card {
  background-image: linear-gradient(155deg, var(--tint-bg) 0%, rgba(255, 255, 255, 0) 44%) !important;
}

[data-theme="dark"] .mini-kpi-grid,
[data-theme="dark"] .seg-tabs,
[data-theme="dark"] .product-row-meta code {
  background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .mini-kpi,
[data-theme="dark"] .product-row {
  background-color: var(--bg-surface);
}

[data-theme="dark"] .seg-tab:hover { background-color: rgba(255, 255, 255, 0.07); }

/* Tints are mid-tone hexes, so brighten the coloured ink instead of the chip. */
[data-theme="dark"] .section-head-icon,
[data-theme="dark"] .chart-stat-icon,
[data-theme="dark"] .role-chip {
  filter: brightness(1.35);
}

[data-theme="dark"] .chart-axis-y--right { fill: #a78bfa; }
[data-theme="dark"] .chart-line,
[data-theme="dark"] .chart-dot { stroke: #a78bfa; }
[data-theme="dark"] .chart-dot { fill: var(--bg-surface); }
[data-theme="dark"] .legend-swatch--line,
[data-theme="dark"] .legend-dot--line { background: #a78bfa; }

[data-theme="dark"] .chart-tip {
  background: #e2e8f0;
  color: #0f172a;
}

/* --- Responsive --------------------------------------------------------- */
/* KPI column layout. The shared .stats-grid / .dashboard-stats-grid rules above
   are overridden further down the file by a later .stats-grid rule, so the
   dashboard grid declares its own (higher-specificity) breakpoints. */
/* One-line KPI row: five compact cards side by side from 1200px up, which is
   where a card still has room for the icon chip and a two-line label. Below
   that the row would squeeze the text, so it drops to two cards per row. */
@media (min-width: 1200px) {
  .dashboard-stats-grid.kpi-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }
  .dashboard-stats-grid.kpi-grid .kpi-card {
    grid-column: auto !important;
    gap: 8px;
    padding: 14px 14px 13px !important;
  }
  .dashboard-stats-grid.kpi-grid .kpi-head { gap: 9px; }
  .dashboard-stats-grid.kpi-grid .kpi-icon { width: 42px; height: 42px; border-radius: 11px; }
  .dashboard-stats-grid.kpi-grid .kpi-icon svg { width: 20px; height: 20px; }
  .dashboard-stats-grid.kpi-grid .kpi-label { font-size: 0.75rem; }
  .dashboard-stats-grid.kpi-grid .kpi-value { font-size: clamp(1.5rem, 1.02rem + 0.9vw, 1.6rem); }
  .dashboard-stats-grid.kpi-grid .kpi-desc { font-size: 0.7rem; }
}

/* On the tighter end of the one-line row the hover arrow would steal label
   width, and the whole card is a link anyway, so it is dropped. */
@media (min-width: 1200px) and (max-width: 1499px) {
  .kpi-go { display: none; }
}

/* Tablet / narrow window: two comfortable cards per row, last card full width. */
@media (min-width: 561px) and (max-width: 1199px) {
  .dashboard-stats-grid.kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-stats-grid.kpi-grid .kpi-card {
    grid-column: span 1 !important;
  }
  .dashboard-stats-grid.kpi-grid .kpi-card:nth-child(5) {
    grid-column: span 2 !important;
  }
}

@media (max-width: 560px) {
  .dashboard-stats-grid.kpi-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .dashboard-stats-grid.kpi-grid .kpi-card {
    grid-column: auto !important;
  }
}

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

@media (max-width: 900px) {
  .chart-toolbar { align-items: stretch; }
  .seg-tabs { border-radius: 14px; }
  .kpi-icon { width: 42px; height: 42px; }
  .kpi-icon svg { width: 20px; height: 20px; }
}

@media (max-width: 680px) {
  .chart-stats { grid-template-columns: 1fr; }
  .chart-legend { width: 100%; justify-content: flex-start; }
  .chart-body { padding: 14px 12px 8px; }
  .chart-custom { width: 100%; }
  .chart-date-field { flex: 1 1 0; }
  .chart-date-field .form-control { width: 100%; }
  .section-head { gap: 10px; }
  .section-head-icon { width: 34px; height: 34px; border-radius: 10px; }
}

@media (max-width: 520px) {
  .mini-kpi-grid { grid-template-columns: 1fr; padding: 12px 14px; }
  .seg-tab { padding: 5px 10px; font-size: 0.76rem; }
  .kpi-label { font-size: 0.75rem; }
  .kpi-value { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .kpi-card,
  .kpi-icon,
  .kpi-go,
  .mini-kpi,
  .product-row,
  .seg-tab {
    transition: none;
  }
  .kpi-card:hover,
  .mini-kpi:hover,
  .kpi-card:hover .kpi-icon,
  .kpi-card:hover .kpi-go {
    transform: none;
  }
}

/* ==========================================================================
   PWA & MOBILE ENHANCEMENTS
   Install prompt UI, offline state, safe-area insets and touch ergonomics
   for installed-standalone / phone usage. Kept isolated at the end of the
   sheet so existing rules above stay untouched.
   ========================================================================== */

/* Remove the 300ms double-tap-zoom delay and the grey tap flash on touch
   devices; maximum-scale in the viewport meta already allows user zoom. */
* {
  -webkit-tap-highlight-color: transparent;
}

a, button, input, select, textarea, summary, .btn, .icon-btn {
  touch-action: manipulation;
}

/* Notch / home-indicator safe areas (viewport-fit=cover). The sticky header
   absorbs the top inset so content never sits under the status bar, and the
   page gutters absorb the side insets in landscape. */
.app-header {
  padding-top: env(safe-area-inset-top);
  height: calc(var(--app-header-h) + env(safe-area-inset-top));
  padding-left: max(32px, env(safe-area-inset-left));
  padding-right: max(32px, env(safe-area-inset-right));
}

.page-container {
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.app-sidebar {
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  /* Re-apply the smaller mobile header height on top of the safe-area calc
     above (later rule wins; media queries add no specificity). */
  .app-header {
    height: calc(62px + env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .page-container {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
}

@media (max-width: 640px) {
  .app-header {
    height: calc(58px + env(safe-area-inset-top));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
}

/* Installed standalone mode: the OS already draws the chrome, so tighten the
   top inset (the header keeps only the notch area) and let the app fill down
   under the iOS home indicator gracefully. */
@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: none;
  }
}

/* Touch ergonomics: 44px minimum tap targets on primary controls (Apple HIG /
   Material) without changing the desktop visual size much. */
@media (max-width: 1024px) {
  .btn {
    min-height: 44px;
  }

  .icon-btn {
    min-width: 40px;
    min-height: 40px;
  }

  .app-sidebar a,
  .app-sidebar button {
    min-height: 42px;
  }

  /* Dropdown menus fit small screens: cap to the viewport, scroll inside. */
  .notif-dropdown-menu {
    max-width: calc(100vw - 24px);
    max-height: 70vh;
    overflow-y: auto;
  }
}

/* Install button injected by pwa.js into .header-right. */
.pwa-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.pwa-install-btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.pwa-install-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

@media (max-width: 640px) {
  /* On narrow phones the label is noise - keep only the download glyph. */
  .pwa-install-btn span {
    display: none;
  }

  .pwa-install-btn {
    padding: 7px 9px;
  }
}

/* Offline pill shown while body.pwa-offline (set by pwa.js). */
body.pwa-offline .app-header::after {
  content: 'Offline';
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  background: var(--danger);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  z-index: 40;
  pointer-events: none;
}

/* Toasts shown by pwa.js (update / install / connectivity messages). */
.pwa-toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 12px);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #f1f5f9;
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 10000;
}

.pwa-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.pwa-toast-success { border-left: 4px solid var(--success); }
.pwa-toast-error { border-left: 4px solid var(--danger); }
.pwa-toast-info { border-left: 4px solid var(--primary); }

.pwa-toast-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

/* iOS only paints the status bar background in standalone mode when the
   content is light; match the app header color. */
@media (display-mode: standalone) {
  .app-header {
    background-color: rgba(255, 255, 255, 0.96);
  }

  [data-theme="dark"] .app-header {
    background-color: var(--bg-surface);
  }
}

/* Mobile bottom navigation bar (includes/mobile-nav.php) — native-app style
   menu shown on phone/tablet sizes; desktop keeps the sidebar only. */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 1024px) {
  .mobile-bottom-nav {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.06);
    padding-bottom: env(safe-area-inset-bottom);
  }

  [data-theme="dark"] .mobile-bottom-nav {
    background: rgba(15, 23, 42, 0.94);
    border-top-color: var(--border-subtle);
  }

  .mobile-bottom-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: stretch;
  }

  .mobile-bottom-nav li {
    flex: 1 1 0;
    min-width: 0;
  }

  .mbn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 100%;
    min-height: 56px;
    padding: 5px 4px 4px;
    border: none;
    background: none;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-muted);
    font-family: inherit;
    transition: color 0.15s ease;
  }

  /* Per-tab palette feeding the 3D icon chips below. */
  .mbn-tab--dashboard {
    --mbn-accent: #2563eb;
    --mbn-accent-deep: #1d4ed8;
    --mbn-chip: #dbe7ff;
    --mbn-glow: rgba(37, 99, 235, 0.45);
  }

  .mbn-tab--leads {
    --mbn-accent: #7c3aed;
    --mbn-accent-deep: #6d28d9;
    --mbn-chip: #e9e2ff;
    --mbn-glow: rgba(124, 58, 237, 0.45);
  }

  .mbn-tab--orders {
    --mbn-accent: #f59e0b;
    --mbn-accent-deep: #b45309;
    --mbn-chip: #ffeed4;
    --mbn-glow: rgba(245, 158, 11, 0.45);
  }

  .mbn-tab--service-visits {
    --mbn-accent: #0ea5e9;
    --mbn-accent-deep: #0369a1;
    --mbn-chip: #d8effc;
    --mbn-glow: rgba(14, 165, 233, 0.45);
  }

  .mbn-tab--more {
    --mbn-accent: #475569;
    --mbn-accent-deep: #334155;
    --mbn-chip: #e2e8f0;
    --mbn-glow: rgba(71, 85, 105, 0.40);
  }

  /* Raised, bevelled chip: top highlight + bottom inner shade + cast shadow
     makes every tab icon read as a physical 3D button. */
  .mbn-icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 11px;
    color: var(--mbn-accent-deep, var(--text-muted));
    background: linear-gradient(165deg, #ffffff 0%, var(--mbn-chip, #eef1f6) 100%);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.95),
      inset 0 -2px 3px rgba(15, 23, 42, 0.09),
      0 3px 6px rgba(15, 23, 42, 0.13),
      0 1px 2px rgba(15, 23, 42, 0.10);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
  }

  /* Gloss sheen over the upper half of the chip. */
  .mbn-icon::before {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.80) 0%, rgba(255, 255, 255, 0.18) 48%, rgba(255, 255, 255, 0) 64%);
    pointer-events: none;
  }

  .mbn-icon svg {
    position: relative;
    z-index: 1;
    width: 19px;
    height: 19px;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.75));
  }

  .mbn-label {
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .mbn-item.active {
    color: var(--mbn-accent-deep, var(--primary));
  }

  .mbn-item.active .mbn-icon {
    color: #ffffff;
    background: linear-gradient(165deg, var(--mbn-accent, var(--primary)) 0%, var(--mbn-accent-deep, var(--primary-hover)) 100%);
    box-shadow:
      inset 0 1px 1px rgba(255, 255, 255, 0.55),
      inset 0 -3px 5px rgba(15, 23, 42, 0.22),
      0 6px 13px var(--mbn-glow, rgba(37, 99, 235, 0.4)),
      0 2px 4px rgba(15, 23, 42, 0.18);
    transform: translateY(-2px);
  }

  .mbn-item.active .mbn-icon::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.08) 46%, rgba(255, 255, 255, 0) 62%);
  }

  .mbn-item.active .mbn-icon svg {
    stroke-width: 2.4;
    filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.35));
  }

  .mbn-item:active {
    transform: scale(0.96);
  }

  .mbn-item:active .mbn-icon {
    transform: translateY(0) scale(0.95);
  }

  [data-theme="dark"] .mbn-icon {
    color: var(--mbn-accent, #93c5fd);
    background: linear-gradient(165deg, #263449 0%, #121a29 100%);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      inset 0 -2px 4px rgba(0, 0, 0, 0.45),
      0 3px 7px rgba(0, 0, 0, 0.55);
  }

  [data-theme="dark"] .mbn-icon svg {
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.65));
  }

  [data-theme="dark"] .mbn-item.active {
    color: var(--mbn-accent, #93c5fd);
  }

  [data-theme="dark"] .mbn-item.active .mbn-icon {
    color: #ffffff;
    background: linear-gradient(165deg, var(--mbn-accent, #2563eb) 0%, var(--mbn-accent-deep, #1e40af) 100%);
  }

  @media (prefers-reduced-motion: reduce) {
    .mbn-icon {
      transition: none;
    }
    .mbn-item.active .mbn-icon,
    .mbn-item:active .mbn-icon {
      transform: none;
    }
  }

  /* The hamburger button is redundant once the bottom menu exists - the
     "More" tab opens the same drawer. */
  .mobile-toggle {
    display: none;
  }

  /* Keep page content (and sticky table tools / bulk bars) clear of the bar. */
  .page-container {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  /* The open drawer floats above the bar too, so lift its footer (user card
     + Sign Out) clear of the bottom nav, otherwise those taps hit the bar. */
  .app-sidebar {
    padding-bottom: calc(61px + env(safe-area-inset-bottom));
  }

  .sidebar-backdrop {
    bottom: calc(57px + env(safe-area-inset-bottom));
  }
}

/* --- Customer dashboard feedback form (includes/role-dashboard.php) ------ */
.dash-fb-card {
  margin-bottom: 22px;
}

.dash-fb-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  padding: 16px 18px 18px;
}

.dash-fb-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px 16px;
}

.dash-fb-ticket {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.dash-fb-ticket__no {
  font-weight: 800;
  color: var(--primary);
  font-size: 0.86rem;
}

.dash-fb-ticket__subject {
  flex: 1 1 auto;
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.9rem;
}

.dash-fb-ticket__meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dash-fb-form__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dash-fb-exp {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Pure-CSS star picker: the radios are emitted 5 -> 1 and the row is reversed,
   so ":checked ~ label" lights the lower stars that now sit to the left. The
   inputs stay focusable (opacity 0) so keyboard users can still rate. */
.fb-stars {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  gap: 6px;
}

.fb-stars input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.fb-stars label {
  font-size: 1.7rem;
  line-height: 1;
  color: #cbd5e1;
  cursor: pointer;
  transition: color 0.12s ease, transform 0.12s ease;
}

.fb-stars label:hover,
.fb-stars label:hover ~ label,
.fb-stars input:checked + label,
.fb-stars input:checked ~ label {
  color: #eab308;
}

.fb-stars label:hover {
  transform: scale(1.12);
}

.fb-stars input:focus-visible + label {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ============================================================
   Exhaustive Print / PDF Overrides (List Tables & Reports)
   ============================================================ */
@media print {
  /* Hide application navigation, header chrome, mobile dock, toggles and popups */
  .app-sidebar,
  .app-header,
  .mobile-bottom-nav,
  .sidebar-backdrop,
  .mobile-toggle,
  .notif-dropdown-container,
  #theme-toggle-btn,
  .user-menu-trigger,
  .flash-stack,
  .tabs-nav,
  .modal-backdrop,
  .modal,
  .alert,
  button,
  .btn,
  a.btn,
  .no-print {
    display: none !important;
  }

  /* When tt_print_head() is present on the page, hide the on-screen duplicate title/actions row */
  .table-print-head + div,
  .table-print-head + .clients-hero,
  .table-print-head + .tickets-page__hero,
  .table-print-head + .leads-hero {
    display: none !important;
  }

  /* Hide directory tabs, role filters, quick-add labels and actions */
  .role-tabs-bar,
  .role-tabs-quick,
  .field-visits-tabs,
  .field-visits-pill,
  .field-visits-pills-row,
  .field-visits-pills-scroll,
  .field-visits-filter-card,
  .incentive-quick-action,
  .stat-row,
  .page-header-actions,
  .clients-hero__actions,
  .leads-hero__actions,
  .hero-actions {
    display: none !important;
  }

  /* Hide all search/filter forms, search boxes, dropdowns and text inputs */
  form[method="GET" i],
  form[method="get" i],
  form.filter-form,
  form.search-form,
  form.field-visits-form,
  .search-box,
  .filter-card,
  .filter-grid,
  .filter-actions,
  select:not([data-printable]),
  input:not([type="checkbox"]) {
    display: none !important;
  }

  /* Hide filter cards or card headers that wrap search/filter controls, so only the data table prints */
  .card-header:has(form),
  .card-header:has(.search-box),
  .card-header:has(select),
  .card-header:has(input),
  .card-header.no-print,
  .card-body.no-print,
  .card.no-print,
  .card > div:has(form[method="GET" i]):not(.table-container),
  .card > div:has(form[method="get" i]):not(.table-container),
  .card > div:has(.search-box):not(.table-container),
  .card:has(form[method="GET" i]):not(:has(.table-container)):not(:has(table)),
  .card:has(form[method="get" i]):not(:has(.table-container)):not(:has(table)),
  .card:has(.search-box):not(:has(.table-container)):not(:has(table)),
  .card:has(.field-visits-form):not(:has(.table-container)):not(:has(table)),
  .card:has(.role-tabs-bar):not(:has(.table-container)):not(:has(table)),
  .card-body:has(form[method="GET" i]):not(:has(.table-container)):not(:has(table)),
  .card-body:has(form[method="get" i]):not(:has(.table-container)):not(:has(table)),
  .card-body:has(.search-box):not(:has(.table-container)):not(:has(table)) {
    display: none !important;
  }

  /* Details configuration / setup boxes */
  details#lowstock-setup,
  details.card {
    display: none !important;
  }

  /* Row action menu / button column & bulk action bar */
  .action-dropdown,
  .action-menu,
  th.action-col,
  td.action-col,
  .bulk-bar,
  th.bulk-check-col,
  td.bulk-check-col {
    display: none !important;
  }
}

