/*
 * app-ui.css — shared UI layer on top of the Vuexy theme
 * -----------------------------------------------------------------------------
 * Loaded on every page after the theme and vendor CSS (layouts/sections/styles.blade.php).
 * Only refines the look; it does not change layout structure. Light and dark styles
 * follow the theme customizer (html.light-style / html.dark-style).
 */

/* ===== Tokens ===== */
:root {
  /* Brand colour. The "Brand colour override" section at the end of this file applies it to
     the theme (buttons, links, menu, forms, …) in place of Vuexy's purple #7367f0.
     Contrast (WCAG): white on #231f60 14.6:1, #231f60 on white 14.6:1. */
  --app-brand: #231f60; /* solid fills: buttons, active menu item, pagination, checked inputs */
  --app-brand-rgb: 35, 31, 96;
  --app-brand-hover: #2e297f; /* lighter on hover: a darker navy would look unchanged */
  --app-brand-active: #1d1a51; /* pressed / selected */
  --app-brand-solid-border: var(--app-brand); /* edge of solid fills (light tint in dark mode) */

  /* Brand as text, links, outlines and focus rings on the page background */
  --app-brand-fg: #231f60;
  --app-brand-fg-rgb: 35, 31, 96;
  --app-brand-fg-hover: #2e297f;
  --app-brand-fg-strong: #231f60; /* text on brand-tinted backgrounds */
  --app-brand-tint-rgb: 35, 31, 96; /* source of the tinted backgrounds below */

  --app-radius: 0.625rem;
  --app-radius-sm: 0.5rem;
  --app-shadow-sm: 0 1px 2px rgba(47, 43, 61, 0.06), 0 1px 3px rgba(47, 43, 61, 0.08);
  --app-shadow: 0 2px 6px rgba(47, 43, 61, 0.06), 0 6px 18px rgba(47, 43, 61, 0.06);
  --app-focus-ring: 0 0 0 0.2rem rgba(var(--app-brand-fg-rgb), 0.35);

  /* Text that passes WCAG AA (4.5:1) on the page background */
  --app-text-muted: #716e7d;
  --app-surface: #fff; /* cards and raised controls */
  --app-surface-subtle: #f6f5f9;
  --app-border-subtle: #ebe9f1;
}

html.dark-style {
  /* Solid fills stay navy with white text. #231f60 is only 1.18:1 against the dark card,
     so solid fills get a light-tint edge (4.65:1) to stay visible. */
  --app-brand-solid-border: #9b97dd;

  /* Lighter tint of the same hue (244°) for links, outlines and focus rings:
     #9b97dd = 4.65:1 on cards (#2f3349), 5.38:1 on the page (#25293c). */
  --app-brand-fg: #9b97dd;
  --app-brand-fg-rgb: 155, 151, 221;
  --app-brand-fg-hover: #b1aee5; /* 5.95:1 on cards */
  --app-brand-fg-strong: #c0bdea; /* ≥ 4.66:1 on the 8–25% tinted backgrounds */
  --app-brand-tint-rgb: 155, 151, 221;

  --app-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --app-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 6px 18px rgba(0, 0, 0, 0.2);
  --app-focus-ring: 0 0 0 0.2rem rgba(var(--app-brand-fg-rgb), 0.5);
  --app-text-muted: #949cc9;
  --app-surface: #2f3349;
  --app-surface-subtle: #2a2e42;
  --app-border-subtle: #3b405a;
}

/* ===== Typography & contrast ===== */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.text-muted,
.form-text,
.dataTables_info {
  color: var(--app-text-muted) !important;
}

.form-control::placeholder,
.form-select::placeholder {
  color: var(--app-text-muted);
  opacity: 0.85;
}

.form-label {
  font-weight: 500;
}

/* Mark required fields (label directly followed by a required control) */
.form-label:has(+ .form-control[required]):not(:has(.app-required))::after,
.form-label:has(+ .form-select[required]):not(:has(.app-required))::after,
.form-label:has(+ select[required]):not(:has(.app-required))::after {
  content: ' *';
  color: #c9302c;
}

/* Small solid badges: darker fills so white text stays readable (AA) */
.badge.bg-success {
  background-color: #1b854a !important;
}
.badge.bg-warning {
  background-color: #b85a00 !important;
}
.badge.bg-info {
  background-color: #007f8f !important;
}
.badge.bg-danger {
  background-color: #c9302c !important;
}
.badge.bg-secondary {
  background-color: #72757b !important;
}

