.index-as-table table {
  white-space: nowrap;
  white-space-collapse: collapse;
  text-wrap-mode: nowrap;
}

a {
  text-decoration: none;
}

/* Tighten index row height slightly (10-15% reduction). */
.index-as-table .data-table :where(tbody>tr>td),
table.index_table tbody tr td {
  padding: 0.675rem 0.55rem;
}

:root[data-index-density="compact"] .index-as-table .data-table :where(thead>tr>th),
:root[data-index-density="compact"] table.index_table thead tr th {
  padding: 0.5rem 0.45rem;
}

:root[data-index-density="compact"] .index-as-table .data-table :where(tbody>tr>td),
:root[data-index-density="compact"] table.index_table tbody tr td {
  padding: 0.45rem 0.45rem;
}

.form-table.has_many .has-many-fields .input:last-child {
  margin-bottom: 0 !important;
}

/* Smaller pagination info text. */
.pagination-information,
.paginated-collection-footer {
  font-size: 0.875rem;
}

.dark .pagination-information,
.dark .paginated-collection-footer {
  font-size: 0.875rem;
}

/* Product UI paginator styling for default Kaminari markup. */
body[data-product-controller] nav.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

body[data-product-controller] nav.pagination > span,
body[data-product-controller] nav.pagination > a {
  display: inline-flex;
}

body[data-product-controller] nav.pagination a,
body[data-product-controller] nav.pagination .current,
body[data-product-controller] nav.pagination .gap,
body[data-product-controller] nav.pagination .disabled {
  display: inline-flex;
  min-width: 2.5rem;
  min-height: 2.5rem;
  align-items: center;
  justify-content: center;
  padding: 0 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 9999px;
  background: #ffffff;
  color: #374151;
  font-size: 0.875rem;
  line-height: 1;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

body[data-product-controller] nav.pagination a:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  color: #111827;
  transform: translateY(-1px);
}

body[data-product-controller] nav.pagination a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

body[data-product-controller] nav.pagination .current {
  border-color: #111827;
  background: #111827;
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

body[data-product-controller] nav.pagination .gap {
  min-width: auto;
  padding: 0 0.5rem;
  border-style: dashed;
  background: transparent;
  color: #9ca3af;
  box-shadow: none;
}

body[data-product-controller] nav.pagination .disabled {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #9ca3af;
  box-shadow: none;
  cursor: not-allowed;
}

.dark body[data-product-controller] nav.pagination a,
.dark body[data-product-controller] nav.pagination .gap,
.dark body[data-product-controller] nav.pagination .disabled {
  border-color: #374151;
  background: #111827;
  color: #d1d5db;
  box-shadow: none;
}

.dark body[data-product-controller] nav.pagination a:hover {
  border-color: #60a5fa;
  background: #1f2937;
  color: #ffffff;
}

.dark body[data-product-controller] nav.pagination .current {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #111827;
}

.dark body[data-product-controller] nav.pagination .gap {
  border-color: transparent;
  background: transparent;
  color: #6b7280;
}

.dark body[data-product-controller] nav.pagination .disabled {
  border-color: #1f2937;
  background: #0f172a;
  color: #6b7280;
}

@media (max-width: 640px) {
  body[data-product-controller] nav.pagination {
    gap: 0.375rem;
  }

  body[data-product-controller] nav.pagination a,
  body[data-product-controller] nav.pagination .current,
  body[data-product-controller] nav.pagination .gap,
  body[data-product-controller] nav.pagination .disabled {
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0 0.75rem;
    font-size: 0.8125rem;
  }
}

/* Consistent action button styling (Stripe-like) */
.action-item-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  /* background: #ffffff; */
  /* color: #111827; */
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}

.action-item-button:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  color: #111827;
  text-decoration: none;
}

.action-item-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

.action-item-button:disabled,
.action-item-button.disabled,
.action-item-button[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.action-item-button--primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.action-item-button--primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}

.action-item-button--secondary {
  background: #ffffff;
  border-color: #d1d5db;
  color: #111827;
}

.action-item-button--danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

.action-item-button--danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #ffffff;
}

.action-item-button--success {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.action-item-button--success:hover {
  background: #15803d;
  border-color: #15803d;
  color: #ffffff;
}

.batch-actions-dropdown-menu {
  z-index: 50 !important;
}

/* Floating batch action bar (Jira-style) */
.floating-batch-bar {
  opacity: 0;
  transform: translateX(-50%) translateY(1.5rem);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
  pointer-events: none;
}
.floating-batch-bar--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.batch-actions-dropdown-menu a[data-icon]::before {
  font-family: "Material Symbols Outlined";
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  content: attr(data-icon);
  display: inline-flex;
  margin-right: 0.5rem;
  font-size: 1rem;
  line-height: 1;
  vertical-align: middle;
}

.tabs.tabs--vertical {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  width: 100%;
}

.tabs.tabs--vertical .tabs-nav {
  width: 14rem;
  min-width: 14rem;
  margin-bottom: 0;
  flex-direction: column;
  flex-wrap: nowrap;
  border-bottom-width: 0;
  border-right-width: 1px;
  text-align: left;
}

.tabs.tabs--vertical .tabs-nav > a {
  width: 100%;
  border-bottom-width: 0;
  border-right-width: 2px;
  border-top-right-radius: 0;
  border-bottom-left-radius: 0.375rem;
  border-bottom-right-radius: 0;
  padding: 0.75rem 1rem;
}

.tabs.tabs--vertical .tabs-content {
  flex: 1 1 0%;
  width: 0;
  max-width: 100%;
  min-width: 0;
  padding-top: 0;
}

.tabs.tabs--vertical .tabs-content > [role="tabpanel"] {
  width: 100%;
}

@media (max-width: 767px) {
  .tabs.tabs--vertical {
    display: block;
  }

  .tabs.tabs--vertical .tabs-nav {
    width: auto;
    min-width: 0;
    margin-bottom: 0.5rem;
    flex-direction: row;
    flex-wrap: wrap;
    border-right-width: 0;
    border-bottom-width: 1px;
    text-align: center;
  }

  .tabs.tabs--vertical .tabs-nav > a {
    width: auto;
    border-right-width: 0;
    border-bottom-width: 2px;
    border-top-right-radius: 0.375rem;
    border-bottom-left-radius: 0;
  }

  .tabs.tabs--vertical .tabs-content {
    padding-top: 1rem;
  }
}

/* Hide hidden inputs completely so they don't take space */
.form-table.has_many .has-many-fields .input.hidden,
.form-table.has_many .has-many-fields .input input[type="hidden"] {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  margin-right: 1rem !important;
  padding: 0 !important;
  border: none !important;
  overflow: hidden !important;
  position: absolute !important;
  left: -9999px !important;
}

/* Essential CSS for horizontal row layout */
.form-table.has_many .has-many-fields {
  display: flex !important;
  align-items: flex-start !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 1rem !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 0.5rem !important;
  margin-bottom: 0.25rem !important;
  padding: 1rem !important;
}

.form-table.has_many .has-many-fields .input {
  display: inline-block !important;
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 120px !important;
  margin-right: 1rem !important;
  padding: 0 !important;
  vertical-align: top !important;
}

/* Hide labels in all rows except the first (header) */
.form-table.has_many .has-many-fields .input:not(.boolean) label {
  display: none !important;
}

/* Show labels only in the first row (header) */
.form-table.has_many .has-many-fields:first-child .input label {
  display: block !important;
  color: #374151 !important;
  margin: 0 !important;
  padding: 0 !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.05em !important;
}



.form-table.has_many .has-many-fields{
  margin: 0;
}
/* Ensure inputs are properly sized for horizontal layout */
.form-table.has_many .has-many-fields .input input:not([type="checkbox"]),
.form-table.has_many .has-many-fields .input select,
.form-table.has_many .has-many-fields .input textarea {
  width: auto !important;
  min-width: 120px !important;
  max-width: 200px !important;
  display: inline-block !important;
  margin: 0 !important;
}

/* Force horizontal layout for all has-many fields */
.form-table.has_many .has-many-fields {
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  /* overflow-x: auto !important; */
}

/* Remove the debug borders now that layout is working */
.form-table.has_many .has-many-fields {
  border: 1px solid #e5e7eb !important;
}

.form-table.has_many .has-many-fields .input {
  border: none !important;
}

/* Form grid layout for regular form inputs */
.form-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
  gap: 1rem !important;
  align-items: start !important;
}

