/* ==========================================================================
   FEE Ticket Tracking — Design System
   Modern Enterprise · Indigo/Blue · Light mode · Bootstrap 5
   Single source of truth. Tokens defined once, consumed by all views.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* Brand — Indigo → Blue */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-800: #3730a3;
  --brand-900: #312e81;
  --brand-gradient: linear-gradient(135deg, #312e81 0%, #4f46e5 55%, #2563eb 100%);
  --brand-gradient-soft: linear-gradient(135deg, #6366f1 0%, #2563eb 100%);

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Semantic */
  --success-50: #ecfdf5; --success-100: #d1fae5; --success-500: #10b981; --success-600: #059669; --success-700: #047857; --success-800: #065f46;
  --warning-50: #fffbeb; --warning-100: #fef3c7; --warning-500: #f59e0b; --warning-600: #d97706; --warning-700: #b45309; --warning-800: #92400e;
  --danger-50:  #fef2f2; --danger-100:  #fee2e2; --danger-500: #ef4444; --danger-600: #dc2626; --danger-700: #b91c1c; --danger-800: #991b1b;
  --info-50:    #f0f9ff; --info-100:    #e0f2fe; --info-500:   #0ea5e9; --info-600:   #0284c7; --info-700:   #0369a1; --info-800:   #075985;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', ui-monospace, 'Cascadia Code', Menlo, monospace;

  --text-xs: 0.6875rem;
  --text-sm: 0.78125rem;
  --text-base: 0.875rem;
  --text-lg: 0.9375rem;
  --text-xl: 1.0625rem;
  --text-2xl: 1.1875rem;
  --text-3xl: 1.5rem;

  /* Spacing (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .1), 0 2px 4px -2px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, .12), 0 4px 6px -4px rgba(15, 23, 42, .08);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, .16), 0 8px 10px -6px rgba(15, 23, 42, .1);

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Motion */
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 300ms;
  --ease-standard: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(0, 0, .2, 1);

  /* Layout */
  --sidebar-width: 228px;
  --topbar-height: 54px;

  /* Bootstrap 5 variable overrides */
  --bs-primary: var(--brand-500);
  --bs-primary-rgb: 99, 102, 241;
  --bs-secondary: var(--gray-500);
  --bs-success: var(--success-500);
  --bs-warning: var(--warning-500);
  --bs-danger: var(--danger-500);
  --bs-info: var(--info-500);
  --bs-body-bg: var(--gray-50);
  --bs-body-color: var(--gray-700);
  --bs-border-color: var(--gray-200);
  --bs-border-radius: var(--radius-md);
  --bs-font-sans-serif: var(--font-sans);
  --bs-btn-border-radius: var(--radius-sm);
  --bs-btn-font-weight: 500;
  --bs-body-font-family: var(--font-sans);
}

/* --------------------------------------------------------------------------
   2. BASE
   -------------------------------------------------------------------------- */
html, body {
  height: 100%;
}
body {
  font-family: var(--font-sans);
  background-color: var(--gray-50);
  color: var(--gray-700);
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--gray-800);
  font-weight: 600;
}
h1 { font-size: 1.375rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
h4 { font-size: 0.9375rem; }
h5 { font-size: 0.875rem; }
h6 { font-size: 0.8125rem; }

a {
  color: var(--brand-600);
  text-decoration: none;
}
a:hover {
  color: var(--brand-700);
}

::selection {
  background: var(--brand-200);
  color: var(--brand-900);
}

/* Focus visibility */
:focus-visible {
  outline: 3px solid var(--brand-200);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   3. APP SHELL
   -------------------------------------------------------------------------- */
.app-shell {
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--brand-gradient);
  color: #fff;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform var(--duration-slow) var(--ease-standard), width var(--duration-slow) var(--ease-standard);
  overflow-y: auto;
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 1035;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-base) ease;
}
body.sidebar-open .sidebar-backdrop {
  opacity: 1;
  visibility: visible;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.sidebar-brand .brand-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.sidebar-brand .brand-name {
  font-weight: 700;
  font-size: var(--text-base);
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, .65);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-2) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar-nav .nav-section {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, .45);
  padding: var(--space-3) var(--space-3) var(--space-1);
}
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .72);
  font-weight: 500;
  font-size: var(--text-xs);
  position: relative;
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
}
.sidebar-nav .nav-link i {
  font-size: 1rem;
  width: 1.15rem;
  text-align: center;
  opacity: .9;
}
.sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}
.sidebar-nav .nav-link.active {
  color: var(--brand-800);
  background: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.sidebar-nav .nav-link.active i {
  color: var(--brand-600);
  opacity: 1;
}
.sidebar-nav .nav-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--brand-400);
}
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, .12);
}