/* ===== Focus states (keyboard users) ===== */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
[role='button']:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible,
.menu-link:focus-visible,
.page-link:focus-visible,
.nav-link:focus-visible,
.dropdown-item:focus-visible {
  outline: 2px solid var(--app-brand-fg) !important;
  outline-offset: 2px;
  box-shadow: none;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.select2-container--focus .select2-selection,
.select2-container--open .select2-selection {
  box-shadow: var(--app-focus-ring) !important;
}

/* ===== Cards ===== */
.card {
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
}

.card > .card-header:first-child {
  border-top-left-radius: var(--app-radius);
  border-top-right-radius: var(--app-radius);
}

.card-header .card-title,
h5.card-header {
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ===== Buttons ===== */
.btn {
  border-radius: var(--app-radius-sm);
  font-weight: 500;
}

.btn-icon {
  border-radius: var(--app-radius-sm);
}

/* Icon-only action buttons rendered in table rows */
.table .btn-icon {
  color: var(--app-text-muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.table .btn-icon:hover {
  background-color: rgba(var(--app-brand-fg-rgb), 0.1);
  color: var(--app-brand-fg);
}

.table .btn-icon.delete-record:hover {
  background-color: rgba(234, 84, 85, 0.12);
  color: #c9302c;
}

/* "Saving…" state set by app-ui.js on form submit */
.btn.app-btn-loading {
  pointer-events: none;
  opacity: 0.85;
}

.btn.app-btn-loading .spinner-border {
  width: 1rem;
  height: 1rem;
  border-width: 0.15em;
  vertical-align: -0.15em;
}

/* Button that started an AJAX request (app-ui.js section 15): its content stays, a spinner is added */
.app-btn-busy {
  pointer-events: none;
  opacity: 0.8;
  cursor: progress;
}

.app-btn-busy::before {
  content: '';
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  margin-right: 0.4rem;
  border: 0.15em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.12em;
  animation: app-busy-spin 0.7s linear infinite;
}

/* Icon-only buttons: the spinner replaces the icon instead of widening the button */
.btn-icon.app-btn-busy {
  position: relative;
}

.btn-icon.app-btn-busy > * {
  visibility: hidden;
}

.btn-icon.app-btn-busy::before {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -0.45rem 0 0 -0.45rem;
}

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

@media (prefers-reduced-motion: reduce) {
  .app-btn-busy::before {
    animation-duration: 2s;
  }
}

/* ===== Tables & DataTables ===== */
.table > thead th {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table > :not(caption) > * > * {
  vertical-align: middle;
}

.table-hover > tbody > tr:hover > *,
.dataTable > tbody > tr:hover > * {
  background-color: rgba(var(--app-brand-fg-rgb), 0.04);
}

.card-datatable .dataTables_filter input,
.dataTables_wrapper .dataTables_filter input {
  min-width: 14rem;
}

/* Loading indicator (DataTables "processing") */
.dataTables_wrapper {
  position: relative;
}

.dataTables_wrapper .dataTables_processing {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: auto;
  min-width: 11rem;
  margin: 0 !important;
  padding: 0.75rem 1.25rem !important;
  border: 0;
  border-radius: 999px;
  background: var(--bs-body-bg, #fff);
  box-shadow: var(--app-shadow);
  color: inherit;
  text-align: center;
}

.dataTables_wrapper .dataTables_processing > div:last-child {
  display: none; /* hide DataTables' default dots; we show a spinner */
}

/* Empty state rows */
td.dataTables_empty {
  padding: 2.5rem 1rem !important;
  text-align: center;
}

.app-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  color: var(--app-text-muted);
}

.app-empty-state .ti {
  font-size: 2.25rem;
  opacity: 0.6;
}

.app-empty-state strong {
  color: var(--bs-heading-color, inherit);
  font-weight: 600;
}

/* Generic empty state block (usable in any page: <div class="app-empty-state">…</div>) */
.app-empty-state.app-empty-block {
  padding: 2.5rem 1rem;
  text-align: center;
}

/* ===== Alerts (flash messages & validation summary) ===== */
.app-alert {
  gap: 0.75rem;
  border-radius: var(--app-radius);
  border-left-width: 4px;
  padding-top: 0.875rem;
  padding-bottom: 0.875rem;
  margin-bottom: 1.5rem;
}

.app-alert .alert-heading {
  color: inherit;
  font-weight: 600;
}

.app-alert-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

html.dark-style .app-alert-icon {
  background: rgba(0, 0, 0, 0.15);
}

.app-alert-icon .ti {
  font-size: 1.25rem;
}

.app-alert .btn-close {
  position: static;
  padding: 0.5rem;
  margin: -0.25rem -0.25rem 0 auto;
}

/* Highlight on fields named in the validation summary (set by app-ui.js) */
.app-field-error {
  border-color: #c9302c !important;
}

/* ===== Navbar ===== */
.app-kbd {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--app-border-subtle);
  border-radius: 0.3rem;
  background: var(--app-surface-subtle);
  color: var(--app-text-muted);
  font-size: 0.7rem;
  font-family: inherit;
  box-shadow: none;
}

.app-help-link {
  border-radius: var(--app-radius-sm);
}

.navbar-search-suggestion .suggestion small {
  font-size: 0.75rem;
}

/* ===== Sidebar menu ===== */
.layout-menu .app-brand .app-brand-img {
  display: block;
  max-width: 100%;
  max-height: 48px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.layout-menu .app-brand .app-brand-link {
  min-width: 0;
  flex: 1 1 auto;
}

/* Company without a logo (or a missing file): initials + name */
.layout-menu .app-brand .app-brand-wordmark {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  max-height: none;
  color: var(--bs-heading-color, inherit);
}

.layout-menu .app-brand .app-brand-img[hidden] {
  display: none;
}

.app-brand-wordmark-mark {
  flex: 0 0 auto;
  width: 2.375rem;
  height: 2.375rem;
  border-radius: var(--app-radius-sm);
  background: var(--app-brand);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 2.375rem;
  text-align: center;
  box-shadow: var(--app-shadow-sm);
}

html.dark-style .app-brand-wordmark-mark {
  box-shadow: inset 0 0 0 1px var(--app-brand-solid-border);
}

.app-brand-wordmark-name {
  min-width: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Search: stays at the top, because the menu scrolls to the current page when it loads */
.app-menu-search {
  list-style: none;
  padding: 0.5rem 1rem 0.75rem;
  position: sticky;
  top: 0;
  z-index: 3;
  flex-shrink: 0;
  background-color: var(--app-surface);
}

.app-menu-searching > #pinnedHeader,
.app-menu-searching > #pinnedContainer,
.app-menu-searching > #recentHeader,
.app-menu-searching > #recentContainer {
  display: none !important;
}

.app-menu-search .input-group-text,
.app-menu-search .form-control {
  background-color: var(--app-surface-subtle);
}

.app-menu-search .form-control::-webkit-search-cancel-button {
  cursor: pointer;
}

.app-menu-empty {
  list-style: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 1rem 1.25rem;
  text-align: center;
  color: var(--app-text-muted);
  font-size: 0.8125rem;
}

.app-menu-empty .ti {
  font-size: 1.5rem;
  opacity: 0.7;
}

.app-menu-empty.d-none {
  display: none !important;
}

/* Section headers: one subtle accent per area to help orientation */
.layout-menu .app-menu-section {
  --app-section-accent: var(--app-brand-fg);
  margin-top: 0.5rem;
  padding: 0.5rem 1.25rem 0.375rem !important;
  border-left: 3px solid var(--app-section-accent);
}

.layout-menu .app-menu-section .menu-header-text {
  color: var(--app-section-accent) !important;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.app-menu-section--home {
  --app-section-accent: #5a6c8f !important;
}
.app-menu-section--commercial {
  --app-section-accent: #3e7a52 !important;
}
.app-menu-section--operations {
  --app-section-accent: #3f6a80 !important;
}
.app-menu-section--finance {
  --app-section-accent: #7a6a2e !important;
}
.app-menu-section--reporting {
  --app-section-accent: #6e4a85 !important;
}
.app-menu-section--documents {
  --app-section-accent: #855a42 !important;
}
.app-menu-section--tools {
  --app-section-accent: #3d7373 !important;
}
.app-menu-section--administration {
  --app-section-accent: #7e4a74 !important;
}

html.dark-style .app-menu-section--home {
  --app-section-accent: #9fb0d4 !important;
}
html.dark-style .app-menu-section--commercial {
  --app-section-accent: #8fd1a4 !important;
}
html.dark-style .app-menu-section--operations {
  --app-section-accent: #8cc3dc !important;
}
html.dark-style .app-menu-section--finance {
  --app-section-accent: #d7c37d !important;
}
html.dark-style .app-menu-section--reporting {
  --app-section-accent: #c6a1df !important;
}
html.dark-style .app-menu-section--documents {
  --app-section-accent: #e0ad8f !important;
}
html.dark-style .app-menu-section--tools {
  --app-section-accent: #8fd0d0 !important;
}
html.dark-style .app-menu-section--administration {
  --app-section-accent: #dba2d0 !important;
}

#pinnedHeader,
#recentHeader {
  margin-top: 0.5rem;
  padding: 0.5rem 1.25rem 0.375rem !important;
}

#pinnedHeader .menu-header-text,
#recentHeader .menu-header-text {
  color: var(--app-text-muted) !important;
}

/* Pin buttons (moved from verticalMenu.blade.php) */
.pin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  margin-left: auto !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0.375rem;
  background: none !important;
  color: var(--app-text-muted) !important;
  font-size: 1rem !important;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.menu-item:hover > .menu-link > .pin-btn,
.menu-link:focus-within > .pin-btn,
.pin-btn:focus-visible,
.pin-btn.pinned {
  opacity: 1 !important;
}

/* Touch screens have no hover: keep pins reachable */
@media (hover: none) {
  .pin-btn {
    opacity: 0.6;
  }
}

.pin-btn:hover {
  background: rgba(var(--app-brand-fg-rgb), 0.1) !important;
  color: var(--app-brand-fg) !important;
}

.pin-btn.pinned {
  color: var(--app-brand-fg) !important;
}

.pin-btn.pinned:hover {
  background: rgba(234, 84, 85, 0.1) !important;
  color: #c9302c !important;
}

#pinnedContainer .pin-btn,
#recentContainer .pin-btn {
  display: none !important;
}

/* Pinned / Recent entries sit inside a container, so the theme's ".menu-inner > .menu-item" spacing
   missed them (their icons were further left than the rest of the menu): same spacing here. */
.menu-vertical #pinnedContainer > .menu-item,
.menu-vertical #recentContainer > .menu-item {
  width: 16.25rem;
  margin: 0.125rem 0;
}

.menu-vertical #pinnedContainer > .menu-item > .menu-link,
.menu-vertical #recentContainer > .menu-item > .menu-link {
  margin: 0 0.875rem;
  border-radius: 0.375rem;
}

/* ----- Collapsed sidebar (desktop, menu closed and not hovered) -----
   The theme styles only direct children of .menu-inner, so the Pinned / Recent entries (inside
   #pinnedContainer / #recentContainer) kept their text; the pins and the search box had no
   collapsed style; and the logo had no small version. Hovering the menu still expands it. */
.app-brand-mark {
  display: none; /* shown by the theme (.app-brand-img-collapsed) only while collapsed */
  width: 2.375rem;
  height: 2.375rem;
  border-radius: var(--app-radius-sm);
  background: var(--app-brand);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 2.375rem;
  text-align: center;
  box-shadow: var(--app-shadow-sm);
}

@media (min-width: 1200px) {
  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) .layout-menu .app-brand {
    justify-content: center;
    margin-inline: 0;
    padding-inline: 0;
  }

  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) .layout-menu .app-brand-link {
    flex: 0 0 auto;
  }

  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) .layout-menu .app-brand .layout-menu-toggle {
    display: none !important;
  }

  /* Pinned / Recent entries: icon only, like the other items */
  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) #pinnedContainer > .menu-item,
  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) #recentContainer > .menu-item {
    width: 5.25rem;
  }

  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) #pinnedContainer > .menu-item > .menu-link > div,
  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) #recentContainer > .menu-item > .menu-link > div {
    overflow: hidden;
    white-space: nowrap;
    opacity: 0;
  }

  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) #pinnedContainer > .menu-item > .menu-link .menu-icon,
  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) #recentContainer > .menu-item > .menu-link .menu-icon {
    margin-right: 0;
    text-align: center;
  }

  /* Pin buttons only make sense with the labels visible */
  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) .layout-menu .pin-btn {
    display: none !important;
  }

  /* Search: just the icon, centred like a menu icon (hover the menu to type) */
  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) .app-menu-search {
    display: flex;
    justify-content: center;
    width: 5.25rem;
    padding-inline: 0;
  }

  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) .app-menu-search .input-group {
    width: auto;
  }

  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) .app-menu-search .form-control {
    display: none;
  }

  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) .app-menu-search .input-group-text {
    justify-content: center;
    width: 2.375rem;
    height: 2.375rem;
    padding: 0;
    border-radius: var(--app-radius-sm) !important;
    border-right-width: 1px !important;
  }

  /* Section dividers keep their area colour; the left accent bar would sit off to the side */
  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) .layout-menu .app-menu-section {
    border-left: 0;
  }

  .layout-menu-collapsed:not(.layout-menu-hover):not(.layout-menu-offcanvas):not(.layout-menu-fixed-offcanvas) .layout-menu .app-menu-section::before {
    color: var(--app-section-accent) !important;
  }
}