/* Right-aligned form section with inline labels */
.align-end.inputs {
  text-align: right !important;
  justify-content: flex-end !important;
}

.align-end.inputs ol {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  gap: 0.25rem !important;
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.align-end.inputs .input {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 0.5rem !important;
  width: auto !important;
  min-width: 200px !important;
  padding-top: 0.25rem !important;
  padding-bottom: 0.25rem !important;
}

.align-end.inputs .input label {
  display: inline-block !important;
  margin: 0 !important;
  padding: 0 !important;
  white-space: nowrap !important;
  min-width: 120px !important;
  text-align: right !important;
  font-weight: bold !important;
  text-transform: uppercase !important;
}

.align-end.inputs .input input,
.align-end.inputs .input select,
.align-end.inputs .input textarea {
  width: 120px !important;
  min-width: 120px !important;
  max-width: 120px !important;
  text-align: right !important;
}

/* Override ActiveAdmin's default form layout */
.form-grid.inputs {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
  gap: 1rem !important;
}

.form-grid.inputs .input {
  float: none !important;
  width: auto !important;
  margin-right: 0 !important;
  margin-bottom: 0 !important;
}

/* Target the ol element that ActiveAdmin uses to wrap inputs */
.form-grid ol,
.form-grid.inputs ol {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
  gap: 1rem !important;
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.form-grid ol li,
.form-grid.inputs ol li {
  float: none !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Responsive adjustments for form grid */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  
  .form-grid .input {
    padding: 0.5rem !important;
  }
}

/* Clean header styling for the first row */
.form-table.has_many .has-many-fields:nth-of-type(1) {
  background: transparent !important;
  color: #374151 !important;
  border: 1px solid #e5e7eb !important;
  padding: 1rem !important;
  margin-bottom: 0.25rem !important;
  border-radius: 0.5rem !important;
}

.form-table.has_many .has-many-fields:nth-of-type(1) .input label,
.form-table.has_many .has-many-fields:nth-of-type(1) .input .label {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.05em !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Alternative selector for compatibility */
.form-table.has_many .has-many-fields:first-of-type {
  background: transparent !important;
  color: #374151 !important;
  border: 1px solid #e5e7eb !important;
  padding: 1rem !important;
  margin-bottom: 0.25rem !important;
  border-radius: 0.5rem !important;
}

.form-table.has_many .has-many-fields:first-of-type .input label,
.form-table.has_many .has-many-fields:first-of-type .input .label {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.05em !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Debug: Add a border to see the first row clearly */
.form-table.has_many .has-many-fields:first-child {
  border: 1px solid #e5e7eb !important;
}

/* Debug: Add border to see the layout */
.form-table.has_many .has-many-fields {
  border: 1px solid #e5e7eb !important;
}

.form-table.has_many .has-many-fields .input {
  border: none !important;
}
fieldset.has-many-fields {
  overflow: visible !important;
}

/** Restrict form width for professional appearance */
/* Default form background */
/* .formtastic:not(.payment, .form-settings, .purchase_order, .quote, .sales_order, .invoice, .transaction, .repayment_schedule, .journal_entry) {
  max-width: 700px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  width: 100% !important;
  box-sizing: border-box !important;
  background: white !important;
  padding: 2rem !important;
  border-radius: 0.5rem !important; 
  border-width: 2px;
} */

/* Dark mode support using :where(.dark, .dark *) selector */
.formtastic:not(.purchase_order, .quote, .sales_order, .invoice, .transaction, .repayment_schedule):where(.dark, .dark *) {
  background: #23272f !important;
  color: #f3f4f6 !important;
}

/* Semantic Errors Caption Styling */
.semantic-errors-container {
  margin-bottom: 1.5rem !important;
  padding: 1rem !important;
  background-color: #fef2f2 !important;
  border: 1px solid #fecaca !important;
  border-radius: 0.5rem !important;
  border-left: 4px solid #ef4444 !important;
}

.semantic-errors-caption {
  color: #dc2626 !important;
  font-size: 1.125rem !important;
  font-weight: 600 !important;
  margin: 0 0 0.75rem 0 !important;
  padding: 0 !important;
  line-height: 1.4 !important;
}

.semantic-errors-container .errors {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

.semantic-errors-container .errors li {
  color: #dc2626 !important;
  font-size: 0.875rem !important;
  margin-bottom: 0.25rem !important;
  padding-left: 1rem !important;
  position: relative !important;
}

.semantic-errors-container .errors li:before {
  content: "•" !important;
  color: #ef4444 !important;
  font-weight: bold !important;
  position: absolute !important;
  left: 0 !important;
}

/* Dark mode support for semantic errors */
:where(.dark, .dark *) .semantic-errors-container {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
  border-left-color: #ef4444 !important;
}

:where(.dark, .dark *) .semantic-errors-caption {
  color: #fca5a5 !important;
}

:where(.dark, .dark *) .semantic-errors-container .errors li {
  color: #fca5a5 !important;
}

.right-align,
[data-column="net_amount"],
[data-column="amount"],
[data-column="debit"],
[data-column="credit"],
[data-column="debit_ccy"],
[data-column="credit_ccy"] {
  text-align: right !important;
}
.marker {
  background-color: #f0f0f0 !important;
}
.marker:where(.dark, .dark *) {
  background-color: #374151 !important;
}
.marker:where(.dark, .dark *):hover {
  background-color: #1e293b !important;
}

[data-status="posted"] {
  color: white !important;
  background-color: #16a34a !important; /* Tailwind's green-600 */
}
[data-status="posted"]:where(.dark, .dark *) {
  color: white !important;
  background-color: #16a34a !important; /* Tailwind's green-600 */
}
/* panel fullscreen */
.panel.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: white;
   overflow: auto;
}

/* Customer Balance Display Styling */
.balance-display {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
}

.badge {
  display: inline-block !important;
  padding: 0.25rem 0.75rem !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  text-align: center !important;
  white-space: nowrap !important;
  vertical-align: baseline !important;
  border-radius: 0.375rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.025em !important;
}

.badge-lg {
  padding: 0.5rem 1rem !important;
  font-size: 0.875rem !important;
}

.badge-warning {
  color: #92400e !important;
  background-color: #fef3c7 !important;
  border: 1px solid #f59e0b !important;
}

.badge-success {
  color: #065f46 !important;
  background-color: #d1fae5 !important;
  border: 1px solid #10b981 !important;
}

.badge-danger {
  color: #991b1b !important;
  background-color: #fee2e2 !important;
  border: 1px solid #ef4444 !important;
}

.text-muted {
  color: #6b7280 !important;
  font-size: 0.875rem !important;
}

/* Dark mode support for balance display */
:where(.dark, .dark *) .badge-warning {
  color: #fbbf24 !important;
  background-color: #451a03 !important;
  border-color: #f59e0b !important;
}

:where(.dark, .dark *) .badge-success {
  color: #34d399 !important;
  background-color: #064e3b !important;
  border-color: #10b981 !important;
}

:where(.dark, .dark *) .badge-danger {
  color: #fca5a5 !important;
  background-color: #7f1d1d !important;
  border-color: #ef4444 !important;
}

:where(.dark, .dark *) .text-muted {
  color: #9ca3af !important;
}

/* Remove list bullets from transaction forms */
.transaction > li {
  list-style: none !important;
}

.transaction li {
  list-style: none !important;
}

.transaction .inputs {
  list-style: none !important;
}

.transaction .inputs li {
  list-style: none !important;
}

/* Chat Message Styles */
.user-bubble {
  @apply ml-auto max-w-[85%] mb-4;
  @apply bg-blue-600 text-white rounded-2xl rounded-tr-none px-4 py-3;
  @apply shadow-sm;
}

.system-bubble {
  @apply mr-auto max-w-[85%] mb-4;
  @apply bg-white dark:bg-gray-700 text-gray-900 dark:text-white;
  @apply rounded-2xl rounded-tl-none px-4 py-3 border border-gray-200 dark:border-gray-600;
  @apply shadow-sm;
}

.message {
  @apply break-words;
  animation: messageSlideIn 0.3s ease-out;
}

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

/* Loading indicator styles */
.loading-indicator {
  @apply flex items-center space-x-2 text-gray-600 dark:text-gray-400 italic;
}

/* In-chat form container */
.in-chat-form-container {
  @apply bg-white dark:bg-gray-800 rounded-lg shadow-md p-4 my-2;
  @apply border border-gray-200 dark:border-gray-600;
}

/* Hide filter containers by default to prevent flash on page load */
/* JavaScript will remove the hiding once initial state is applied */
/* Target specific filter container selectors used by the JavaScript */
/* #filters_sidebar_section,
.sidebar_section,
.filters,
.filter_form {
  display: none !important;
} */

/* Hide .space-y-8 elements that are filter containers (within sidebar/filter contexts) */
/* Note: The JS also selects standalone .space-y-8, but we only hide them in filter contexts */
/* to avoid breaking other layout elements that use this Tailwind utility class */
/* #filters_sidebar_section .space-y-8,
.sidebar_section .space-y-8,
.filters .space-y-8,
.filter_form .space-y-8 {
  display: none !important;
} */

/* Prevent brief flash of filter container wrappers before JS marks ready */
/* body:not(.filters-ready) .main-content-container .space-y-8 {
  display: none !important;
} */

/* As a fallback, hide any standalone .space-y-8 until filters are ready */
/* body:not(.filters-ready) .space-y-8 {
  display: none !important;
} */

/* When filters are ready, allow them to render normally */
/* body.filters-ready #filters_sidebar_section,
body.filters-ready .sidebar_section,
body.filters-ready .filters,
body.filters-ready .filter_form,
body.filters-ready #filters_sidebar_section .space-y-8,
body.filters-ready .sidebar_section .space-y-8,
body.filters-ready .filters .space-y-8,
body.filters-ready .filter_form .space-y-8 {
  display: block !important;
} */

/* Restore standalone space-y-8 once ready */
/*body.filters-ready .space-y-8 {
  display: block !important;
} */

/* Modern styling enhancements for Tom Select dropdowns */
.ts-dropdown {
  border-radius: 0.5rem !important;
  border: 1px solid rgba(209, 213, 219, 0.8) !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
  margin-top: 0.5rem !important;
  background: #ffffff !important;
  overflow: hidden;
  transition: opacity 0.15s ease-in-out, transform 0.15s ease-in-out;
  z-index: 9999 !important;
}

/* Dark mode support for dropdown */
.dark .ts-dropdown {
  background: #1f2937 !important;
  border-color: rgba(75, 85, 99, 0.8) !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2) !important;
}

/* Modern dropdown content styling */
.ts-dropdown-content {
  max-height: 300px !important;
  padding: 0.25rem !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
}

.ts-dropdown-content::-webkit-scrollbar {
  width: 8px;
}

.ts-dropdown-content::-webkit-scrollbar-track {
  background: transparent;
}

.ts-dropdown-content::-webkit-scrollbar-thumb {
  background-color: rgba(156, 163, 175, 0.5);
  border-radius: 4px;
}

.ts-dropdown-content::-webkit-scrollbar-thumb:hover {
  background-color: rgba(156, 163, 175, 0.7);
}

.dark .ts-dropdown-content::-webkit-scrollbar-thumb {
  background-color: rgba(75, 85, 99, 0.5);
}

.dark .ts-dropdown-content::-webkit-scrollbar-thumb:hover {
  background-color: rgba(75, 85, 99, 0.7);
}

/* Modern option styling */
.ts-dropdown .option {
  padding: 0.625rem 0.875rem !important;
  margin: 0.125rem 0 !important;
  border-radius: 0.375rem !important;
  transition: all 0.15s ease-in-out !important;
  cursor: pointer;
  color: #374151 !important;
  font-size: 0.875rem !important;
  line-height: 1.25rem !important;
}

.dark .ts-dropdown .option {
  color: #e5e7eb !important;
}

/* Hover state for options */
.ts-dropdown [data-selectable].option:hover {
  background-color: #f3f4f6 !important;
  color: #111827 !important;
  transform: translateX(2px);
}

.dark .ts-dropdown [data-selectable].option:hover {
  background-color: #374151 !important;
  color: #f9fafb !important;
}

/* Active/selected option styling */
.ts-dropdown .active {
  background-color: #eff6ff !important;
  color: #1e40af !important;
  font-weight: 500 !important;
}

.dark .ts-dropdown .active {
  background-color: #1e3a8a !important;
  color: #dbeafe !important;
}

/* Focus state for keyboard navigation */
.ts-dropdown [data-selectable].option:focus {
  outline: none;
  background-color: #eff6ff !important;
  color: #1e40af !important;
}

.dark .ts-dropdown [data-selectable].option:focus {
  background-color: #1e3a8a !important;
  color: #dbeafe !important;
}

/* Highlighted search text */
.ts-dropdown [data-selectable] .highlight {
  background: rgba(59, 130, 246, 0.3) !important;
  border-radius: 0.125rem !important;
  padding: 0.125rem 0.25rem !important;
  font-weight: 600 !important;
}

.dark .ts-dropdown [data-selectable] .highlight {
  background: rgba(96, 165, 250, 0.3) !important;
  color: #dbeafe !important;
}

/* Disabled options */
.ts-dropdown [data-disabled],
.ts-dropdown [data-disabled] [data-selectable].option {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  background-color: transparent !important;
}

/* Optgroup headers */
.ts-dropdown .optgroup-header {
  padding: 0.75rem 0.875rem 0.5rem !important;
  font-weight: 600 !important;
  font-size: 0.75rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  color: #6b7280 !important;
  background: #f9fafb !important;
  border-bottom: 1px solid #e5e7eb !important;
  margin-top: 0.5rem !important;
}

.dark .ts-dropdown .optgroup-header {
  color: #9ca3af !important;
  background: #111827 !important;
  border-bottom-color: #374151 !important;
}

.ts-dropdown .optgroup:first-child .optgroup-header {
  margin-top: 0 !important;
  border-top: none !important;
}

/* No results message */
.ts-dropdown .no-results {
  padding: 1rem 0.875rem !important;
  color: #6b7280 !important;
  font-size: 0.875rem !important;
  text-align: center !important;
}

.dark .ts-dropdown .no-results {
  color: #9ca3af !important;
}

/* Create option styling */
.ts-dropdown .create {
  padding: 0.625rem 0.875rem !important;
  color: #3b82f6 !important;
  font-weight: 500 !important;
  border-radius: 0.375rem !important;
  margin: 0.125rem 0 !important;
}

.ts-dropdown .create:hover {
  background-color: #eff6ff !important;
}

.dark .ts-dropdown .create {
  color: #60a5fa !important;
}

.dark .ts-dropdown .create:hover {
  background-color: #1e3a8a !important;
}

.ts-dropdown .active.create {
  background-color: #eff6ff !important;
  color: #1e40af !important;
}

.dark .ts-dropdown .active.create {
  background-color: #1e3a8a !important;
  color: #dbeafe !important;
}

/* Control input styling improvements */
/* Ensure ts-wrapper has no border to prevent double border issue */
.ts-wrapper {
  border: none !important;
  outline: none !important;
  padding: 0 !important;
}

/* Remove Tailwind padding classes from ts-wrapper */
.ts-wrapper.px-3,
.ts-wrapper.py-2,
.ts-wrapper.px-3.py-2,
.ts-wrapper[class*="px-"],
.ts-wrapper[class*="py-"] {
  padding: 0 !important;
}

/* Hide the original select when TomSelect takes over */
.ts-hidden-accessible {
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
  -webkit-clip-path: inset(50%) !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  width: 1px !important;
  white-space: nowrap !important;
}

/* Ensure original select element inside wrapper has no border */
.ts-wrapper select {
  border: none !important;
  outline: none !important;
}

.ts-control {
  border-radius: 0.5rem !important;
  border: 1px solid #d1d5db !important;
  transition: all 0.15s ease-in-out !important;
  background: #ffffff !important;
  margin: 0 !important;
}

.ts-control:hover {
  border-color: #9ca3af !important;
}

.ts-wrapper.focus .ts-control {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
  outline: none !important;
}

.dark .ts-control {
  background: #1f2937 !important;
  border-color: #4b5563 !important;
  color: #e5e7eb !important;
}

.dark .ts-control:hover {
  border-color: #6b7280 !important;
}

.dark .ts-wrapper.focus .ts-control {
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2) !important;
}

.ts-wrapper.signup-country-select {
  width: 100%;
}

.ts-wrapper.signup-country-select .ts-control {
  align-items: center !important;
  flex-wrap: nowrap !important;
  min-height: 3rem !important;
  padding: 0.75rem 1rem !important;
}

.ts-wrapper.signup-country-select .ts-control > input {
  width: 0 !important;
  min-width: 0 !important;
  flex: 0 0 0 !important;
  margin: 0 !important;
  opacity: 0 !important;
  position: absolute !important;
  left: -10000px !important;
}

.ts-wrapper.signup-country-select .ts-control > .item,
.ts-wrapper.signup-country-select .ts-control > div {
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.5rem !important;
}

.ts-wrapper.signup-country-select .ts-dropdown {
  margin-top: 0.25rem !important;
}

/* Multi-select item styling */
.ts-wrapper.multi .ts-control > div {
  border-radius: 0.375rem !important;
  padding: 0.25rem 0.5rem !important;
  margin: 0.125rem 0.25rem 0.125rem 0 !important;
  background: #eff6ff !important;
  color: #1e40af !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  border: 1px solid #bfdbfe !important;
  transition: all 0.15s ease-in-out !important;
}

.ts-wrapper.multi .ts-control > div:hover {
  background: #dbeafe !important;
  border-color: #93c5fd !important;
}

.ts-wrapper.multi .ts-control > div.active {
  background: #dbeafe !important;
  border-color: #93c5fd !important;
}

.dark .ts-wrapper.multi .ts-control > div {
  background: #1e3a8a !important;
  color: #dbeafe !important;
  border-color: #3b82f6 !important;
}

.dark .ts-wrapper.multi .ts-control > div:hover,
.dark .ts-wrapper.multi .ts-control > div.active {
  background: #1e40af !important;
  border-color: #60a5fa !important;
}

/* Loading spinner styling */
.ts-dropdown .spinner {
  margin: 1rem auto !important;
}

.ts-dropdown .spinner::after {
  border-color: #3b82f6 transparent #3b82f6 transparent !important;
}

.dark .ts-dropdown .spinner::after {
  border-color: #60a5fa transparent #60a5fa transparent !important;
}

/* Dropdown input plugin styling */
.plugin-dropdown_input .dropdown-input {
  border-color: #e5e7eb !important;
  padding: 0.75rem !important;
  font-size: 0.875rem !important;
  border-radius: 0 !important;
}

.dark .plugin-dropdown_input .dropdown-input {
  background: #1f2937 !important;
  color: #e5e7eb !important;
  border-color: #4b5563 !important;
}

.plugin-dropdown_input .dropdown-input:focus {
  outline: none;
  border-color: #3b82f6 !important;
}

.dark .plugin-dropdown_input .dropdown-input:focus {
  border-color: #60a5fa !important;
}

/* Column visibility is managed by ColumnPicker JS to avoid initial flicker. */
html.column-picker-loading table.index_table,
html.column-picker-loading #index_table,
html.column-picker-loading div.index_as_table table,
html.column-picker-loading div.index-as-table table,
html.column-picker-loading .index-as-table table,
html.column-picker-loading table[class*="index"],
html.column-picker-loading .paginated_collection table,
html.column-picker-loading div.paginated_collection table {
  visibility: hidden;
}

.column-picker-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 92vw);
  background: #ffffff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -12px 0 24px rgba(15, 23, 42, 0.12);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 70;
  display: flex;
  flex-direction: column;
}