/* Main wrapper */
.main-wrapper {
  margin-left: 0;
  transition: margin-left var(--duration-slow) var(--ease-standard);
}
@media (min-width: 992px) {
  .main-wrapper {
    margin-left: var(--sidebar-width);
  }
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
}
.topbar .page-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--gray-800);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-toggle {
  border: none;
  background: transparent;
  color: var(--gray-600);
  font-size: 1.4rem;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  line-height: 1;
}
.sidebar-toggle:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Compact page-header rendered inside the topbar */
.topbar-heading {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.topbar .page-header {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 0;
  position: static;
  overflow: visible;
  flex: 1;
  min-width: 0;
}
.topbar .page-header::before {
  display: none;
}
.topbar .page-header-row {
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-3);
}
.topbar .page-header-text {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
}
.topbar .page-header-title {
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .page-header-title > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .page-header-desc {
  margin: 0;
  font-size: var(--text-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .page-header-icon {
  width: 30px;
  height: 30px;
  font-size: 0.95rem;
}
.topbar .page-header-actions {
  margin-left: auto;
  white-space: nowrap;
}
@media (max-width: 767.98px) {
  .topbar .page-header-desc { display: none; }
  .topbar .page-header-icon { width: 26px; height: 26px; font-size: 0.85rem; }
  .topbar { padding: 0 var(--space-3); gap: var(--space-2); }
}

.main-content {
  padding: var(--space-4);
  min-height: calc(100vh - var(--topbar-height) - 48px);
}
@media (max-width: 991.98px) {
  .main-content { padding: var(--space-3); }
}
@media (max-width: 575.98px) {
  .main-content { padding: var(--space-3); }
}

/* Main footer */
.main-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--gray-200);
  background: #fff;
  text-align: center;
}
@media (max-width: 575.98px) {
  .main-footer { padding: var(--space-2) var(--space-3); }
}

/* --------------------------------------------------------------------------
   4. TOPBAR USER DROPDOWN
   -------------------------------------------------------------------------- */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--brand-gradient-soft);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.btn-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-700);
  font-weight: 500;
  font-size: var(--text-sm);
}
.btn-user:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}
.dropdown-menu {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
}
.dropdown-item {
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--gray-700);
}
.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--brand-50);
  color: var(--brand-700);
}
.dropdown-header {
  color: var(--gray-500);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}

/* Profile page avatar (large identity circle) */
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

/* --------------------------------------------------------------------------
   5. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: var(--text-sm);
  padding: 0 var(--space-3);
  transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease, transform var(--duration-fast) ease;
}
.btn-sm {
  height: 28px;
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
}
.btn-lg {
  height: 40px;
  padding: 0 var(--space-5);
}

.btn-primary {
  --bs-btn-bg: var(--brand-500);
  --bs-btn-border-color: var(--brand-500);
  --bs-btn-hover-bg: var(--brand-600);
  --bs-btn-hover-border-color: var(--brand-600);
  --bs-btn-active-bg: var(--brand-700);
  --bs-btn-active-border-color: var(--brand-700);
  --bs-btn-disabled-bg: var(--gray-300);
  --bs-btn-disabled-border-color: var(--gray-300);
}
.btn-outline-primary {
  --bs-btn-color: var(--brand-600);
  --bs-btn-border-color: var(--brand-400);
  --bs-btn-hover-bg: var(--brand-600);
  --bs-btn-hover-border-color: var(--brand-600);
  --bs-btn-active-bg: var(--brand-700);
}
.btn-secondary {
  --bs-btn-bg: var(--gray-100);
  --bs-btn-border-color: var(--gray-200);
  --bs-btn-color: var(--gray-700);
  --bs-btn-hover-bg: var(--gray-200);
  --bs-btn-hover-border-color: var(--gray-200);
  --bs-btn-active-bg: var(--gray-300);
}
.btn-outline-secondary {
  --bs-btn-color: var(--gray-600);
  --bs-btn-border-color: var(--gray-300);
  --bs-btn-hover-bg: var(--gray-50);
  --bs-btn-hover-color: var(--gray-800);
  --bs-btn-hover-border-color: var(--gray-400);
}
.btn-danger {
  --bs-btn-bg: var(--danger-500);
  --bs-btn-border-color: var(--danger-500);
  --bs-btn-hover-bg: var(--danger-600);
  --bs-btn-hover-border-color: var(--danger-600);
  --bs-btn-active-bg: var(--danger-700);
}
.btn-success {
  --bs-btn-bg: var(--success-500);
  --bs-btn-border-color: var(--success-500);
  --bs-btn-hover-bg: var(--success-600);
  --bs-btn-hover-border-color: var(--success-600);
}
/* Soft amber button — used for contextual "Edit" actions (non-destructive) */
.btn-warning {
  --bs-btn-bg: var(--warning-50);
  --bs-btn-border-color: var(--warning-200);
  --bs-btn-color: var(--warning-700);
  --bs-btn-hover-bg: var(--warning-100);
  --bs-btn-hover-border-color: var(--warning-300);
  --bs-btn-hover-color: var(--warning-800);
  --bs-btn-active-bg: var(--warning-200);
  --bs-btn-active-border-color: var(--warning-400);
  --bs-btn-active-color: var(--warning-800);
}
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--gray-600);
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}
.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--gray-500);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
}
.btn-icon:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}
.btn-icon.btn-icon-danger:hover {
  background: var(--danger-50);
  color: var(--danger-600);
}
.btn:disabled,
.btn.disabled {
  cursor: not-allowed;
  opacity: 1;
  color: var(--gray-500);
}

/* --------------------------------------------------------------------------
   6. CARDS
   -------------------------------------------------------------------------- */