/* Small confirmation after pin/unpin */
.app-menu-toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1100;
  max-width: min(22rem, calc(100vw - 2.5rem));
  padding: 0.625rem 1rem;
  border-radius: var(--app-radius-sm);
  background: #2f2b3d;
  color: #fff;
  font-size: 0.8125rem;
  box-shadow: var(--app-shadow);
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.app-menu-toast.show {
  opacity: 1;
  transform: none;
}

/* ===== Toasts (toastr) ===== */
#toast-container > div {
  border-radius: var(--app-radius-sm) !important;
  box-shadow: var(--app-shadow) !important;
  opacity: 1 !important;
}

/* ===== Small screens ===== */
@media (max-width: 767.98px) {
  .container-p-y:not([class^='pt-']):not([class*=' pt-']) {
    padding-top: 1rem !important;
  }

  .container-p-y:not([class^='pb-']):not([class*=' pb-']) {
    padding-bottom: 1rem !important;
  }

  .card-header,
  .card-body {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* DataTables toolbar: stack search + buttons, full width */
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_filter label,
  .dataTables_wrapper .dataTables_filter input {
    width: 100%;
    min-width: 0;
    margin-left: 0 !important;
  }

  .dataTables_wrapper .dt-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0 0 !important;
  }

  .dataTables_wrapper .dt-buttons .btn {
    margin: 0 !important;
  }

  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    text-align: center !important;
  }

  .dataTables_wrapper .dataTables_paginate .pagination {
    justify-content: center !important;
    flex-wrap: wrap;
  }

  .modal-dialog {
    margin: 0.75rem;
  }
}

@media (max-width: 575.98px) {
  /* Comfortable tap targets */
  .btn:not(.btn-xs):not(.btn-sm),
  .form-control:not(.form-control-sm),
  .form-select:not(.form-select-sm) {
    min-height: 2.75rem;
  }

  .table .btn-icon {
    width: 2.25rem;
    height: 2.25rem;
  }

  .app-alert {
    margin-bottom: 1rem;
  }
}

/* ===== Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =============================================================================
 * Brand colour override (#231f60)
 * -----------------------------------------------------------------------------
 * Replaces Vuexy's purple (#7367f0) wherever the theme hard-codes it. Selectors mirror
 * theme-default(-dark).css, core(-dark).css and the plugin CSS so they win by load order
 * (this file loads after them); "!important" is used only where the theme uses it.
 * Light mode: navy everywhere. Dark mode: solid fills stay navy with white text plus a
 * light-tint edge; text, links, outlines and focus rings use the light tint (see tokens).
 * Not covered: colours set from JavaScript (ApexCharts via assets/js/config.js).
 * ========================================================================== */

/* ----- Bootstrap variables ----- */
:root {
  --bs-primary: #231f60;
  --bs-primary-rgb: 35, 31, 96;
  --bs-purple: #231f60;
  --bs-link-color: var(--app-brand-fg);
  --bs-link-hover-color: var(--app-brand-fg-hover);
}

.dropdown-menu,
.dropdown-menu-dark {
  --bs-dropdown-link-hover-color: var(--app-brand-fg-strong);
  --bs-dropdown-link-hover-bg: rgba(var(--app-brand-tint-rgb), 0.08);
  --bs-dropdown-link-active-bg: var(--app-brand);
}

.nav-tabs {
  --bs-nav-tabs-link-active-color: var(--app-brand-fg);
}

.nav-pills {
  --bs-nav-pills-link-active-bg: var(--app-brand);
}

.pagination {
  --bs-pagination-active-bg: var(--app-brand);
  --bs-pagination-active-border-color: var(--app-brand-solid-border);
}

.progress {
  --bs-progress-bar-bg: var(--app-brand);
}

.list-group {
  --bs-list-group-action-hover-color: var(--app-brand-fg-strong);
  --bs-list-group-action-hover-bg: rgba(var(--app-brand-tint-rgb), 0.08);
  --bs-list-group-action-active-color: var(--app-brand-fg-strong);
  --bs-list-group-action-active-bg: rgba(var(--app-brand-tint-rgb), 0.08);
  --bs-list-group-active-bg: var(--app-brand);
  --bs-list-group-active-border-color: var(--app-brand-solid-border);
}

.table {
  --bs-table-active-bg: rgba(var(--app-brand-tint-rgb), 0.08);
}

.accordion {
  --bs-accordion-btn-focus-border-color: var(--app-brand-fg);
}

/* ----- Links & text ----- */
a {
  color: var(--bs-link-color);
}

.text-primary,
.link-primary {
  color: var(--app-brand-fg) !important;
}

.link-primary:hover,
.link-primary:focus,
.text-body[href]:hover {
  color: var(--app-brand-fg-hover) !important;
}

.breadcrumb-item,
.breadcrumb-item a,
.breadcrumb-item.active a:hover,
.breadcrumb-item.active a:focus,
.toast-message a {
  color: var(--app-brand-fg);
}

.border-primary,
html:not([dir='rtl']) .border-primary,
html[dir='rtl'] .border-primary {
  border-color: var(--app-brand-fg) !important;
}

/* ----- Backgrounds & badges ----- */
.bg-primary,
.text-bg-primary {
  background-color: var(--app-brand) !important;
  color: #fff;
}

.badge.bg-primary {
  color: #fff;
}

html.dark-style .badge.bg-primary {
  box-shadow: inset 0 0 0 1px var(--app-brand-solid-border);
}

.bg-label-primary,
.bg-label-hover-primary {
  background-color: rgba(var(--app-brand-tint-rgb), 0.15) !important;
  color: var(--app-brand-fg-strong) !important;
}

.bg-label-hover-primary:hover {
  background-color: var(--app-brand) !important;
  color: #fff !important;
}

.alert-primary,
.list-group-item-primary {
  background-color: rgba(var(--app-brand-tint-rgb), 0.15);
  border-color: transparent;
  color: var(--app-brand-fg-strong) !important;
}

.alert-primary .alert-link {
  color: var(--app-brand-fg-strong);
}

a.list-group-item-primary,
button.list-group-item-primary,
a.list-group-item-primary:hover,
a.list-group-item-primary:focus,
button.list-group-item-primary:hover,
button.list-group-item-primary:focus {
  background-color: rgba(var(--app-brand-tint-rgb), 0.15);
  color: var(--app-brand-fg-strong);
}

a.list-group-item-primary.active,
button.list-group-item-primary.active {
  border-color: var(--app-brand-solid-border);
  background-color: var(--app-brand);
  color: #fff;
}

.bg-primary.bg-glow {
  box-shadow: 0 2px 3px 0 rgba(var(--app-brand-rgb), 0.3);
}

.table-primary {
  --bs-table-bg: rgba(var(--app-brand-tint-rgb), 0.08);
  --bs-table-striped-bg: rgba(var(--app-brand-tint-rgb), 0.15);
}

.nav-tabs.widget-nav-tabs .nav-link.active .badge {
  background-color: rgba(var(--app-brand-tint-rgb), 0.15) !important;
  color: var(--app-brand-fg-strong) !important;
}

/* ----- Buttons: primary ----- */
.btn-primary {
  color: #fff;
  background-color: var(--app-brand);
  border-color: var(--app-brand-solid-border);
}