.column-picker-drawer.is-open {
  transform: translateX(0);
}

.column-picker-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 60;
}

.column-picker-backdrop-visible {
  opacity: 1;
}

body.column-picker-drawer-open {
  overflow: hidden;
}

.column-picker-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
}

.column-picker-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  width: 2rem;
  border-radius: 9999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #6b7280;
}

.column-picker-drawer-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.column-picker-drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.column-picker-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.column-picker-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: #6b7280;
}

.column-picker-density-toggle {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 0.75rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}

.column-picker-density-option {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.45rem 0.6rem;
  border-radius: 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
}

.column-picker-density-option.is-active {
  background: #2563eb;
  color: #ffffff;
}

.column-picker-groupby {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.column-picker-groupby-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: 0.6rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #374151;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}

.column-picker-groupby-option:hover {
  background: #f3f4f6;
  color: #111827;
}

.column-picker-groupby-option.is-active {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
}

.column-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 360px;
  overflow-y: auto;
}

.column-picker-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem 1.25rem;
  border-top: 1px solid #e5e7eb;
}

.column-picker-action-button {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #374151;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
}

.column-picker-action-button:hover {
  background: #e5e7eb;
}

.dark .column-picker-drawer {
  background: #111827;
  border-color: #1f2937;
}

.dark .column-picker-drawer-header,
.dark .column-picker-actions {
  border-color: #1f2937;
}