.card {
  background: #fff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-100);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header .card-toolbar { display: flex; gap: var(--space-2); }
.card-body {
  padding: var(--space-4);
}
.card-footer {
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  padding: var(--space-2) var(--space-4);
}

/* Compact info summary card (edit pages) — tighter padding, less vertical gap */
.card-compact .card-header {
  padding: var(--space-2) var(--space-4);
}
.card-compact .card-body {
  padding: var(--space-3);
}
.card-compact .card-body .row.g-3 {
  --bs-gutter-y: 0.375rem;
}
.card-compact .info-row {
  padding: var(--space-1) 0;
}

/* Stat cards */
.stats-card {
  background: #fff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: box-shadow var(--duration-base) ease, transform var(--duration-base) ease;
}
.stats-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stats-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}
.stats-icon.bg-brand  { background: var(--brand-gradient-soft); }
.stats-icon.bg-success { background: linear-gradient(135deg, #10b981, #059669); }
.stats-icon.bg-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stats-icon.bg-danger  { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stats-icon.bg-info    { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.stats-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
}
.stats-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stats-delta { font-size: var(--text-xs); font-weight: 600; }
.stats-delta.up { color: var(--success-600); }
.stats-delta.down { color: var(--danger-600); }

/* Quick action cards */
.action-card {
  background: #fff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3);
  text-align: center;
  transition: box-shadow var(--duration-base) ease, transform var(--duration-base) ease;
  cursor: pointer;
  text-decoration: none;
  display: block;
  color: inherit;
}
.action-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  color: inherit;
}
.action-icon-wrapper {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--brand-50);
  color: var(--brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin: 0 auto var(--space-2);
}
.action-card .action-title { font-weight: 600; color: var(--gray-800); }
.action-card .action-desc { font-size: var(--text-xs); color: var(--gray-500); margin-top: 4px; }

/* --------------------------------------------------------------------------
   7. TABLES
   -------------------------------------------------------------------------- */
.table-card { overflow: hidden; }
.table-card .table { margin: 0; }
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--gray-700);
  font-size: var(--text-sm);
}
.table thead th {
  background: var(--gray-50);
  color: var(--gray-500);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--gray-200);
  padding: var(--space-2) var(--space-3);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.table tbody tr {
  transition: background var(--duration-fast) ease;
}
.table tbody tr:hover {
  background: var(--gray-50);
}
.table .ticket-row { cursor: pointer; }
.table .ticket-row:hover {
  background: var(--brand-50);
}
.table td .fw-semibold { color: var(--gray-800); }

/* Ticket listing tables — balanced column widths */
.table-listing th:nth-child(1) { width: 44px; }
.table-listing th:nth-child(2) { width: 22%; }
.table-listing th:nth-child(3) { width: 32%; }
.table-listing th:nth-child(4) { width: 13%; }
.table-listing th:nth-child(5) { width: 13%; }
.table-listing th:nth-child(6) { width: 96px; }
/* Variant with leading checkbox column (admin dashboard) */
.table-listing.has-checkbox th:nth-child(1) { width: 44px; }
.table-listing.has-checkbox th:nth-child(2) { width: 44px; }
.table-listing.has-checkbox th:nth-child(3) { width: 22%; }
.table-listing.has-checkbox th:nth-child(4) { width: 32%; }
.table-listing.has-checkbox th:nth-child(5) { width: 13%; }
.table-listing.has-checkbox th:nth-child(6) { width: 13%; }
.table-listing.has-checkbox th:nth-child(7) { width: 96px; }
.ticket-project {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table td .ticket-meta-badges .badge { font-size: 0.6875rem; }

/* Mobile card view for tables */
.table-mobile-cards {
  display: none;
}
@media (max-width: 767.98px) {
  .table-desktop-wrap { display: none; }
  .table-mobile-cards { display: block; }
}

/* Pagination */
.pagination {
  --bs-pagination-color: var(--gray-600);
  --bs-pagination-border-color: var(--gray-200);
  --bs-pagination-hover-color: var(--brand-700);
  --bs-pagination-hover-bg: var(--brand-50);
  --bs-pagination-hover-border-color: var(--brand-200);
  --bs-pagination-active-bg: var(--brand-500);
  --bs-pagination-active-border-color: var(--brand-500);
  --bs-pagination-focus-box-shadow: 0 0 0 .25rem rgba(99, 102, 241, .15);
  --bs-pagination-border-radius: var(--radius-sm);
  --bs-pagination-font-size: var(--text-sm);
  gap: 2px;
}
.pagination .page-link { border-radius: var(--radius-sm); }

/* --------------------------------------------------------------------------
   8. BADGES
   -------------------------------------------------------------------------- */
.badge {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: .45em .8em;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  display: inline-block;
}
.badge-warning { background: var(--warning-50); color: var(--warning-700); }
.badge-warning .badge-dot { background: var(--warning-500); }
.badge-success { background: var(--success-50); color: var(--success-700); }
.badge-success .badge-dot { background: var(--success-500); }
.badge-danger  { background: var(--danger-50);  color: var(--danger-700); }
.badge-danger .badge-dot  { background: var(--danger-500); }
.badge-info    { background: var(--info-50);    color: var(--info-700); }
.badge-info .badge-dot    { background: var(--info-500); }
.badge-neutral { background: var(--gray-100);   color: var(--gray-600); }
.badge-neutral .badge-dot { background: var(--gray-400); }
.badge-primary { background: var(--brand-50);   color: var(--brand-700); }
.badge-primary .badge-dot { background: var(--brand-500); }

.status-badge {
  font-size: var(--text-xs);
  padding: .45em .8em;
  border-radius: var(--radius-full);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   9. FORMS
   -------------------------------------------------------------------------- */
.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: var(--space-2);
}
.form-label .required { color: var(--danger-500); }
/* Required asterisk for labels inside .form-floating (kept for compatibility) */
.required-label::after { content: " *"; color: var(--danger-500); font-weight: 700; }
.form-control, .form-select {
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-300);
  background-color: #fff;
  color: var(--gray-700);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
/* Dropdowns should be distinguishable from text inputs at a glance: a subtle
   slate tint, a brand-colored chevron on the right, and a pointer cursor all
   signal "this opens a list". */
.form-select {
  background-color: var(--gray-50);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236366f1' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 14px 12px;
  padding-right: 2.5rem;
  cursor: pointer;
}
textarea.form-control { height: auto; min-height: 80px; }
.form-control::placeholder { color: var(--gray-400); }
/* Brand-colored text caret while typing = smart focus cue */
.form-control { caret-color: var(--brand-500); }
.form-control:hover:not(:disabled):not(:read-only),
.form-select:hover:not(:disabled) { border-color: var(--gray-400); }
/* Hovering a dropdown nudges it toward the brand color as an interactive cue */
.form-select:hover:not(:disabled) { border-color: var(--brand-300); }
.form-control:focus, .form-select:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .16);
}
.form-control:disabled, .form-select:disabled,
.form-control[readonly] { background: var(--gray-100); color: var(--gray-500); }
.form-control.is-invalid, .was-validated .form-control:invalid {
  border-color: var(--danger-500);
  background-image: none;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}