.btn-primary:hover {
  color: #fff !important;
  background-color: var(--app-brand-hover) !important;
  border-color: var(--app-brand-solid-border) !important;
}

.btn-check:focus + .btn-primary,
.btn-primary:focus,
.btn-primary.focus {
  color: #fff;
  background-color: var(--app-brand-hover);
  border-color: var(--app-brand-solid-border);
}

.btn-check:checked + .btn-primary,
.btn-check:active + .btn-primary,
.btn-primary:active,
.btn-primary.active,
.btn-primary.show.dropdown-toggle,
.show > .btn-primary.dropdown-toggle {
  color: #fff !important;
  background-color: var(--app-brand-active) !important;
  border-color: var(--app-brand-solid-border) !important;
}

.btn-primary.disabled,
.btn-primary:disabled {
  color: #fff !important;
  background-color: var(--app-brand) !important;
  border-color: var(--app-brand-solid-border) !important;
}

.btn-group .btn-primary,
.input-group .btn-primary {
  border-right: 1px solid var(--app-brand-active);
  border-left: 1px solid var(--app-brand-active);
}

.btn-group-vertical .btn-primary {
  border-top-color: var(--app-brand-active);
  border-bottom-color: var(--app-brand-active);
}

html.dark-style .btn-group .btn-primary,
html.dark-style .input-group .btn-primary,
html.dark-style .btn-group-vertical .btn-primary {
  border-color: var(--app-brand-solid-border);
}

/* ----- Buttons: outline primary ----- */
.btn-outline-primary {
  color: var(--app-brand-fg);
  border-color: var(--app-brand-fg);
}

.btn-outline-primary:hover {
  color: var(--app-brand-fg-strong) !important;
  background-color: rgba(var(--app-brand-tint-rgb), 0.08) !important;
  border-color: var(--app-brand-fg) !important;
}

.btn-check:focus + .btn-outline-primary,
.btn-outline-primary:focus {
  color: var(--app-brand-fg-strong);
  background-color: rgba(var(--app-brand-tint-rgb), 0.08);
  border-color: var(--app-brand-fg);
}

.btn-check:checked + .btn-outline-primary,
.btn-check:active + .btn-outline-primary,
.btn-outline-primary:active,
.btn-outline-primary.active,
.btn-outline-primary.dropdown-toggle.show {
  color: var(--app-brand-fg-strong) !important;
  background-color: rgba(var(--app-brand-tint-rgb), 0.15) !important;
  border-color: var(--app-brand-fg) !important;
}

.btn-outline-primary.disabled,
.btn-outline-primary:disabled {
  color: var(--app-brand-fg) !important;
}

.btn-outline-primary .badge,
.btn-outline-primary:hover .badge,
.btn-outline-primary:focus:hover .badge,
.btn-outline-primary:active .badge,
.btn-outline-primary.active .badge,
.show > .btn-outline-primary.dropdown-toggle .badge {
  background: var(--app-brand);
  border-color: var(--app-brand-solid-border);
  color: #fff;
}

/* ----- Buttons: label (tinted) primary ----- */
.btn-label-primary {
  color: var(--app-brand-fg-strong);
  background: rgba(var(--app-brand-tint-rgb), 0.15);
}

.btn-label-primary:hover,
.btn-label-primary:focus,
.btn-label-primary.focus {
  color: var(--app-brand-fg-strong) !important;
  background: rgba(var(--app-brand-tint-rgb), 0.25) !important;
}

.btn-label-primary:active,
.btn-label-primary.active,
.btn-label-primary.show.dropdown-toggle,
.show > .btn-label-primary.dropdown-toggle {
  color: var(--app-brand-fg-strong) !important;
  background-color: rgba(var(--app-brand-tint-rgb), 0.25) !important;
}

.btn-label-primary.disabled,
.btn-label-primary:disabled {
  color: var(--app-brand-fg-strong) !important;
  background: rgba(var(--app-brand-tint-rgb), 0.15) !important;
}

.btn-group .btn-label-primary,
.input-group .btn-label-primary {
  border-right: 1px solid rgba(var(--app-brand-tint-rgb), 0.25);
  border-left: 1px solid rgba(var(--app-brand-tint-rgb), 0.25);
}

.btn-label-primary.waves-effect .waves-ripple,
.btn-outline-primary.waves-effect .waves-ripple {
  background: radial-gradient(
    rgba(var(--app-brand-tint-rgb), 0.2) 0,
    rgba(var(--app-brand-tint-rgb), 0.3) 40%,
    rgba(var(--app-brand-tint-rgb), 0.4) 50%,
    rgba(var(--app-brand-tint-rgb), 0.5) 60%,
    rgba(255, 255, 255, 0) 70%
  );
}

/* ----- Active sidebar menu item ----- */
.bg-menu-theme.menu-vertical .menu-item.active > .menu-link:not(.menu-toggle),
.bg-menu-theme.menu-horizontal .menu-inner > .menu-item.active > .menu-link.menu-toggle {
  background: linear-gradient(72.47deg, var(--app-brand) 22.16%, var(--app-brand-hover) 76.47%);
  box-shadow: 0 2px 6px 0 rgba(var(--app-brand-rgb), 0.35);
  color: #fff !important;
}

[dir='rtl'] .bg-menu-theme.menu-vertical .menu-item.active > .menu-link:not(.menu-toggle),
[dir='rtl'] .bg-menu-theme.menu-horizontal .menu-inner > .menu-item.active > .menu-link.menu-toggle {
  background: linear-gradient(72.47deg, var(--app-brand-hover) 22.16%, var(--app-brand) 76.47%) !important;
}

.bg-menu-theme.menu-horizontal .menu-item.active > .menu-link:not(.menu-toggle) {
  background: rgba(var(--app-brand-tint-rgb), 0.08);
  color: var(--app-brand-fg-strong) !important;
}

html.dark-style .bg-menu-theme.menu-vertical .menu-item.active > .menu-link:not(.menu-toggle),
html.dark-style .bg-menu-theme.menu-horizontal .menu-inner > .menu-item.active > .menu-link.menu-toggle {
  box-shadow: inset 0 0 0 1px var(--app-brand-solid-border), 0 2px 6px 0 rgba(0, 0, 0, 0.3);
}

/* ----- Form focus ----- */
.form-control:focus,
.form-select:focus,
.input-group:focus-within .form-control,
.input-group:focus-within .input-group-text,
.select2-container--default.select2-container--focus .select2-selection,
.select2-container--default.select2-container--open .select2-selection,
.tagify--focus,
.daterangepicker .input-mini.active,
.dropzone.dz-drag-hover {
  border-color: var(--app-brand-fg) !important;
}