.dark .column-picker-drawer-close {
  border-color: #1f2937;
  background: #111827;
  color: #9ca3af;
}

.dark .column-picker-drawer-close:hover {
  background: #1f2937;
  color: #e5e7eb;
}

.dark .column-picker-section-label {
  color: #9ca3af;
}

.dark .column-picker-density-toggle {
  background: #1f2937;
  border-color: #374151;
}

.dark .column-picker-density-option {
  color: #9ca3af;
}

.dark .column-picker-density-option.is-active {
  background: #3b82f6;
  color: #ffffff;
}

.dark .column-picker-groupby-option {
  background: #111827;
  border-color: #374151;
  color: #e5e7eb;
}

.dark .column-picker-groupby-option:hover {
  background: #1f2937;
  color: #ffffff;
}

.dark .column-picker-groupby-option.is-active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.2);
  color: #bfdbfe;
}

.dark .column-picker-action-button {
  background: #1f2937;
  border-color: #374151;
  color: #e5e7eb;
}

.dark .column-picker-action-button:hover {
  background: #374151;
}

html.column-picker-loading .paginated_collection {
  position: relative;
  min-height: 220px;
  display: block;
}

html.column-picker-loading .index_as_table,
html.column-picker-loading .index-as-table {
  position: relative;
  min-height: 220px;
  display: block;
}