.form-select.is-invalid, .was-validated .form-select:invalid {
  border-color: var(--danger-500);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ef4444' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
.form-control.is-invalid:focus, .form-select.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .2);
}
.form-text { color: var(--gray-500); font-size: var(--text-xs); }
.invalid-feedback { color: var(--danger-600); font-size: var(--text-xs); font-weight: 500; }
.form-check-input:checked {
  background-color: var(--brand-500);
  border-color: var(--brand-500);
}
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
/* Switch in brand color */
.form-switch .form-check-input:checked {
  background-color: var(--brand-500);
  border-color: var(--brand-500);
}
/* Large checkbox/radio/switch (used on ELI review edit) */
.form-check-lg .form-check-input {
  width: 1.5rem;
  height: 1.5rem;
  margin-top: .125em;
}
.form-check-lg .form-check-label {
  font-size: var(--text-lg);
  padding-top: 2px;
}
.form-switch.form-check-lg .form-check-input {
  width: 3rem;
  height: 1.5rem;
}

/* File dropzone — the invisible file input covers the WHOLE box (position:relative
   + inset:0) so any click or keyboard focus opens the picker; drag & drop handled in JS. */
.file-dropzone {
  position: relative;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  color: var(--gray-500);
  cursor: pointer;
  transition: border-color var(--duration-fast) ease, background var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
  background: var(--gray-50);
  overflow: hidden;
}
.file-dropzone:hover,
.file-dropzone.dragover {
  border-color: var(--brand-400);
  background: var(--brand-50);
  color: var(--brand-700);
}
.file-dropzone:focus-within {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .16);
}
.file-dropzone:has(> input.is-invalid) {
  border-color: var(--danger-500);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}
.file-dropzone > input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.file-dropzone-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  pointer-events: none;
}
.file-dropzone-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: var(--brand-50);
  color: var(--brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-1);
  transition: transform var(--duration-base) var(--ease-out);
}
.file-dropzone:hover .file-dropzone-icon,
.file-dropzone.dragover .file-dropzone-icon { transform: translateY(-3px); }
.file-dropzone-icon i { font-size: 1.5rem; }
.file-dropzone-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--gray-700);
}
.file-dropzone-sub {
  font-size: var(--text-xs);
  color: var(--gray-500);
}
.file-dropzone-btn {
  margin-top: var(--space-2);
  padding: 0.375rem 1.1rem;
  border-radius: var(--radius-full);
  background: var(--brand-600);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  box-shadow: var(--shadow-sm);
}