.form-check-input:focus,
.form-control:focus ~ .form-label,
.bootstrap-select .dropdown-toggle.show {
  border-color: var(--app-brand-fg);
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select ~ label,
.form-floating > .form-control:-webkit-autofill ~ label {
  color: var(--app-brand-fg);
}

/* ----- Checkboxes, radios, switches ----- */
.form-check-input:checked,
.form-check-input[type='checkbox']:indeterminate {
  background-color: var(--app-brand);
  border-color: var(--app-brand-solid-border);
}

.switch-input:checked ~ .switch-toggle-slider,
.switch-primary.switch .switch-input:checked ~ .switch-toggle-slider {
  background: var(--app-brand);
  border-color: var(--app-brand-solid-border) !important;
}

.switch-input:focus ~ .switch-toggle-slider,
.switch-primary.switch .switch-input:focus ~ .switch-toggle-slider {
  border: 1px solid var(--app-brand-fg);
  box-shadow: var(--app-focus-ring);
}

/* The theme gives every switch colour a purple focus glow; only the glow changes here,
   each variant keeps its own border colour. */
.switch-secondary.switch .switch-input:focus ~ .switch-toggle-slider,
.switch-success.switch .switch-input:focus ~ .switch-toggle-slider,
.switch-info.switch .switch-input:focus ~ .switch-toggle-slider,
.switch-warning.switch .switch-input:focus ~ .switch-toggle-slider,
.switch-danger.switch .switch-input:focus ~ .switch-toggle-slider,
.switch-dark.switch .switch-input:focus ~ .switch-toggle-slider,
.switch-gray.switch .switch-input:focus ~ .switch-toggle-slider {
  box-shadow: var(--app-focus-ring);
}

.custom-option.checked {
  border: 1px solid var(--app-brand-fg);
}

.custom-option-icon.checked i,
.custom-option-icon.checked svg {
  color: var(--app-brand-fg);
}

/* ----- Pagination ----- */
.page-item.active .page-link,
.pagination li.active > a:not(.page-link),
.page-item > .page-link.active,
.page-item.first .page-link.active,
.page-item.last .page-link.active,
.page-item.next .page-link.active,
.page-item.prev .page-link.active,
.page-item.previous .page-link.active {
  border-color: var(--app-brand-solid-border);
  background-color: var(--app-brand);
  color: #fff;
}

/* ----- Tabs & pills ----- */
.nav-tabs .nav-link.active,
.nav-tabs .nav-link.active:hover,
.nav-tabs .nav-link.active:focus {
  color: var(--app-brand-fg);
  box-shadow: 0 -2px 0 var(--app-brand-fg) inset;
}

.nav-align-bottom .nav-tabs .nav-link.active,
.nav-align-bottom .nav-tabs .nav-link.active:hover,
.nav-align-bottom .nav-tabs .nav-link.active:focus {
  box-shadow: 0 2px 0 var(--app-brand-fg) inset;
}

.nav-align-left .nav-tabs .nav-link.active,
.nav-align-left .nav-tabs .nav-link.active:hover,
.nav-align-left .nav-tabs .nav-link.active:focus,
[dir='rtl'] .nav-align-right .nav-tabs .nav-link.active,
[dir='rtl'] .nav-align-right .nav-tabs .nav-link.active:hover,
[dir='rtl'] .nav-align-right .nav-tabs .nav-link.active:focus {
  box-shadow: -2px 0 0 var(--app-brand-fg) inset;
}

.nav-align-right .nav-tabs .nav-link.active,
.nav-align-right .nav-tabs .nav-link.active:hover,
.nav-align-right .nav-tabs .nav-link.active:focus,
[dir='rtl'] .nav-align-left .nav-tabs .nav-link.active,
[dir='rtl'] .nav-align-left .nav-tabs .nav-link.active:hover,
[dir='rtl'] .nav-align-left .nav-tabs .nav-link.active:focus {
  box-shadow: 2px 0 0 var(--app-brand-fg) inset;
}

.nav-tabs.widget-nav-tabs .nav-link.active {
  border-color: var(--app-brand-fg);
}

.nav-tabs .nav-link:not(.active):hover,
.nav-tabs .nav-link:not(.active):focus,
.nav-pills .nav-link:not(.active):hover,
.nav-pills .nav-link:not(.active):focus {
  color: var(--app-brand-fg);
}

.nav-pills .nav-link.active,
.nav-pills .nav-link.active:hover,
.nav-pills .nav-link.active:focus {
  background-color: var(--app-brand);
  color: #fff;
}

html.dark-style .nav-pills .nav-link.active {
  box-shadow: inset 0 0 0 1px var(--app-brand-solid-border);
}

/* ----- Progress bars ----- */
.progress-bar {
  background-color: var(--app-brand);
  color: #fff;
}

/* A navy fill disappears on the dark track (#363b54), so dark mode uses the light tint
   (about 4:1 against the track) with navy text (5.96:1). */
html.dark-style .progress {
  --bs-progress-bar-bg: var(--app-brand-fg);
}

html.dark-style .progress-bar {
  background-color: var(--app-brand-fg);
  color: var(--app-brand-active);
}

/* ----- Dropdowns, lists, tables ----- */
.dropdown-item:not(.disabled).active,
.dropdown-item:not(.disabled):active,
.dropdown-menu > li:not(.disabled) > a:not(.dropdown-item):active,
.dropdown-menu > li.active:not(.disabled) > a:not(.dropdown-item),
.list-group-item-action.active,
.list-group-item-action.active:hover,
.list-group-item-action.active:focus {
  background-color: var(--app-brand);
  border-color: var(--app-brand-solid-border);
  color: #fff;
}

table.dataTable.dtr-column > tbody > tr > td.control:before,
table.dataTable.dtr-column > tbody > tr > th.control:before {
  background-color: var(--app-brand);
}

/* ----- Plugins used across the app ----- */
/* select2 (loaded on 435 views) */
.select2-results__option[role='option'][aria-selected='true'] {
  background-color: var(--app-brand);
  color: #fff;
}

.select2-container--default .select2-results__option--highlighted:not([aria-selected='true']) {
  background-color: rgba(var(--app-brand-tint-rgb), 0.08) !important;
  color: var(--app-brand-fg-strong) !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice,
.select2-primary .select2-container--default .select2-selection--multiple .select2-selection__choice {
  background: rgba(var(--app-brand-tint-rgb), 0.15) !important;
  color: var(--app-brand-fg-strong) !important;
}

/* ----- Forms & dropdowns (app-ui.js sections 14 and 16) ----- */
/* Required field: red asterisk after its label */
label.app-required::after {
  content: ' *';
  color: var(--bs-danger, #ea5455);
  font-weight: 600;
}

/* Dropdowns inside table rows (picking, transfers, repeaters) keep a readable width */
.table td .select2-container {
  min-width: 10rem;
}

.table td .select2-selection__rendered {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Disabled dropdowns look like disabled inputs */
.select2-container--default.select2-container--disabled .select2-selection {
  background-color: var(--app-surface-subtle);
  cursor: not-allowed;
  opacity: 0.85;
}

/* Lists opened inside a modal sit above it and stay readable */
.modal .select2-dropdown {
  z-index: 1090;
}

.select2-results__message {
  color: var(--app-text-muted);
  font-style: italic;
}

/* Wide tables inside modals: the header stays visible while scrolling */
.modal .table-responsive > .table > thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--app-surface);
}

/* Navbar page search (typeahead) */
.tt-suggestion:active,
.tt-cursor {
  background: var(--app-brand) !important;
  color: #fff !important;
}

.tt-suggestion:active a,
.tt-cursor a,
.tt-cursor .text-muted {
  color: #fff !important;
}

.light-style .twitter-typeahead .tt-suggestion:hover,
.light-style .twitter-typeahead .tt-suggestion:focus,
.dark-style .twitter-typeahead .tt-menu .tt-suggestion:hover,
.dark-style .twitter-typeahead .tt-menu .tt-suggestion:focus {
  background-color: rgba(var(--app-brand-tint-rgb), 0.08);
  color: var(--app-brand-fg-strong);
}

/* bootstrap-select */
.bootstrap-select .dropdown-menu.inner a[aria-selected='true'] {
  background: var(--app-brand) !important;
  color: #fff !important;
}

.bootstrap-select .dropdown-menu a:not([href]):not(.active):not(:active):not(.selected):hover {
  color: var(--app-brand-fg-strong) !important;
}

/* Date pickers (flatpickr, bootstrap-datepicker, daterangepicker, timepicker) */
.flatpickr-day.today {
  border-color: var(--app-brand-fg);
}

.flatpickr-day.inRange,
.flatpickr-day.nextMonthDay.inRange,
.flatpickr-day.prevMonthDay.inRange,
.flatpickr-day.today.inRange,
.flatpickr-day.prevMonthDay.today.inRange,
.flatpickr-day.nextMonthDay.today.inRange,
.datepicker table tr td.range,
.datepicker table tr td.range.highlighted,
.datepicker table tr td.range.today,
.daterangepicker td.in-range:not(.start-date):not(.end-date):not(.off) {
  color: var(--app-brand-fg-strong) !important;
  background: rgba(var(--app-brand-tint-rgb), 0.15) !important;
  border-color: transparent !important;
}

.flatpickr-day.selected,
.flatpickr-day.selected.inRange,
.flatpickr-day.selected:focus,
.flatpickr-day.selected:hover,
.flatpickr-day.selected.nextMonthDay,
.flatpickr-day.selected.prevMonthDay,
.flatpickr-day.startRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.startRange:focus,
.flatpickr-day.startRange:hover,
.flatpickr-day.startRange.nextMonthDay,
.flatpickr-day.startRange.prevMonthDay,
.flatpickr-day.endRange,
.flatpickr-day.endRange.inRange,
.flatpickr-day.endRange:focus,
.flatpickr-day.endRange:hover,
.flatpickr-day.endRange.nextMonthDay,
.flatpickr-day.endRange.prevMonthDay,
.flatpickr-day.week.selected {
  color: #fff !important;
  background: var(--app-brand) !important;
  border-color: var(--app-brand-solid-border) !important;
}

.datepicker table tr td.active,
.datepicker table tr td.active.highlighted,
.datepicker table tr td .focused,
.datepicker table tr td span.active,
.datepicker table tr td span.active.disabled,
.datepicker table tr td.range-start,
.datepicker table tr td.range-end,
.daterangepicker td.active:not(.off),
.daterangepicker .start-date:not(.end-date):not(.off):hover,
.daterangepicker .end-date:not(.start-date):not(.off):hover,
.ranges li.active,
li.ui-timepicker-selected,
.ui-timepicker-list .ui-timepicker-selected:hover {
  background: var(--app-brand) !important;
  color: #fff !important;
}

.daterangepicker .start-date:not(.end-date):not(.off),
.daterangepicker .end-date:not(.start-date):not(.off) {
  background-color: var(--app-brand);
  color: #fff;
}

.datepicker table tr td.today:not(.active) {
  box-shadow: 0 0 0 1px var(--app-brand-fg) inset;
}

/* Timeline (used on detail pages). The generic defaults stay without !important so the
   theme's success/danger/… variants keep their own colours. */
.timeline .timeline-item .timeline-point {
  background-color: var(--app-brand);
}

.timeline .timeline-point-primary {
  background-color: var(--app-brand) !important;
  box-shadow: 0 0 0 0.1875rem rgba(var(--app-brand-tint-rgb), 0.16);
}

.timeline .timeline-item .timeline-indicator i,
.timeline .timeline-item .timeline-indicator-advanced i {
  color: var(--app-brand-fg);
}

.timeline .timeline-indicator-primary i {
  color: var(--app-brand-fg) !important;
}

/* Carousel & Swiper (only in the Vuexy demo views under resources/views/content) */
.carousel-control-prev,
.carousel-control-next,
.carousel-control-prev:hover,
.carousel-control-prev:focus,
.carousel-control-next:hover,
.carousel-control-next:focus {
  color: var(--app-brand-fg);
}

.modal-onboarding .carousel-indicators [data-bs-target] {
  background-color: var(--app-brand-fg);
}

.swiper-pagination-bullet.swiper-pagination-bullet-active,
.swiper-pagination.swiper-pagination-progressbar .swiper-pagination-progressbar-fill {
  background: var(--app-brand-fg) !important;
}

/* =============================================================================
 * DataTables page design (set up by app-ui.js section 8, cells by AppTable)
 * ========================================================================== */
:root {
  --app-dt-bg: var(--bs-card-bg, #fff);
  --app-wa: #13824a; /* 4.86:1 on white */
  --app-warn-text: #ac5400; /* 5.22:1 on white */
  --app-negative: #c9302c; /* 5.33:1 on white */
  --app-gold-bg: #fdf3d7;
  --app-gold-text: #7a5a00; /* 5.77:1 on its background */
}

html.dark-style {
  --app-dt-bg: var(--bs-card-bg, #2f3349);
  --app-wa: #4fd18b; /* 6.4:1 on the dark card */
  --app-warn-text: #ffb269;
  --app-negative: #ff8a8a;
  --app-gold-bg: rgba(240, 199, 94, 0.16);
  --app-gold-text: #f0c75e; /* 5.35:1 on its background */
}

/* ----- Toolbar: search · filters · buttons (main action last) ----- */
/* Until an Ajax table has its data (init), DataTables' own controls wait hidden: they move into the toolbar then */
.dataTables_wrapper.app-dt-pending .dataTables_length,
.dataTables_wrapper.app-dt-pending .dataTables_filter,
.dataTables_wrapper.app-dt-pending .dt-buttons {
  display: none;
}

.app-dt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--app-border-subtle);
}

.app-dt-toolbar > div:empty {
  display: none;
}

.app-dt-toolbar-search {
  flex: 0 1 18rem;
  min-width: 12rem;
}

.app-dt-toolbar-filters {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
}

.app-dt-toolbar-actions {
  display: flex;
  margin-left: auto;
}

[dir='rtl'] .app-dt-toolbar-actions {
  margin-left: 0;
  margin-right: auto;
}

/* Search box with icon */
.app-dt-search,
.app-dt-search label {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 !important;
  text-align: start !important;
}

.app-dt-search-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 0.75rem;
  transform: translateY(-50%);
  color: var(--app-text-muted);
  font-size: 1.05rem;
  pointer-events: none;
}

.app-dt-search input {
  width: 100% !important;
  margin: 0 !important;
  padding-inline-start: 2.25rem !important;
}

/* Filters moved from the "Search Filter" card header */
.app-dt-filter {
  flex: 0 1 auto !important;
  width: auto !important;
  min-width: 10rem;
  max-width: 100%;
  margin: 0 !important;
  padding: 0 !important;
}

.app-dt-filter:empty {
  display: none;
}

.app-dt-filter .form-label {
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  color: var(--app-text-muted);
}

.app-dt-filter > [class*='mb-'],
.app-dt-filter .form-control,
.app-dt-filter .form-select {
  margin-bottom: 0 !important;
}

.app-dt-filter .select2-container {
  min-width: 10rem;
  width: 100% !important;
}

/* Toggle chip (a single checkbox filter, e.g. "Gold Client") */
.app-chip {
  min-width: 0;
}

.app-chip label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.375rem;
  margin: 0 !important;
  padding: 0.375rem 0.875rem;
  border: 1px solid var(--app-border-subtle);
  border-radius: 999px;
  background: var(--app-dt-bg);
  color: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.app-chip label:hover {
  border-color: var(--app-brand-fg);
}

.app-chip label:focus-within {
  box-shadow: var(--app-focus-ring);
}

.app-chip .form-check-input {
  float: none;
  margin: 0 !important;
}

.app-chip.is-active label {
  border-color: var(--app-brand-fg);
  background: rgba(var(--app-brand-tint-rgb), 0.1);
  color: var(--app-brand-fg-strong);
}

/* Buttons: outline secondary actions, one solid main action */
.app-dt-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 !important;
}