html.column-picker-loading .paginated_collection::after,
html.column-picker-loading .index_as_table::after,
html.column-picker-loading .index-as-table::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 0.5rem;
  background-color: #f8fafc;
  background:
    linear-gradient(90deg, rgba(226, 232, 240, 0.6) 25%, rgba(241, 245, 249, 0.9) 37%, rgba(226, 232, 240, 0.6) 63%) 0 0 / 300% 100%,
    linear-gradient(#e2e8f0, #e2e8f0) 0 0 / 100% 1px,
    repeating-linear-gradient(#e2e8f0, #e2e8f0 1px, transparent 1px, transparent 36px) 0 40px / 100% calc(100% - 40px);
  opacity: 1;
  animation: column-picker-skeleton 1.2s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes column-picker-skeleton {
  0% {
    background-position: 0% 0, 0 0, 0 40px;
  }
  100% {
    background-position: 100% 0, 0 0, 0 40px;
  }
}

table.column-picker-loading th.default-hidden-column,
table.column-picker-loading td.default-hidden-column,
table.column-picker-loading thead th.col-net_amount,
table.column-picker-loading thead th.col-vat_rate,
table.column-picker-loading thead th.col-invoice_vat_amount,
table.column-picker-loading thead th.col-ccy,
table.column-picker-loading tbody td.col-net_amount,
table.column-picker-loading tbody td.col-vat_rate,
table.column-picker-loading tbody td.col-invoice_vat_amount,
table.column-picker-loading tbody td.col-ccy {
  display: none !important;
}

/* Single-line truncation with tooltip for index table cells */
table.index_table td {
  overflow: hidden; /* Ensures truncation works in table cells */
}

table.index_table td .truncate {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  min-width: 0; /* Allows flex items to shrink below their content size */
}

div[role="toolbar"].scopes {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

div[role="toolbar"].scopes .index-button-group.scope-dropdown-hidden {
  display: none !important;
}

div[role="toolbar"].scopes .aa-scope-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: 0.875rem;
}

div[role="toolbar"].scopes .aa-scope-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #374151;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

div[role="toolbar"].scopes .aa-scope-trigger:hover,
div[role="toolbar"].scopes .aa-scope-dropdown.is-open .aa-scope-trigger {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #111827;
}

div[role="toolbar"].scopes .aa-scope-trigger .scopes-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.375rem;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  color: #374151;
  font-size: 0.75rem;
}

div[role="toolbar"].scopes .aa-scope-caret {
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  display: inline-block;
  margin-left: 0.15rem;
  opacity: 0.75;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

div[role="toolbar"].scopes .aa-scope-dropdown.is-open .aa-scope-caret {
  transform: rotate(-135deg);
  opacity: 0.9;
}

div[role="toolbar"].scopes .aa-scope-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: 12rem;
  padding: 0.35rem;
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

div[role="toolbar"].scopes .aa-scope-dropdown.is-open .aa-scope-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

div[role="toolbar"].scopes .aa-scope-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0.5rem;
  color: #374151;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}

div[role="toolbar"].scopes .aa-scope-item:hover {
  background: #f3f4f6;
  color: #111827;
}

div[role="toolbar"].scopes .aa-scope-item.is-active {
  background: #2563eb;
  color: #ffffff;
}

div[role="toolbar"].scopes .aa-scope-item .scopes-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.375rem;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.3);
  color: inherit;
  font-size: 0.75rem;
}