/* Photo / attached-file grid (used on detail pages) */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}
.file-card {
  background: #fff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--duration-base) ease, transform var(--duration-base) ease;
}
.file-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.file-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
}
/* Long file names wrap inside the card instead of truncating/overflowing */
.file-name {
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.file-display {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.file-info {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--gray-500);
  background: var(--gray-50);
}

/* --------------------------------------------------------------------------
   10. ALERTS (inline) — unified style
   -------------------------------------------------------------------------- */
.alert {
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}
.alert i { font-size: 1.1rem; margin-top: 1px; }
.alert-success { background: var(--success-50); color: var(--success-800); border-color: var(--success-100); }
.alert-danger  { background: var(--danger-50);  color: var(--danger-800);  border-color: var(--danger-100); }
.alert-warning { background: var(--warning-50); color: var(--warning-800); border-color: var(--warning-100); }
.alert-info    { background: var(--info-50);    color: var(--info-800);    border-color: var(--info-100); }
.alert ul { margin: var(--space-2) 0 0; padding-left: 1.25rem; }

/* --------------------------------------------------------------------------
   11. TOASTS (top-right)
   -------------------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: min(380px, calc(100vw - 2rem));
}
.fee-toast {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  position: relative;
  overflow: hidden;
  animation: toast-in var(--duration-slow) var(--ease-out);
  min-width: 300px;
}
.fee-toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}
.fee-toast.toast-success::before { background: var(--success-500); }
.fee-toast.toast-error::before   { background: var(--danger-500); }
.fee-toast.toast-warning::before { background: var(--warning-500); }
.fee-toast.toast-info::before    { background: var(--info-500); }
.fee-toast .toast-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.fee-toast.toast-success .toast-icon { background: var(--success-50); color: var(--success-600); }
.fee-toast.toast-error .toast-icon   { background: var(--danger-50);  color: var(--danger-600); }
.fee-toast.toast-warning .toast-icon { background: var(--warning-50); color: var(--warning-600); }
.fee-toast.toast-info .toast-icon    { background: var(--info-50);    color: var(--info-600); }
.fee-toast .toast-title { font-weight: 600; color: var(--gray-800); font-size: var(--text-sm); }
.fee-toast .toast-body  { font-size: var(--text-sm); color: var(--gray-600); margin-top: 2px; }
.fee-toast .toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--gray-400);
  font-size: 1rem;
  padding: 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.fee-toast .toast-close:hover { background: var(--gray-100); color: var(--gray-600); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
.fee-toast.leaving { animation: toast-out var(--duration-base) var(--ease-standard) forwards; }
@keyframes toast-out {
  to { opacity: 0; transform: translateX(24px); }
}

/* --------------------------------------------------------------------------
   12. MODALS
   -------------------------------------------------------------------------- */
.modal-content {
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}
.modal-header {
  border-bottom: 1px solid var(--gray-100);
  padding: var(--space-3) var(--space-4);
}
.modal-title { font-weight: 600; color: var(--gray-800); font-size: var(--text-base); }
.modal-body { padding: var(--space-4); color: var(--gray-700); font-size: var(--text-sm); }
.modal-footer {
  border-top: 1px solid var(--gray-100);
  padding: var(--space-2) var(--space-4);
  gap: var(--space-2);
}
.modal-backdrop.show { opacity: .5; }
.btn-close:focus { box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }

/* --------------------------------------------------------------------------
   13. INFO BOX & DETAIL ROWS
   -------------------------------------------------------------------------- */
.info-box {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.info-box-header {
  background: #fff;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--gray-100);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--gray-800);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.info-box-header .info-box-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--brand-50);
  color: var(--brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: var(--space-2);
  font-size: 0.9rem;
}
/* Collapsible Activity Log header (show page sidebar) */
.activity-log-header {
  cursor: pointer;
  user-select: none;
  transition: background-color var(--duration-fast) var(--ease-out);
}
.activity-log-header:hover { background-color: var(--gray-50); }
.activity-log-chevron {
  font-size: 0.8rem;
  color: var(--gray-500);
  transition: transform var(--duration-base) var(--ease-out);
}
.activity-log-header[aria-expanded="true"] .activity-log-chevron {
  transform: rotate(180deg);
}
.info-box-body { padding: var(--space-4); }
/* On ticket detail/show pages each info-box lives in its own spaced row
   (.row.mb-4 provides the 12px gap), so drop the info-box's own bottom margin
   to avoid doubling it — keeps the same tight rhythm as the compact forms. */
.container-content > .row.mb-4 > [class*="col-"] > .info-box { margin-bottom: 0; }

/* Ticket detail show page: two-column layout (70% main + 30% status sidebar) */
.ticket-layout {
  --bs-gutter-x: 1rem;
  --bs-gutter-y: 0.75rem;
}
.col-lg-70, .col-lg-30 {
  flex: 0 0 auto;
  width: 100%;
  padding-right: calc(var(--bs-gutter-x) * .5);
  padding-left: calc(var(--bs-gutter-x) * .5);
}
@media (min-width: 992px) {
  .col-lg-70 { flex: 0 0 70%; max-width: 70%; }
  .col-lg-30 { flex: 0 0 30%; max-width: 30%; }
}
.ticket-sidebar {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-3));
  align-self: flex-start;
}
/* Compact detail rows on the ticket show page (less gap) */
.ticket-detail .info-box-body { padding: var(--space-3); }
.ticket-detail .info-row { padding: var(--space-1) 0; }
.ticket-detail .info-label { min-width: 120px; }
.ticket-detail .row.mb-4 > [class*="col-"] > .info-box { margin-bottom: 0; }
.info-row {
  display: flex;
  align-items: flex-start;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--gray-100);
  gap: var(--space-3);
}
.info-row:last-child { border-bottom: none; }
.info-row:hover { background: var(--gray-50); border-radius: var(--radius-sm); }
.info-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-500);
  min-width: 140px;
  flex-shrink: 0;
}
.info-value {
  font-size: var(--text-sm);
  color: var(--gray-700);
  line-height: 1.5;
  flex: 1;
  word-break: break-word;
}
.info-value small { display: block; margin-top: 4px; font-size: var(--text-xs); color: var(--gray-500); }

/* --------------------------------------------------------------------------
   14. TIMELINE (activity logs)
   -------------------------------------------------------------------------- */
.timeline {
  position: relative;
  padding-left: 30px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--gray-200);
}
.timeline-item {
  position: relative;
  margin-bottom: var(--space-3);
}
.timeline-marker {
  position: absolute;
  left: -22px;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--gray-200);
}
.timeline-marker.marker-success { background: var(--success-500); }
.timeline-marker.marker-danger  { background: var(--danger-500); }
.timeline-marker.marker-warning { background: var(--warning-500); }
.timeline-marker.marker-info    { background: var(--info-500); }
.timeline-marker.marker-brand   { background: var(--brand-500); }
.timeline-marker.marker-neutral { background: var(--gray-400); }
.timeline-content {
  background: #fff;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand-500);
  box-shadow: var(--shadow-xs);
}
.timeline-content.tc-success { border-left-color: var(--success-500); }
.timeline-content.tc-danger  { border-left-color: var(--danger-500); }
.timeline-content.tc-warning { border-left-color: var(--warning-500); }
.timeline-content.tc-info    { border-left-color: var(--info-500); }
.timeline-content.tc-neutral { border-left-color: var(--gray-300); }
.timeline-title { margin: 0 0 4px; font-size: var(--text-sm); font-weight: 600; color: var(--gray-800); }
.timeline-text { margin: 0 0 8px; font-size: var(--text-sm); color: var(--gray-600); }
.timeline-date { font-size: var(--text-xs); color: var(--gray-500); }
.timeline-metadata {
  margin-top: var(--space-2);
  padding: var(--space-2);
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
}