.app-dt-buttons > .btn,
.app-dt-buttons > .btn-group > .btn {
  margin: 0 !important;
  border-radius: var(--app-radius-sm) !important;
}

/* Footer: page size next to "Showing x–y of z" */
.app-dt-footer-start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.app-dt-length,
.app-dt-length label {
  margin: 0 !important;
}

.app-dt-length select {
  margin: 0 !important;
}

/* ----- Table body ----- */
.app-dt-scroll {
  position: relative;
  overflow: auto;
  max-height: max(24rem, calc(100vh - 16rem));
}

table.dataTable.app-dt > thead > tr > th,
table.dataTable.app-dt > thead > tr > td {
  padding-top: 0.625rem;
  padding-bottom: 0.625rem;
}

table.dataTable.app-dt > tbody > tr > td {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

/* Sticky header inside the scroll box */
.app-dt-scroll > table.dataTable > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--app-dt-bg);
  box-shadow: inset 0 -1px 0 var(--app-border-subtle);
}

/* Sticky action column on the right */
.app-dt-scroll > table.app-dt-has-actions > thead > tr > th:last-child,
.app-dt-scroll > table.app-dt-has-actions > tbody > tr > td.app-dt-actions-cell {
  position: sticky;
  inset-inline-end: 0;
  background-color: var(--app-dt-bg);
  box-shadow: -8px 0 8px -8px rgba(47, 43, 61, 0.18);
  white-space: nowrap;
}

[dir='rtl'] .app-dt-scroll > table.app-dt-has-actions > thead > tr > th:last-child,
[dir='rtl'] .app-dt-scroll > table.app-dt-has-actions > tbody > tr > td.app-dt-actions-cell {
  box-shadow: 8px 0 8px -8px rgba(47, 43, 61, 0.18);
}

.app-dt-scroll > table.app-dt-has-actions > thead > tr > th:last-child {
  z-index: 3;
}

.app-dt-scroll > table.app-dt-has-actions > tbody > tr > td.app-dt-actions-cell {
  z-index: 1;
}

/* A cell with an open row dropdown sits above the next rows and the sticky header (app-ui.js 17) */
.app-dt-scroll > table.app-dt-has-actions > tbody > tr > td.app-dt-actions-cell.app-dt-menu-open,
td.app-dt-menu-open {
  z-index: 4;
}

/* Keep the hover tint on the opaque sticky cell */
table.dataTable.app-dt > tbody > tr:hover > td.app-dt-actions-cell {
  background-image: linear-gradient(rgba(var(--app-brand-fg-rgb), 0.04), rgba(var(--app-brand-fg-rgb), 0.04));
}