div[role="toolbar"].scopes .aa-scope-item.is-active .scopes-count {
  background: rgba(255, 255, 255, 0.25);
}

div[role="toolbar"].scopes .aa-scope-group-label {
  padding: 0.35rem 0.65rem 0.2rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
}

div[role="toolbar"].scopes .aa-scope-divider {
  height: 1px;
  margin: 0.35rem 0.35rem;
  background: #e5e7eb;
  opacity: 0.7;
}

:where(.dark, .dark *) div[role="toolbar"].scopes .aa-scope-trigger {
  border-color: #374151;
  background: #111827;
  color: #e5e7eb;
}

:where(.dark, .dark *) div[role="toolbar"].scopes .aa-scope-trigger:hover,
:where(.dark, .dark *) div[role="toolbar"].scopes .aa-scope-dropdown.is-open .aa-scope-trigger {
  background: #1f2937;
  border-color: #4b5563;
  color: #ffffff;
}

:where(.dark, .dark *) div[role="toolbar"].scopes .aa-scope-trigger .scopes-count {
  background: rgba(148, 163, 184, 0.2);
  color: #e5e7eb;
}

:where(.dark, .dark *) div[role="toolbar"].scopes .aa-scope-menu {
  border-color: #374151;
  background: #111827;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.35);
}

:where(.dark, .dark *) div[role="toolbar"].scopes .aa-scope-group-label {
  color: #94a3b8;
}

:where(.dark, .dark *) div[role="toolbar"].scopes .aa-scope-divider {
  background: #374151;
}

:where(.dark, .dark *) div[role="toolbar"].scopes .aa-scope-item {
  color: #d1d5db;
}

:where(.dark, .dark *) div[role="toolbar"].scopes .aa-scope-item:hover {
  background: #1f2937;
  color: #f9fafb;
}

:where(.dark, .dark *) div[role="toolbar"].scopes .aa-scope-item.is-active {
  background: #3b82f6;
  color: #ffffff;
}

/* Audit Trail Collapsible Styles */
.audit-trail-content {
  display: none;
  padding-top: 0.5rem;
}

.audit-trail-content.expanded {
  display: block;
}

.audit-trail-toggle {
  transition: transform 0.2s ease;
}

.audit-trail-toggle.rotated {
  transform: rotate(180deg);
}

/* Description expand-on-hover styles */
.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-none {
  -webkit-line-clamp: unset;
}

/* Sticky expanded row */
tr.ajax-expand.expanded {
  position: relative;
  border: 2px solid #3b82f6 !important; /* blue-500 */
}

/* Blue border for regular expandable rows when expanded */
tr.expand.expanded {
  border: 2px solid #3b82f6 !important; /* blue-500 */
}

/* Dark mode support for expanded row borders */
.dark tr.ajax-expand.expanded,
:where(.dark, .dark *) tr.ajax-expand.expanded {
  border-color: #60a5fa !important; /* blue-400 for dark mode */
}

.dark tr.expand.expanded,
:where(.dark, .dark *) tr.expand.expanded {
  border-color: #60a5fa !important; /* blue-400 for dark mode */
}

tr.ajax-expand-details {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: rgb(249 250 251); /* bg-gray-50 */
}

/* Keep expanded row content within visible table width */
.index-as-table .data-table tbody tr.ajax-expand-details td[colspan] {
  white-space: normal;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.index-as-table .data-table tbody tr.ajax-expand-details td[colspan] > * {
  white-space: normal;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}

.index-as-table .data-table tbody tr.ajax-expand-details td.ajax-expand-cell,
.index-as-table .data-table tbody tr.no_highlight td.ajax-expand-cell {
  padding-left: 0;
  padding-right: 0;
}

.index-as-table .data-table tbody tr.ajax-expand-details .ajax-expand-details-content,
.index-as-table .data-table tbody tr.no_highlight .ajax-expand-details-content {
  position: sticky;
  left: 0;
  right: 0;
  width: min(100%, var(--ajax-expand-max-width, 100%));
  max-width: var(--ajax-expand-max-width, 100%);
  padding-left: 0.875rem;
  padding-right: 0.875rem;
  box-sizing: border-box;
  overflow-x: auto;
}

.index-as-table .data-table tbody tr.ajax-expand-details .ajax-expand-details-content table,
.index-as-table .data-table tbody tr.no_highlight .ajax-expand-details-content table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}

.index-as-table .data-table tbody tr.ajax-expand-details .ajax-expand-details-content :where(th, td),
.index-as-table .data-table tbody tr.no_highlight .ajax-expand-details-content :where(th, td) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.dark tr.ajax-expand-details {
  background-color: rgb(31 41 55); /* dark:bg-gray-800 */
}