/* --------------------------------------------------------------------------
   15. LOADING STATES
   -------------------------------------------------------------------------- */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  z-index: 5;
  border-radius: inherit;
}
.spinner-border { --bs-spinner-color: var(--brand-500); --bs-spinner-width: 2rem; --bs-spinner-height: 2rem; }
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --------------------------------------------------------------------------
   16. EMPTY STATE
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--gray-500);
}
.empty-state i {
  font-size: 2.25rem;
  color: var(--gray-300);
  display: block;
  margin-bottom: var(--space-2);
}
.empty-state .empty-title { font-weight: 600; color: var(--gray-700); font-size: var(--text-lg); }
.empty-state .empty-desc { font-size: var(--text-sm); margin: var(--space-2) 0 var(--space-4); }

/* --------------------------------------------------------------------------
   17. AUTH (login) PAGE
   -------------------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-gradient);
  position: relative;
  overflow: hidden;
  padding: var(--space-4);
}
.auth-page::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -10%;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
}
.auth-page::after {
  content: '';
  position: absolute;
  bottom: -25%;
  left: -5%;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
}
.auth-card {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  padding: var(--space-8);
  position: relative;
  z-index: 1;
  animation: auth-in .4s var(--ease-out);
}
@keyframes auth-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--brand-gradient-soft);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto var(--space-4);
}
.auth-title { font-weight: 700; color: var(--gray-800); text-align: center; }
.auth-subtitle { color: var(--gray-500); text-align: center; font-size: var(--text-sm); margin-bottom: var(--space-6); }
.auth-card .form-label { color: var(--gray-700); }
.auth-card .btn { height: 48px; width: 100%; }
/* Login inputs: match the 48px submit button so the form feels cohesive. */
.auth-card .form-control,
.auth-card .input-group-text {
  height: 48px;
}
.auth-card .input-group-text {
  color: var(--gray-500);
  border-color: var(--gray-300);
  font-size: 1rem;
}
.auth-card .form-control:focus { z-index: 3; }

/* --------------------------------------------------------------------------
   18. PAGE BLUEPRINT — reusable anatomy for ALL pages
   -------------------------------------------------------------------------- */

/* --- Page Header (breadcrumbs + title + description + actions) --- */
.page-header {
  background: #fff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  position: relative;
  overflow: hidden;
}
.page-header::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--brand-gradient);
}
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.page-header-text { min-width: 0; }
.page-header-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.page-header-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.page-header-icon.tone-brand   { background: var(--brand-50);   color: var(--brand-600); }
.page-header-icon.tone-success { background: var(--success-50); color: var(--success-600); }
.page-header-icon.tone-warning { background: var(--warning-50); color: var(--warning-600); }
.page-header-icon.tone-danger  { background: var(--danger-50);  color: var(--danger-600); }
.page-header-icon.tone-info    { background: var(--info-50);    color: var(--info-600); }
.page-header-icon.tone-neutral { background: var(--gray-100);   color: var(--gray-600); }
.page-header-desc {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin: 2px 0 0 0;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.page-header-sub {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--gray-100);
}

/* Breadcrumbs */
.breadcrumbs { margin-bottom: var(--space-2); }
.breadcrumb {
  --bs-breadcrumb-divider-color: var(--gray-400);
  font-size: var(--text-xs);
  margin: 0;
}
.breadcrumb-item a {
  color: var(--brand-600);
  text-decoration: none;
  font-weight: 500;
}
.breadcrumb-item a:hover { color: var(--brand-700); text-decoration: underline; }
.breadcrumb-item.active { color: var(--gray-500); }

/* --- Utility Bar (search / filters / toggles / bulk actions) --- */
.utility-bar {
  background: #fff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}
.utility-bar-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  margin-bottom: var(--space-2);
}
.utility-bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.utility-bar--compact {
  padding: var(--space-1) var(--space-2);
  margin-bottom: var(--space-2);
}
.utility-search { min-width: 220px; flex: 0 1 auto; }
.utility-search .form-control,
.utility-search .input-group { min-width: 220px; }
.utility-filters { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.utility-spacer { flex: 1 1 auto; }
.utility-toggles { display: flex; align-items: center; gap: var(--space-1); }
.utility-actions { display: flex; align-items: center; gap: var(--space-2); }
.utility-bar-extra { margin-top: var(--space-3); }

/* --- Card header text + toolbar (used by x-table-card) --- */
.card-header-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-title { margin: 0; font-size: var(--text-base); font-weight: 600; color: var(--gray-800); }
.card-subtitle { font-size: var(--text-xs); color: var(--gray-500); }
.card-toolbar { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; flex-wrap: wrap; }

/* --- Table footer (pagination / totals) --- */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--gray-100);
}
.table-footer-info { font-size: var(--text-xs); color: var(--gray-500); }
.table-footer-pagination .pagination { margin: 0; }