/* Cell spacing: the theme pads every cell 1.5rem on both sides, which pushes 10+ column lists past
   the card. Tighter inner padding; the first / last column line up with the toolbar and footer
   (1.25rem from the card edge). Sortable headers keep room on the right for the sort arrows. */
table.dataTable.app-dt > thead > tr > th,
table.dataTable.app-dt > tbody > tr > td {
  padding-inline: 0.75rem;
}

/* DataTables fixes a pixel width at load (often a few px wider than the box, which shows a
   scrollbar for nothing); fill the box instead. A table whose columns need more still grows. */
table.dataTable.app-dt {
  width: 100% !important;
}

table.dataTable.app-dt > thead > tr > th.sorting,
table.dataTable.app-dt > thead > tr > th.sorting_asc,
table.dataTable.app-dt > thead > tr > th.sorting_desc {
  padding-inline-end: 1.5rem;
}

table.dataTable.app-dt > thead > tr > :first-child,
table.dataTable.app-dt > tbody > tr > :first-child {
  padding-inline-start: 1.25rem;
}

table.dataTable.app-dt > thead > tr > :last-child,
table.dataTable.app-dt > tbody > tr > :last-child {
  padding-inline-end: 1.25rem;
}

/* Header band: subtle background so the column titles read as one strip */
table.dataTable.app-dt > thead > tr > th,
.app-dt-scroll > table.dataTable > thead > tr > th,
.app-dt-scroll > table.app-dt-has-actions > thead > tr > th:last-child {
  background-color: var(--app-surface-subtle);
  color: var(--app-text-muted);
  border-bottom: 1px solid var(--app-border-subtle);
}

/* Rows: light separators, roomier line height for two-line names */
table.dataTable.app-dt > tbody > tr > td {
  border-bottom-color: var(--app-border-subtle);
  line-height: 1.35;
}

table.dataTable.app-dt > tbody > tr:last-child > td {
  border-bottom: 0;
}

/* Action buttons: compact, evenly spaced, never wrapping */
td.app-dt-actions-cell .btn-icon {
  width: 2rem;
  height: 2rem;
  margin-inline-end: 0.125rem !important;
}

td.app-dt-actions-cell .btn-icon:last-child {
  margin-inline-end: 0 !important;
}

/* Horizontal / vertical scrollbar of the table box: thin and quiet */
.app-dt-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--app-brand-fg-rgb), 0.25) transparent;
}

.app-dt-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.app-dt-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background-color: rgba(var(--app-brand-fg-rgb), 0.25);
}

.app-dt-scroll::-webkit-scrollbar-thumb:hover {
  background-color: rgba(var(--app-brand-fg-rgb), 0.4);
}

.app-dt-scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* Footer ("Showing x–y of z", page size, pagination): separated from the rows, same edge */
.card-datatable .dataTables_wrapper > .row:last-child {
  margin: 0 !important;
  padding: 0.75rem 0.5rem;
  border-top: 1px solid var(--app-border-subtle);
}

/* Long plain text: one line, full text in the tooltip */
td.app-dt-truncate,
.app-truncate {
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- Phones: each row becomes a card ----- */
@media (max-width: 767.98px) {
  .app-dt-toolbar {
    padding: 0.75rem 1rem;
  }

  .app-dt-toolbar-search {
    flex: 1 1 100%;
  }

  .app-dt-toolbar-actions {
    flex: 1 1 100%;
    margin-left: 0;
  }

  .app-dt-buttons > .btn {
    flex: 1 1 auto;
  }

  .app-dt-filter {
    flex: 1 1 100% !important;
  }

  .app-chip {
    flex: 0 1 auto !important;
    min-width: 0;
  }

  .app-dt-scroll.app-dt-scroll-cards {
    max-height: none;
    overflow: visible;
  }

  table.dataTable.app-dt-cards,
  table.dataTable.app-dt-cards > tbody {
    display: block;
    width: 100% !important;
    border: 0;
  }

  table.dataTable.app-dt-cards > thead {
    display: none;
  }

  table.dataTable.app-dt-cards > tbody > tr {
    display: block;
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--app-border-subtle);
    border-radius: var(--app-radius);
    background: var(--app-dt-bg);
    box-shadow: var(--app-shadow-sm);
  }

  table.dataTable.app-dt-cards > tbody > tr > td,
  table.dataTable.app-dt-cards > tbody > tr > td.dtr-hidden {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    max-width: none;
    padding: 0.375rem 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    text-align: end;
    white-space: normal;
    overflow: visible;
    position: static;
  }

  table.dataTable.app-dt-cards > tbody > tr > td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    color: var(--app-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-align: start;
    text-transform: uppercase;
  }

  table.dataTable.app-dt-cards > tbody > tr > td[data-label='']::before,
  table.dataTable.app-dt-cards > tbody > tr > td.app-dt-actions-cell::before,
  table.dataTable.app-dt-cards > tbody > tr > td.dataTables_empty::before {
    display: none;
  }

  table.dataTable.app-dt-cards > tbody > tr > td.app-dt-actions-cell {
    justify-content: flex-end;
    margin-top: 0.25rem;
    padding-top: 0.5rem !important;
    border-top: 1px solid var(--app-border-subtle) !important;
  }

  table.dataTable.app-dt-cards > tbody > tr > td.dataTables_empty {
    display: block !important;
    text-align: center;
  }

  table.dataTable.app-dt-cards > tbody > tr > td .app-cell-name,
  table.dataTable.app-dt-cards > tbody > tr > td .app-cell-text {
    min-width: 0;
    text-align: start;
  }

  table.dataTable.app-dt-cards > tbody > tr:hover > * {
    background: transparent !important;
  }
}

/* ----- Cell helpers (AppTable.render.*) ----- */
.app-cell-empty {
  color: var(--app-text-muted);
}

.app-cell-name {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 12rem;
}

.app-avatar {
  display: inline-flex;
  flex: 0 0 2.25rem;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
}

.app-avatar::before {
  content: attr(data-initials); /* not real text: stays out of exports and copy/paste */
}

.app-cell-text {
  min-width: 0;
}

.app-cell-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.375rem;
  color: var(--bs-heading-color, inherit);
  font-weight: 600;
  line-height: 1.35;
}

.app-cell-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.375rem;
  margin-top: 0.125rem;
}

.app-cell-sub {
  margin-top: 0.125rem;
  color: var(--app-text-muted);
  font-size: 0.8125rem;
  line-height: 1.35;
}

.app-cell-sub .ti {
  margin-inline-end: 0.25rem;
  font-size: 0.875rem;
  vertical-align: -0.1em;
}

/* Arabic lines keep RTL shaping but line up with the English above them */
html:not([dir='rtl']) .app-cell-text [dir='rtl'] {
  text-align: left;
}