/* Skeleton loader with shimmer effect */
.skeleton-loader {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  min-height: 1em;
  width: 100%;
}

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

/* Make the action column (last column) sticky on index pages */
.index-as-table .data-table thead tr th:last-child {
  position: sticky;
  right: 0;
  z-index: 10;
  background-color: rgb(249 250 251); /* bg-gray-50 to match header */
}

.index-as-table .data-table tbody tr td:last-child {
  position: sticky;
  right: 0;
  z-index: 10;
  background-color: rgb(255 255 255); /* white background for body cells */
}

/* Dark mode support for sticky action column */
.dark .index-as-table .data-table thead tr th:last-child,
:where(.dark, .dark *) .index-as-table .data-table thead tr th:last-child {
  background-color: rgba(3, 7, 18, 0.5); /* dark header background */
}

.dark .index-as-table .data-table tbody tr td:last-child,
:where(.dark, .dark *) .index-as-table .data-table tbody tr td:last-child {
  background-color: rgb(17 24 39); /* dark:bg-gray-900 to match row background */
}

/* Add shadow to indicate scrollable content */
.index-as-table .data-table thead tr th:last-child::before,
.index-as-table .data-table tbody tr td:last-child::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 0;
  bottom: 0;
  width: 8px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.1));
  pointer-events: none;
}

/* Remove shadow in dark mode and replace with dark variant */
.dark .index-as-table .data-table thead tr th:last-child::before,
:where(.dark, .dark *) .index-as-table .data-table thead tr th:last-child::before,
.dark .index-as-table .data-table tbody tr td:last-child::before,
:where(.dark, .dark *) .index-as-table .data-table tbody tr td:last-child::before {
  background: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.3));
}