/* --- Alert component (x-alert) content layout --- */
.alert .alert-content { flex: 1; min-width: 0; }
.alert .alert-content strong { margin-bottom: 2px; }
.alert .btn-close { position: static; margin-left: auto; flex-shrink: 0; }
.alert.alert-dismissible { padding-right: var(--space-4); }

/* --------------------------------------------------------------------------
   19. RESPONSIVE HELPERS
   -------------------------------------------------------------------------- */
.container-content {
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--gray-200);
  padding: var(--space-2) var(--space-3);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  z-index: 5;
}

/* --------------------------------------------------------------------------
   19. REDUCED MOTION
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   20. MOBILE SIDEBAR BEHAVIOR
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
}
@media (min-width: 992px) {
  .sidebar-toggle { display: none; }
  .sidebar-backdrop { display: none; }
}

/* --------------------------------------------------------------------------
   21. COMPACT TYPE SCALE — Bootstrap fs-* utilities
   Shim Bootstrap's fixed font-size utility classes onto the compact scale.
   -------------------------------------------------------------------------- */
.fs-1 { font-size: 1.75rem !important; }
.fs-2 { font-size: 1.5rem !important; }
.fs-3 { font-size: 1.25rem !important; }
.fs-4 { font-size: 1.0625rem !important; }
.fs-5 { font-size: 0.9375rem !important; }
.fs-6 { font-size: 0.8125rem !important; }

/* Tighten default Bootstrap vertical rhythm that adds blank space */
.card .row, .row.mb-4, .row.mb-3, .row.mb-5 { margin-bottom: .25rem; --bs-gutter-y: 0.75rem; }
/* Uniform 12px rhythm across the whole app — matches the compact form gap */
.mb-3, .mb-4, .mb-5 { margin-bottom: 0.75rem !important; }
.mt-3, .mt-4, .mt-5 { margin-top: 0.75rem !important; }
.my-3, .my-4, .my-5 { margin-top: 0.75rem !important; margin-bottom: 0.75rem !important; }
/* Uniform compact vertical gutter for all stacked rows (matches the form) */
.row.g-3, .row.g-4 { --bs-gutter-y: 0.75rem; }

/* --- Compact .form-floating (align to tighter form controls) --- */
.form-floating > .form-control,
.form-floating > .form-select {
  height: 46px;
  min-height: 46px;
  padding: 0.5rem 0.75rem;
}
/* Selects always float their label, so give them top room (matches Bootstrap's
   1.5rem top padding used for filled inputs) so the value sits below the label
   instead of being overlapped by it. Native <select> centers its value in the
   content box; 46px keeps a 16px content box (same as before) so the value is
   never clipped while the whole control is ~6px shorter. */
.form-floating > .form-select {
  height: 46px;
  min-height: 46px;
  padding-top: 1.5rem;
  padding-bottom: 0.375rem;
  padding-right: 2.5rem;
}
/* Filled/focused inputs: Bootstrap's :not(:placeholder-shown) rule applies
   1.625rem/.625rem padding which leaves only a 10px content box at 46px and
   clips the value. Match the select's 1.5rem/.375rem so the 16px content box
   is preserved and the value never clips. */
.form-floating > .form-control:focus,
.form-floating > .form-control:not(:placeholder-shown) {
  padding-top: 1.5rem;
  padding-bottom: 0.375rem;
}
/* Resting label = centered placeholder; floats smoothly to the top on focus/fill
   (transform-based so the position animates, matching Bootstrap's behavior). */
.form-floating > label {
  top: 50%;
  transform: translateY(-50%);
  height: auto;
  padding: 0 0.75rem;
  font-size: var(--text-xs);
  line-height: 1.25;
  transition: top var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out),
              padding var(--duration-base) var(--ease-out),
              font-size var(--duration-base) var(--ease-out),
              opacity var(--duration-fast) ease;
}
/* Floated label: keep it INSIDE the input (cancel Bootstrap's up-translate that
   pushed it onto/above the top border), give it a readable size, and cap its
   height so it never overlays the value below. */
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select ~ label {
  top: 0;
  transform: none;
  height: auto;
  padding: 0.3rem 0.75rem 0.2rem;
  font-size: 0.72rem;
  line-height: 1.25;
  opacity: 1;
}

/* --------------------------------------------------------------------------
   22. MANUAL SIDEBAR COLLAPSE — slim icon rail (desktop)
   Toggle from the topbar hamburger; state persists via localStorage.
   When clipped, only icons remain so the main data area gets more room.
   -------------------------------------------------------------------------- */
@media (min-width: 992px) {
  body.sidebar-collapsed .sidebar { width: 64px; }
  body.sidebar-collapsed .main-wrapper { margin-left: 64px; }

  body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: var(--space-3) var(--space-2);
  }
  body.sidebar-collapsed .sidebar-brand > div:last-child { display: none; }
  body.sidebar-collapsed .sidebar-brand .brand-logo { width: 38px; height: 38px; font-size: 1.2rem; }

  body.sidebar-collapsed .sidebar-nav { padding: var(--space-2) var(--space-1); }
  body.sidebar-collapsed .sidebar-nav .nav-section { display: none; }
  body.sidebar-collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: var(--space-2) 0;
  }
  body.sidebar-collapsed .sidebar-nav .nav-link span { display: none; }
  body.sidebar-collapsed .sidebar-nav .nav-link i { font-size: 1.1rem; width: 1.25rem; }
  body.sidebar-collapsed .sidebar-nav .nav-link.active::before {
    left: 0;
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
  }
  body.sidebar-collapsed .sidebar-footer { padding: var(--space-3) var(--space-2); text-align: center; }
  body.sidebar-collapsed .sidebar-footer small { display: none; }
}