.app-cell-label {
  color: var(--app-text-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.app-cell-link {
  color: inherit;
}

.app-cell-link:hover {
  color: var(--app-brand-fg);
  text-decoration: underline;
}

.app-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.45rem;
  border-radius: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
}

.app-badge .ti {
  font-size: 0.8125rem;
}

.app-badge-gold {
  background-color: var(--app-gold-bg);
  color: var(--app-gold-text);
}

.app-phone {
  color: inherit;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.app-phone:hover {
  color: var(--app-brand-fg);
  text-decoration: underline;
}

.app-wa {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  color: var(--app-wa);
  font-size: 1.05rem;
}

.app-wa:hover,
.app-wa:focus-visible {
  background-color: rgba(37, 211, 102, 0.14);
  color: var(--app-wa);
}

.app-wa-invalid {
  display: inline-flex;
  color: var(--app-warn-text);
  cursor: help;
}

.app-money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.app-money.is-negative {
  color: var(--app-negative);
}

.app-money-currency {
  color: var(--app-text-muted);
  font-size: 0.75em;
}

.app-date {
  white-space: nowrap;
}

/* Soft (label) badges and avatars: the theme's text colours are 1.7–2.9:1 on their
   tints; these are ≥ 4.65:1. Dark mode already uses bright text on dark tints. */
html:not(.dark-style) .badge.bg-label-success,
html:not(.dark-style) .app-avatar.bg-label-success {
  color: #197b44 !important;
}

html:not(.dark-style) .badge.bg-label-info,
html:not(.dark-style) .app-avatar.bg-label-info {
  color: #007685 !important;
}

html:not(.dark-style) .badge.bg-label-warning,
html:not(.dark-style) .app-avatar.bg-label-warning {
  color: #ac5400 !important;
}

html:not(.dark-style) .badge.bg-label-danger,
html:not(.dark-style) .app-avatar.bg-label-danger {
  color: #cc191a !important;
}

html:not(.dark-style) .badge.bg-label-secondary,
html:not(.dark-style) .app-avatar.bg-label-secondary {
  color: #6a6c72 !important;
}

/* ===== Confirmation dialogs (SweetAlert2, see app-ui.js section 10) ===== */
.swal2-actions.app-swal-actions {
  gap: 0.75rem;
}

.swal2-actions.app-swal-actions .btn {
  margin: 0;
}

/* Cancel is focused by default on delete-style questions: make that focus visible
   even when the dialog was opened with the mouse */
.swal2-actions.app-swal-actions .btn:focus {
  box-shadow: var(--app-focus-ring);
}

/* ===== Messages (SweetAlert2, see app-ui.js section 11) ===== */
/* The theme's .btn { display: … !important } beats SweetAlert2's inline display:none, so dialog buttons
   styled with .btn (Cancel on a notice, Deny) showed even when the dialog hides them. */
.swal2-actions .btn[style*="display: none"],
.swal2-actions .btn[style*="display:none"] {
  display: none !important;
}

/* Lists of validation / server errors: left-aligned and readable, scroll when long */
.swal2-html-container .app-swal-list {
  text-align: start;
  margin: 0 auto;
  padding-inline-start: 1.25rem;
  max-height: 40vh;
  overflow-y: auto;
}

.swal2-html-container .app-swal-list li + li {
  margin-top: 0.25rem;
}

/* Long server messages wrap instead of widening the dialog */
.swal2-popup .swal2-html-container {
  overflow-wrap: anywhere;
}

/* Toasts (were toastr): sit below the navbar, readable width */
.swal2-container.swal2-top-end {
  padding-top: 4.5rem;
}

.swal2-popup.swal2-toast.app-swal-toast {
  max-width: 24rem;
  padding: 0.75rem 1rem;
}

.swal2-popup.swal2-toast.app-swal-toast .swal2-title {
  font-size: 0.9375rem;
  margin: 0 0.5rem;
}

.swal2-popup.swal2-toast.app-swal-toast .swal2-html-container {
  font-size: 0.875rem;
  margin: 0.25rem 0.5rem 0;
}

/* ===== Outline secondary buttons (Export, etc.): readable grey =====
   The theme's #a8aaae is 2.3:1 on white; text #6a6c72 is 5.25:1, border #8a8d93 3.33:1. */
html:not(.dark-style) .btn-outline-secondary {
  color: #6a6c72;
  border-color: #8a8d93;
}

html:not(.dark-style) .btn-outline-secondary:hover,
html:not(.dark-style) .btn-outline-secondary:focus,
html:not(.dark-style) .btn-outline-secondary:active,
html:not(.dark-style) .btn-outline-secondary.active,
html:not(.dark-style) .btn-outline-secondary.show.dropdown-toggle {
  color: #5a5c62 !important;
  border-color: #8a8d93 !important;
}

/* Phones: the toolbar buttons wrap onto their own row, so show their labels
   (pages hide them below 576px with d-none d-sm-inline-block) */
@media (max-width: 575.98px) {
  .app-dt-buttons .btn .d-none.d-sm-inline-block {
    display: inline-block !important;
  }

  .app-dt-buttons .btn .ti + .d-none.d-sm-inline-block {
    margin-inline-start: 0.375rem;
  }
}

/* Per-currency amounts (AppTable.render.amounts): one line per currency */
.app-amounts {
  white-space: nowrap;
}

/* Two-line cell without the initials avatar (products, categories) */
.app-cell-name--plain {
  min-width: 8rem;
}

/* Codes such as barcodes */
.app-code {
  font-family: var(--bs-font-monospace, monospace);
  font-size: 0.8125rem;
  white-space: nowrap;
}

/* ===== Choice chips (<x-choice-chips>, see app-ui.js section 12) =====
   Multi-select checkboxes as a wrapping grid of chips: every option is readable
   on one or two lines, the checked state is obvious (fill + tick), and the
   toolbar shows how many are picked. */
.app-choice {
  --app-choice-border: #dbdade;
  border: 1px solid var(--app-border-subtle);
  border-radius: var(--app-radius);
  background: var(--app-surface-subtle);
  padding: 0.75rem;
}

html.dark-style .app-choice {
  --app-choice-border: #434968;
}

.app-choice-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.app-choice-count {
  font-size: 0.8125rem;
  color: var(--app-text-muted);
  margin-inline-end: auto;
}

.app-choice-count strong {
  color: var(--app-brand-fg);
  font-size: 0.9375rem;
}

.app-choice-filter {
  position: relative;
  flex: 0 1 14rem;
}

.app-choice-filter .ti {
  position: absolute;
  inset-inline-start: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--app-text-muted);
  pointer-events: none;
}

.app-choice-filter .form-control {
  padding-inline-start: 2rem;
}

.app-choice-actions {
  display: flex;
  gap: 0.25rem;
}

.app-choice-action {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 0;
  background: none;
  border-radius: var(--app-radius-sm);
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--app-brand-fg);
}

.app-choice-action:hover {
  background: rgba(var(--app-brand-tint-rgb), 0.08);
  color: var(--app-brand-fg-hover);
}

.app-choice-action:focus-visible {
  outline: 0;
  box-shadow: var(--app-focus-ring);
}

.app-choice-action[data-choice-clear] {
  color: var(--app-text-muted);
}

.app-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  grid-auto-rows: 1fr; /* one- and two-line chips line up */
  gap: 0.5rem;
}

.app-choice-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.75rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--app-choice-border);
  border-radius: var(--app-radius-sm);
  background: var(--app-surface);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.app-choice-item[hidden] {
  display: none;
}

/* The real checkbox covers the chip: clicks, keyboard and the browser's
   "required" message all land on it */
.app-choice-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.app-choice-check {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  border: 1.5px solid var(--app-choice-border);
  border-radius: 0.3125rem;
  color: transparent;
  font-size: 0.8125rem;
  transition: inherit;
}

.app-choice-text {
  font-size: 0.875rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.app-choice-item:hover {
  border-color: rgba(var(--app-brand-fg-rgb), 0.55);
  box-shadow: var(--app-shadow-sm);
}

.app-choice-item:focus-within:has(.app-choice-input:focus-visible) {
  box-shadow: var(--app-focus-ring);
}

.app-choice-item.is-checked {
  border-color: var(--app-brand-fg);
  background: rgba(var(--app-brand-tint-rgb), 0.08);
}

.app-choice-item.is-checked .app-choice-text {
  color: var(--app-brand-fg-strong);
  font-weight: 500;
}

.app-choice-item.is-checked .app-choice-check {
  border-color: var(--app-brand-solid-border);
  background: var(--app-brand);
  color: #fff;
}

.app-choice-empty {
  padding: 0.75rem 0 0.25rem;
  font-size: 0.875rem;
  color: var(--app-text-muted);
  text-align: center;
}

.app-choice-error {
  display: none;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--bs-danger, #ea5455);
}

.app-choice.is-invalid {
  border-color: var(--bs-danger, #ea5455);
}

.app-choice.is-invalid .app-choice-error {
  display: block;
}

@media (max-width: 575.98px) {
  .app-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-choice-filter {
    flex-basis: 100%;
    order: 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-choice-item {
    transition: none;
  }
}

/* ===== Form section headings (app-ui.js section 13) =====
   <h6>1. Title</h6><hr class="mt-0"> becomes a numbered step heading. */
.app-form-section {
  margin-top: 1.5rem;
}

.app-form-section-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0 !important;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--app-border-subtle);
  font-size: 1rem;
  font-weight: 600;
  color: var(--bs-heading-color, inherit);
}

.app-form-section-num {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: rgba(var(--app-brand-tint-rgb), 0.12);
  color: var(--app-brand-fg-strong);
  font-size: 0.8125rem;
  font-weight: 700;
}

.app-form-section-rule {
  display: none;
}

/* The first section of a card needs no extra space above it */
.card-body > form > .app-form-section:first-child,
.card-body > .app-form-section:first-child,
.modal-body .app-form-section:first-child {
  margin-top: 0;
}