/* Hide "(current view)" text by default, show on row hover */
.total-current-view-hint {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

tr:hover .total-current-view-hint {
  opacity: 1;
}

/* Keyboard navigation focus styling for index table rows */
.index-as-table tbody tr.keyboard-focused {
  outline: 2px solid #3b82f6 !important; /* blue-500 */
  outline-offset: -2px;
  background-color: #eff6ff !important; /* blue-50 */
  box-shadow: 0 0 0 1px #3b82f6 !important;
}

/* Make ActiveAdmin index rows feel clickable when row navigation is enabled */
.index-as-table tbody tr.row-clickable > td,
table.index_table tbody tr.row-clickable > td,
.paginated_collection table tbody tr.row-clickable > td,
table.data-table tbody tr.row-clickable > td {
  cursor: pointer;
}

/* Copy button for flagged cells on index pages */
td.copy-cell {
  position: relative;
  padding-right: 2.25rem;
}

/* Copy button for inline values on show pages */
.copy-cell-inline {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-right: 2.25rem;
}

td.copy-cell .copy-cell-button {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #6b7280;
  border-radius: 0.375rem;
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.copy-cell-inline .copy-cell-button {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #6b7280;
  border-radius: 0.375rem;
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

td.copy-cell:hover .copy-cell-button,
td.copy-cell .copy-cell-button:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.copy-cell-inline:hover .copy-cell-button,
.copy-cell-inline .copy-cell-button:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

td.copy-cell .copy-cell-button:hover {
  color: #111827;
  border-color: #d1d5db;
}

.copy-cell-inline .copy-cell-button:hover {
  color: #111827;
  border-color: #d1d5db;
}

td.copy-cell .copy-cell-button .material-symbols-outlined {
  font-size: 16px;
  line-height: 1;
}

.copy-cell-inline .copy-cell-button .material-symbols-outlined {
  font-size: 16px;
  line-height: 1;
}

td.copy-cell .copy-cell-button.copy-cell-button--copied {
  color: #059669;
  border-color: #34d399;
}

.copy-cell-inline .copy-cell-button.copy-cell-button--copied {
  color: #059669;
  border-color: #34d399;
}

.dark td.copy-cell .copy-cell-button,
:where(.dark, .dark *) td.copy-cell .copy-cell-button {
  background: #111827;
  border-color: #374151;
  color: #9ca3af;
}

.dark .copy-cell-inline .copy-cell-button,
:where(.dark, .dark *) .copy-cell-inline .copy-cell-button {
  background: #111827;
  border-color: #374151;
  color: #9ca3af;
}

.dark td.copy-cell .copy-cell-button:hover,
:where(.dark, .dark *) td.copy-cell .copy-cell-button:hover {
  color: #e5e7eb;
  border-color: #4b5563;
}

.dark .copy-cell-inline .copy-cell-button:hover,
:where(.dark, .dark *) .copy-cell-inline .copy-cell-button:hover {
  color: #e5e7eb;
  border-color: #4b5563;
}

.index-as-table tbody tr.row-clickable td.expand,
table.index_table tbody tr.row-clickable td.expand,
.paginated_collection table tbody tr.row-clickable td.expand,
.data-table tbody tr.row-clickable td.expand,
.index-as-table tbody tr.row-clickable td.col-actions,
table.index_table tbody tr.row-clickable td.col-actions,
.paginated_collection table tbody tr.row-clickable td.col-actions,
.data-table tbody tr.row-clickable td.col-actions,
.index-as-table tbody tr.row-clickable td.actions,
table.index_table tbody tr.row-clickable td.actions,
.paginated_collection table tbody tr.row-clickable td.actions,
.data-table tbody tr.row-clickable td.actions,
.index-as-table tbody tr.row-clickable .data-table-resource-actions,
table.index_table tbody tr.row-clickable .data-table-resource-actions,
.paginated_collection table tbody tr.row-clickable .data-table-resource-actions,
.data-table tbody tr.row-clickable .data-table-resource-actions {
  cursor: default;
}

/* Expanded detail rows should not show a pointer cursor */
.index-as-table tbody tr.ajax-expand-details td,
.index-as-table tbody tr.no_highlight td,
table.index_table tbody tr.ajax-expand-details td,
table.index_table tbody tr.no_highlight td,
.paginated_collection table tbody tr.ajax-expand-details td,
.paginated_collection table tbody tr.no_highlight td,
table.data-table tbody tr.ajax-expand-details td,
table.data-table tbody tr.no_highlight td {
  cursor: default;
}

.dark .index-as-table tbody tr.keyboard-focused,
:where(.dark, .dark *) .index-as-table tbody tr.keyboard-focused {
  outline-color: #60a5fa !important; /* blue-400 for dark mode */
  background-color: #1e3a8a !important; /* blue-900 for dark mode */
  box-shadow: 0 0 0 1px #60a5fa !important;
}

/* Ensure focused row is visible above other rows */
.index-as-table tbody tr.keyboard-focused {
  position: relative;
  z-index: 5;
}

/* Row highlighting on back navigation */
.index-as-table tbody tr.highlighted-row {
  outline: 2px solid #3b82f6 !important; /* blue-500 */
  outline-offset: -2px;
  transition: outline 0.2s ease-in;
  position: relative;
  z-index: 10;
}

.dark .index-as-table tbody tr.highlighted-row,
:where(.dark, .dark *) .index-as-table tbody tr.highlighted-row {
  outline-color: #60a5fa !important; /* blue-400 for dark mode */
}

/* Keep date pickers above filter dropdown overlays */
.ui-datepicker,
.ui-datepicker.ui-widget,
.ui-datepicker.ui-widget-content,
.flatpickr-calendar {
  z-index: 10050 !important;
}

/* =========================================================
   ENTERPRISE FINANCIAL UX PATTERNS
   ========================================================= */

/* 1. Sticky table headers (enterprise financial pattern)
   Column headers stay visible when scrolling long financial lists
   so users always know which column they are reading. */
.index-as-table .data-table thead tr th,
table.index_table thead tr th {
  position: sticky;
  top: 0;
  z-index: 15; /* above sticky action column (z-index:10) */
  background-color: rgb(249 250 251); /* bg-gray-50 */
}

.dark .index-as-table .data-table thead tr th,
:where(.dark, .dark *) .index-as-table .data-table thead tr th,
.dark table.index_table thead tr th,
:where(.dark, .dark *) table.index_table thead tr th {
  background-color: rgb(17 24 39); /* dark:bg-gray-900 */
}

/* Bottom border shadow on sticky header to signal scroll position */
.index-as-table .data-table thead tr th {
  box-shadow: 0 1px 0 rgb(229 231 235); /* border-gray-200 equivalent */
}

.dark .index-as-table .data-table thead tr th,
:where(.dark, .dark *) .index-as-table .data-table thead tr th {
  box-shadow: 0 1px 0 rgb(55 65 81); /* dark:border-gray-700 */
}

/* Corner cell: sticky header + sticky action column must both be visible */
.index-as-table .data-table thead tr th:last-child {
  z-index: 20; /* above regular sticky headers */
}

/* Product UI sticky headers need to sit below the sticky top search bar. */
.product-ui-sticky-header-table {
  border-collapse: collapse;
}

.product-ui-sticky-header-shell {
  position: sticky;
  top: var(--product-ui-sticky-header-top, 0px);
  z-index: 30;
  height: 0;
  overflow: visible;
  pointer-events: none;
}

.product-ui-sticky-header-shell > * {
  pointer-events: auto;
}

.product-ui-sticky-header-clone-table {
  border-collapse: collapse;
  visibility: hidden;
}

.product-ui-sticky-header-shell.is-visible .product-ui-sticky-header-clone-table {
  visibility: visible;
}

.product-ui-sticky-header-clone-table thead tr th {
  background-color: rgb(249 250 251);
  box-shadow: 0 1px 0 rgb(229 231 235);
}

.dark .product-ui-sticky-header-clone-table thead tr th,
:where(.dark, .dark *) .product-ui-sticky-header-clone-table thead tr th {
  background-color: rgba(31, 41, 55, 0.98);
  box-shadow: 0 1px 0 rgb(55 65 81);
}

.product-ui-sticky-header-shell.is-visible + [data-sticky-table-header-target="scroller"] .product-ui-sticky-header-table thead {
  visibility: hidden;
}

body[data-product-action="index"] [data-controller~="sticky-table-header"] table th,
body[data-product-action="index"] [data-controller~="sticky-table-header"] table td.tabular-nums,
body[data-product-action="index"] [data-controller~="sticky-table-header"] table td .tabular-nums,
body[data-product-action="index"] [data-controller~="sticky-table-header"] table td.whitespace-nowrap,
body[data-product-action="index"] [data-controller~="sticky-table-header"] table td .whitespace-nowrap {
  white-space: nowrap;
}

/* 2. Negative number highlighting (enterprise financial / accounting pattern)
   Negative values display in red — a universal accounting convention.
   Use the .negative class on any element containing a negative amount. */
.negative,
td.negative,
span.negative {
  color: #dc2626 !important; /* red-600 */
}

.dark .negative,
:where(.dark, .dark *) .negative,
:where(.dark, .dark *) td.negative,
:where(.dark, .dark *) span.negative {
  color: #f87171 !important; /* red-400 for dark mode */
}

/* 3. Keyboard shortcuts help overlay (enterprise financial pattern)
   Press ? to see a panel listing all keyboard shortcuts — common in
   Bloomberg Terminal, Jira, GitHub, and other professional tools. */
.kbd-help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10100;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
}

.kbd-help-overlay.is-open {
  display: flex;
}

.kbd-help-panel {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  padding: 1.5rem;
}

.dark .kbd-help-panel,
:where(.dark, .dark *) .kbd-help-panel {
  background: #1f2937; /* gray-800 */
  color: #f9fafb; /* gray-50 */
}

.kbd-help-panel h2 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kbd-help-panel .kbd-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin: 1rem 0 0.375rem;
}

.dark .kbd-help-panel .kbd-section-title,
:where(.dark, .dark *) .kbd-help-panel .kbd-section-title {
  color: #9ca3af;
}

.kbd-help-panel .kbd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3125rem 0;
  border-bottom: 1px solid rgb(243 244 246);
  font-size: 0.875rem;
}

.dark .kbd-help-panel .kbd-row,
:where(.dark, .dark *) .kbd-help-panel .kbd-row {
  border-bottom-color: rgb(55 65 81);
}

.kbd-help-panel .kbd-row:last-child {
  border-bottom: none;
}

.kbd-help-panel kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-bottom-width: 2px;
  border-radius: 0.3rem;
  color: #111827;
  white-space: nowrap;
}

.dark .kbd-help-panel kbd,
:where(.dark, .dark *) .kbd-help-panel kbd {
  background: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

.kbd-help-close-btn {
  float: right;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: #6b7280;
  padding: 0;
  margin-left: auto;
}

.kbd-help-close-btn:hover {
  color: #111827;
}

.dark .kbd-help-close-btn:hover,
:where(.dark, .dark *) .kbd-help-close-btn:hover {
  color: #f9fafb;
}