/* Keep the manual toggle available on desktop too */
@media (min-width: 992px) {
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   23. COMPACT INTEGRATED FILTER FORM (ELSM My Tickets)
   Small labeled fields that wrap tightly so the filter row stays slim.
   -------------------------------------------------------------------------- */
.filter-form {
  row-gap: var(--space-2);
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.filter-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-500);
  letter-spacing: .02em;
}
.filter-form .form-control,
.filter-form .form-select {
  height: 34px;
  padding-top: .25rem;
  padding-bottom: .25rem;
}
/* Uniform width for every filter dropdown so the row looks tidy */
.filter-form .form-select {
  width: 175px;
  min-width: 175px;
  max-width: 175px;
  padding-right: 2rem;
  background-position: right .55rem center;
  background-size: 12px 10px;
}
.filter-form .btn {
  height: 34px;
}

/* --------------------------------------------------------------------------
   24. COLLAPSIBLE FILTER PANEL
   The search/filter form is clipped (hidden) by default; clicking the
   "Search & Filter" toggle expands it. Auto-shown when filters are active.
   -------------------------------------------------------------------------- */
.filter-toggle {
  white-space: nowrap;
}
.filter-toggle .filter-caret {
  transition: transform var(--duration-fast) ease;
}
.filter-toggle .filter-caret.rotated {
  transform: rotate(180deg);
}
.filter-collapse {
  display: none;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--gray-200);
}
.filter-collapse.show {
  display: block;
}
.filter-total {
  white-space: nowrap;
  line-height: 1.2;
}

/* --------------------------------------------------------------------------
   25. CUSTOM SELECT — styled dropdown replacing native <select>
   Every native select is transformed at runtime into a branded trigger + a
   fixed-position popup menu (escapes card/table overflow clipping). The
   original <select> stays in the DOM (visually hidden) so form submission,
   validation and JS reading its .value/change keep working unchanged.
   -------------------------------------------------------------------------- */
.custom-select {
  position: relative;
  display: block;
}
/* Visually-hidden native select — keeps name/id/value/required for the form
   and keeps the paperless label-float rule (.form-floating > .form-select ~ label) alive. */
.custom-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0;
  pointer-events: none;
}
/* Trigger — mirrors the .form-select look (slate tint, brand chevron, pointer). */
.custom-select-control {
  display: block;
  width: 100%;
  height: 36px;
  padding: .4375rem .75rem;
  padding-right: 2.5rem;
  background-color: var(--gray-50);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236366f1' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 14px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  color: var(--gray-700);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color var(--duration-fast) ease,
              box-shadow var(--duration-fast) ease,
              background-color var(--duration-fast) ease;
}
.custom-select-control:hover:not(.custom-select[aria-disabled="true"] *) {
  border-color: var(--brand-300);
}
.custom-select-control:focus-visible,
.custom-select.is-open .custom-select-control {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .16);
  outline: none;
}
.custom-select.is-open .custom-select-control {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236366f1' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='m2 11 6-6 6 6'/%3e%3c/svg%3e");
}

/* Context sizes */
.filter-form .custom-select,
.filter-form .custom-select-menu { width: 175px; min-width: 175px; max-width: 175px; }
.filter-form .custom-select-control {
  height: 34px;
  padding: .25rem 2rem .25rem .75rem;
  background-position: right .55rem center;
  background-size: 12px 10px;
}
.form-floating .custom-select,
.form-floating .custom-select-control { height: 46px; }
.form-floating .custom-select-control {
  padding-top: 1.5rem;
  padding-bottom: .375rem;
  padding-right: 2.5rem;
}

/* Popup menu — position:fixed so it escapes overflow:hidden ancestors
   (e.g. .table-card). Placed by JS under the trigger (or above when tight). */
.custom-select-menu {
  position: fixed;
  z-index: 1070;
  display: none;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 6px;
  padding: var(--space-2);
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: custom-select-in var(--duration-fast) var(--ease-out);
}
.custom-select.open-up .custom-select-menu {
  margin-top: 0;
  margin-bottom: 6px;
}
.custom-select.is-open .custom-select-menu { display: block; }

@keyframes custom-select-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.custom-select.open-up .custom-select-menu {
  animation-name: custom-select-in-up;
}
@keyframes custom-select-in-up {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.custom-select-option {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--gray-700);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}
.custom-select-option:hover,
.custom-select-option:focus-visible {
  background: var(--brand-50);
  color: var(--brand-700);
  outline: none;
}
.custom-select-option.is-selected {
  color: var(--brand-700);
  font-weight: 600;
}
.custom-select-option-check {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--brand-600);
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
}
.custom-select-option.is-selected .custom-select-option-check { opacity: 1; }
.custom-select-option:hover .custom-select-option-check { opacity: .45; }
.custom-select-option.is-selected:hover .custom-select-option-check { opacity: 1; }

/* Validation + disabled states (mirrored from the hidden native select). */
.custom-select.is-invalid .custom-select-control,
.custom-select.is-invalid .custom-select-control:focus-visible {
  border-color: var(--danger-500);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}
.custom-select.is-valid .custom-select-control {
  border-color: var(--success-500);
}
.custom-select.is-disabled .custom-select-control {
  background-color: var(--gray-100);
  color: var(--gray-500);
  cursor: not-allowed;
  opacity: .85;
}
