:root {
  --app-max-width: 1100px;
  --app-sidebar-width: 15rem;
  --app-page-pad-top: 1.5rem;
  --app-page-pad-bottom: 2rem;
  --app-content-gap: 1rem;

  /* Brand palette */
  --app-color-brand: #004159;
  --app-color-brand-strong: #003248;
  --app-color-gold: #b5902e;
  --app-color-gold-strong: #9a7a27;

  /* Neutrals */
  --app-color-bg-subtle: #f8fafc;
  --app-color-border-soft: rgba(15, 23, 42, 0.12);
  --app-color-text-muted: #5f6b7a;

  /* Bootstrap primary overrides */
  --bs-primary: #004159;
  --bs-primary-rgb: 0, 65, 89;
  --bs-link-color: #004159;
  --bs-link-color-rgb: 0, 65, 89;
  --bs-link-hover-color: #003248;
  --bs-link-hover-color-rgb: 0, 50, 72;

  /* Typography scale */
  --app-font-size-page-title: clamp(1.35rem, 1.2rem + 0.55vw, 1.75rem);
  --app-font-size-section-title: 1.05rem;
  --app-font-size-meta: 0.85rem;

  /* Spacing + shape */
  --app-radius-sm: 0.5rem;
  --app-radius-md: 0.75rem;
  --app-radius-lg: 1rem;
  --app-shadow-sm: 0 0.125rem 0.5rem rgba(15, 23, 42, 0.06);
  --app-shadow-md: 0 0.25rem 1rem rgba(15, 23, 42, 0.08);

  --app-card-border-color: rgba(0, 0, 0, 0.08);
  --app-card-shadow: var(--app-shadow-sm);
  --app-card-radius: var(--app-radius-md);
  --app-card-padding: 1.25rem;
  --app-card-padding-lg: 1.75rem;

  /* Inner panels (inside cards / modals) */
  --app-panel-radius: var(--app-radius-sm);
  --app-panel-border-color: var(--app-card-border-color);
  --app-panel-bg: var(--bs-tertiary-bg, #f8f9fa);
  --app-panel-padding: 1.5rem;
  --app-panel-padding-compact: 1rem;
}

/* Bootstrap nav-pills active state override */
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
  background-color: #004159;
  color: #fff;
}

/* Bootstrap button overrides — primary */
.btn-primary {
  --bs-btn-bg: #004159;
  --bs-btn-border-color: #004159;
  --bs-btn-hover-bg: #003248;
  --bs-btn-hover-border-color: #003248;
  --bs-btn-active-bg: #002b3c;
  --bs-btn-active-border-color: #002b3c;
  --bs-btn-focus-shadow-rgb: 0, 65, 89;
  --bs-btn-disabled-bg: #004159;
  --bs-btn-disabled-border-color: #004159;
}

.btn-outline-primary {
  --bs-btn-color: #004159;
  --bs-btn-border-color: #004159;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #004159;
  --bs-btn-hover-border-color: #004159;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #003248;
  --bs-btn-active-border-color: #003248;
  --bs-btn-focus-shadow-rgb: 0, 65, 89;
  --bs-btn-disabled-color: #004159;
  --bs-btn-disabled-border-color: #004159;
}

/* Make header feel app-like */
header.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: #004159;
  border-bottom: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
  color: #fff;
  padding-top: env(safe-area-inset-top, 0);
}

/* Desktop utility header — search, price check, clock */
.app-utility-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: #fff;
  border-bottom: 1px solid var(--app-color-border-soft);
}

.app-utility-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--app-max-width);
  margin: 0 auto;
  padding: 0.45rem 0.75rem;
}

.app-utility-clock {
  color: var(--app-color-text-muted);
  font-size: var(--app-font-size-meta);
  white-space: nowrap;
}

.app-utility-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.app-typeahead {
  position: relative;
  flex: 1 1 18rem;
  max-width: 22rem;
  min-width: 0;
}

.app-typeahead-input-group .input-group-text.app-typeahead-icon {
  background: var(--app-color-bg-subtle);
  border-color: var(--app-color-border-soft);
  color: var(--app-color-text-muted);
  padding-left: 0.7rem;
  padding-right: 0.7rem;
}

.app-typeahead-input-group .input-group-text.app-typeahead-icon .bi {
  font-size: 0.95rem;
  line-height: 1;
}

.app-typeahead-input {
  border-color: var(--app-color-border-soft);
  background: var(--app-color-bg-subtle);
}

.app-typeahead-input-group .app-typeahead-input {
  border-left: 0;
}

.app-typeahead-input:focus {
  border-color: rgba(0, 65, 89, 0.35);
  background: #fff;
  box-shadow: none;
}

.app-typeahead-input-group:focus-within .input-group-text.app-typeahead-icon {
  border-color: rgba(0, 65, 89, 0.35);
  background: #fff;
}

.app-typeahead-results {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  z-index: 1040;
  display: none;
  max-height: 18rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--app-color-border-soft);
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow-md);
}

.app-typeahead-results.is-visible {
  display: block;
}

.app-typeahead-group-label {
  padding: 0.45rem 0.75rem 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--app-color-text-muted);
}

.app-typeahead-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  text-decoration: none;
  color: var(--bs-body-color);
  min-height: 2.5rem;
}

a.app-typeahead-row:hover,
a.app-typeahead-row:focus-visible {
  background: rgba(0, 65, 89, 0.07);
  color: var(--app-color-brand-strong);
}

.app-typeahead-row-main {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.app-typeahead-row-meta,
.app-typeahead-row-type {
  color: var(--app-color-text-muted);
  font-size: var(--app-font-size-meta);
  white-space: nowrap;
}

.app-typeahead-row--price {
  gap: 0.65rem;
}

.app-typeahead-row-price {
  font-weight: 600;
  white-space: nowrap;
}

.app-typeahead-row--muted {
  color: var(--app-color-text-muted);
  font-size: var(--app-font-size-meta);
}

.app-header-inner,
main.app-main {
  max-width: var(--app-max-width);
}

.app-header-menu-btn {
  color: #fff;
  border: 0;
  border-radius: var(--app-radius-sm);
  padding: 0.45rem 0.55rem;
  line-height: 1;
  font-size: 1.35rem;
}

.app-header-menu-btn:hover,
.app-header-menu-btn:focus-visible {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.12);
}

/* Mobile offcanvas navigation */
.app-mobile-nav {
  --bs-offcanvas-width: min(18rem, calc(100vw - 2.5rem));
}

.app-mobile-nav .offcanvas-header {
  background: var(--app-color-brand);
  color: #fff;
}

.app-mobile-nav .offcanvas-title {
  color: #fff;
}

.app-mobile-nav .btn-close {
  filter: invert(1) grayscale(1);
  opacity: 0.85;
}

.app-mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.app-mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--app-radius-sm);
  text-decoration: none;
  color: var(--bs-body-color);
  font-weight: 500;
  min-height: 2.75rem;
}

.app-mobile-nav-link:hover,
.app-mobile-nav-link:focus-visible {
  background: rgba(0, 65, 89, 0.07);
  color: var(--app-color-brand-strong);
}

.app-mobile-nav-link.active {
  background: rgba(0, 65, 89, 0.12);
  color: var(--app-color-brand-strong);
  font-weight: 600;
}

.app-mobile-nav-link .bi {
  font-size: 1.05rem;
  opacity: 0.85;
}

.app-mobile-nav-section-label {
  margin: 0.85rem 0.35rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--app-color-text-muted);
}

/* Django messages → Bootstrap toasts (below sticky header on mobile) */
.app-toast-container {
  top: calc(4rem + env(safe-area-inset-top, 0));
  right: max(0.75rem, env(safe-area-inset-right, 0));
  z-index: 1085;
  max-width: min(22rem, calc(100vw - 1.5rem));
}

/* App shell + desktop sidebar */
.app-shell {
  min-height: 100vh;
}

.app-shell-content {
  min-width: 0;
}

.app-sidebar {
  width: var(--app-sidebar-width);
  flex-direction: column;
  background: var(--app-color-brand);
  color: #fff;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.18);
  padding: 0.85rem 0.75rem;
  gap: 0.5rem;
}

.app-sidebar-brand {
  padding: 0.5rem 0.6rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 0.35rem;
}

.app-sidebar-brand .brand img {
  display: block;
  max-width: 100%;
  height: auto;
}

.app-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow-y: auto;
  padding: 0.15rem 0;
  min-height: 0;
}

.app-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--app-radius-sm);
  text-decoration: none;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.25;
  transition: background-color 140ms ease, color 140ms ease;
}

.app-sidebar-link:hover,
.app-sidebar-link:focus-visible {
  background-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.app-sidebar-link.active {
  background-color: rgba(181, 144, 46, 0.28);
  color: #fff;
  font-weight: 600;
}

.app-sidebar-link .bi {
  font-size: 1.05rem;
  opacity: 0.9;
  flex-shrink: 0;
}

.app-sidebar-section-label {
  margin: 0.85rem 0.5rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.app-sidebar-footer {
  margin-top: auto;
  padding: 0.85rem 0.6rem 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.app-sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.65);
  min-width: 0;
}

.app-sidebar-user .bi {
  flex-shrink: 0;
}

.app-sidebar-logout {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.35rem 0;
}

.app-sidebar-logout:hover,
.app-sidebar-logout:focus-visible {
  color: #fff;
}

@media (min-width: 992px) {
  :root {
    --app-max-width: 1500px;
  }

  .app-shell {
    display: flex;
    align-items: stretch;
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
  }

  .app-shell-content {
    flex: 1;
    margin-left: var(--app-sidebar-width);
    width: calc(100% - var(--app-sidebar-width));
  }

  .app-toast-container {
    top: 1rem;
  }
}

header.app-header .brand {
  font-weight: 700;
  letter-spacing: 0.01em;
}

header.app-header .text-muted {
  color: rgba(255, 255, 255, 0.6) !important;
}

header.app-header a.text-decoration-none {
  color: rgba(255, 255, 255, 0.82);
}

header.app-header a.text-decoration-none:hover {
  color: #fff;
}

/* Reduce default table density slightly */
table td,
table th {
  vertical-align: top;
}

table thead th {
  font-weight: 600;
  color: var(--app-color-text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.app-table thead th {
  border-bottom-width: 1px;
  border-bottom-color: var(--app-color-border-soft);
}

.app-table > :not(caption) > * > * {
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.app-table tbody td {
  font-size: 0.94rem;
}

.app-table tbody tr:hover > * {
  background-color: rgba(0, 65, 89, 0.04);
}

.app-mr-table__expand-col {
  width: 2rem;
  padding-right: 0 !important;
}

/* Medical record list: capped viewport with internal scroll */
.app-mr-scroll {
  max-height: 24rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--app-color-border-soft);
  border-radius: var(--app-panel-radius, 0.5rem);
  background: #fff;
}

.app-mr-scroll .app-mobile-list {
  border: 0;
  border-radius: 0;
}

.app-mr-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: #fff;
  box-shadow: inset 0 -1px 0 var(--app-color-border-soft);
}

.app-mr-table__date-row > td {
  padding: 0.55rem 0.85rem !important;
  border-bottom: 1px solid rgba(0, 65, 89, 0.18) !important;
  background: linear-gradient(
    180deg,
    rgba(0, 65, 89, 0.1) 0%,
    rgba(0, 65, 89, 0.06) 100%
  ) !important;
  vertical-align: middle;
}

.app-mr-table__date-row:hover > td {
  background: linear-gradient(
    180deg,
    rgba(0, 65, 89, 0.1) 0%,
    rgba(0, 65, 89, 0.06) 100%
  ) !important;
}

.app-mr-date-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--app-color-brand-strong);
}

.app-mr-date-heading {
  padding: 0.55rem 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--app-color-brand-strong);
  background: linear-gradient(
    180deg,
    rgba(0, 65, 89, 0.1) 0%,
    rgba(0, 65, 89, 0.06) 100%
  );
  border-bottom: 1px solid rgba(0, 65, 89, 0.18);
}

/* Stripe logical rows only — used by treatment page; MR uses plain white rows */
.app-mr-table > tbody > tr.app-mr-table__row--striped > * {
  --bs-table-color-type: var(--bs-table-striped-color);
  --bs-table-bg-type: var(--bs-table-striped-bg);
  color: var(--bs-table-striped-color);
  background-color: var(--bs-table-striped-bg);
}

/* Medical record data rows: white + clear separators (no striping) */
.app-mr-scroll .app-mr-table > tbody > tr.app-mr-table__data-row > * {
  background-color: #fff;
  border-bottom: 1px solid var(--app-color-border-soft);
}

.app-mr-scroll .app-mr-table > tbody > tr.app-mr-table__data-row:hover > * {
  background-color: rgba(0, 65, 89, 0.04);
}

.app-mr-table__detail-row > td {
  padding: 0 !important;
  border: 0 !important;
  background-color: transparent !important;
}

.app-mr-table__detail-row:hover > td {
  background-color: transparent !important;
}

/* Open entry: white breakdown panel, rule before next row */
.app-mr-table__detail-row--open > td {
  border-bottom: 1px solid var(--app-color-border-soft) !important;
  padding-bottom: 0.65rem !important;
  line-height: normal;
  background-color: #fff !important;
}

.app-mr-table__detail-row--striped.app-mr-table__detail-row--open > td {
  background-color: var(--bs-table-striped-bg) !important;
}

/* Collapse gap only when fully closed */
.app-mr-table__detail-row:not(.app-mr-table__detail-row--open) > td {
  line-height: 0;
}

.app-mr-table__detail-row--open .app-mr-breakdown {
  margin: 0.35rem 0 0.5rem 2rem;
  background-color: #fff;
}

.app-mr-breakdown__table td {
  border: 0;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  font-size: 0.875rem;
}

.app-mr-breakdown__table tr:last-child td {
  padding-bottom: 0;
}

.app-mr-breakdown__nested td {
  font-size: 0.8125rem;
}

.app-lab-status-badge {
  font-weight: 600;
  vertical-align: middle;
}

.app-package-lab-badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  vertical-align: middle;
}

.app-lab-result-container {
  font-size: 0.875rem;
}

.app-lab-result__findings {
  white-space: pre-wrap;
}

.app-lab-result__attachments li + li {
  margin-top: 0.25rem;
}

.treatment-qty-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-wrap: nowrap;
  width: 100%;
}

.treatment-qty-cell .form-control {
  width: 4.5rem;
  flex: 0 0 auto;
}

.treatment-qty-unit {
  line-height: 1.2;
}

.app-dose-input-group {
  width: auto;
  max-width: 100%;
  margin-left: auto;
}

.app-dose-input-group .form-control {
  width: 4rem;
  max-width: 4rem;
  flex: 0 0 4rem;
  text-align: right;
}

.app-dose-input-group .input-group-text {
  font-size: 0.75rem;
  color: var(--bs-secondary-color, #6c757d);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

#calendar .fc-timegrid-slot {
  min-height: 26px;
}

/*
 * Outside-hours bands — Before (FC all-day) and After (custom lane).
 * Chip typography matches main timed-event chips (.fc .app-cal-ev-*).
 */
#calendar {
  --app-cal-outside-max-height: 5.5rem;
  --app-cal-outside-pad: 0.1rem;
  --app-cal-outside-gap: 1px;
  --app-cal-ev-time-size: 0.62rem;
  --app-cal-ev-body-size: 0.68rem;
  overflow-x: hidden;
  max-width: 100%;
}

#calendar .fc-timegrid .fc-daygrid-body,
#calendar .app-cal-after-hours {
  max-height: var(--app-cal-outside-max-height);
  overflow: hidden;
}

/* FC natural all-day adds margin-bottom: 1em — remove so chips sit flush like After Hours. */
#calendar .fc-timegrid .fc-daygrid-body-natural .fc-daygrid-day-events {
  margin-bottom: 0;
}

/* Kill FC clearfix that can add stray height in the all-day row. */
#calendar .fc-timegrid .fc-daygrid-day-events:before,
#calendar .fc-timegrid .fc-daygrid-day-events:after,
#calendar .fc-timegrid .fc-daygrid-day-frame:before,
#calendar .fc-timegrid .fc-daygrid-day-frame:after,
#calendar .fc-timegrid .fc-daygrid-event-harness:before,
#calendar .fc-timegrid .fc-daygrid-event-harness:after {
  content: none;
  display: none;
}

#calendar .fc-timegrid .fc-daygrid-day-frame {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--app-cal-outside-pad);
}

#calendar .fc-timegrid .fc-daygrid-day-events {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0 !important;
  margin-top: 0;
  overflow: hidden;
}

#calendar .fc-timegrid .fc-daygrid-day-bottom {
  display: none;
}

#calendar .fc-timegrid .fc-daygrid-event-harness {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#calendar .fc-timegrid .fc-daygrid-event-harness + .fc-daygrid-event-harness {
  margin-top: var(--app-cal-outside-gap);
}

#calendar .fc-timegrid .fc-daygrid-event.app-cal-ev--outside-hours {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  margin: 0 !important; /* override FC daygrid start/end side margins */
  overflow: hidden;
  white-space: normal;
}

#calendar .fc-timegrid .fc-daygrid-event.app-cal-ev--outside-hours .fc-event-main {
  height: 100%;
  min-height: 0;
  padding: 0;
}

/* Shared axis label style: Before Hours, After Hours, and 9am / 10am / … slot labels. */
#calendar .app-cal-hours-axis-label,
#calendar .fc-timegrid-slot-label,
#calendar .fc-timegrid-slot-label-cushion,
#calendar .fc-timegrid-axis-cushion,
#calendar .fc-daygrid .fc-timegrid-axis-cushion {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--bs-secondary-color, #6c757d);
  text-align: right;
}

#calendar .app-cal-hours-axis-label {
  display: block;
}

#calendar .fc-timegrid-slot-label,
#calendar .fc-timegrid-axis-cushion {
  padding-top: 0;
  padding-bottom: 0;
}

/* Match After Hours axis padding on the Before Hours FC cushion. */
#calendar .fc-daygrid .fc-timegrid-axis-cushion {
  padding: 0.25rem 0.35rem;
}

/*
 * Outside-hours chip shell only (layout). Text styles live with main chips below
 * so After Hours (outside `.fc`) stays in sync.
 */
#calendar .fc-event.app-cal-ev--outside-hours,
#calendar .app-cal-after-hours .fc-event {
  display: block;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.2rem;
  overflow: hidden;
  cursor: pointer;
}

#calendar .app-cal-after-hours .fc-event {
  flex: 1 1 auto;
  min-height: 0;
}

#calendar .app-cal-after-hours .fc-event + .fc-event {
  margin-top: var(--app-cal-outside-gap);
}

/* After-hours lane under the calendar (sibling of .fc so it stays inside the card). */
#calendar .app-cal-after-hours {
  display: flex;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  /* Top border + FC's bottom border = double line, mirroring Before Hours' double bottom. */
  border: 1px solid var(--fc-border-color, #ddd);
  background: var(--bs-body-bg, #fff);
}

#calendar .app-cal-after-hours-axis {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  padding: 0.25rem 0.35rem;
  text-align: right;
  border-right: 1px solid var(--fc-border-color, #ddd);
  box-sizing: border-box;
  min-width: 0;
}

#calendar .app-cal-after-hours-cols {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

#calendar .app-cal-after-hours-col {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-width: 0;
  box-sizing: border-box;
  border-right: 1px solid var(--fc-border-color, #ddd);
  padding: var(--app-cal-outside-pad);
  overflow: hidden;
}

/* Absorbs FC's vertical scrollbar gutter so day columns match the time grid. */
#calendar .app-cal-after-hours-gutter {
  flex: 1 1 auto;
  min-width: 0;
}

/* Utility */
.muted {
  color: var(--bs-secondary-color, #6c757d);
}

.app-page-title {
  font-size: var(--app-font-size-page-title);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.app-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.app-section-header > h1,
.app-section-header > h2,
.app-section-header > h3 {
  margin: 0;
}

.app-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: var(--app-font-size-meta);
  line-height: 1.2;
  border-radius: 999px;
  border: 1px solid var(--app-color-border-soft);
  background: var(--app-color-bg-subtle);
  color: var(--app-color-text-muted);
  padding: 0.28rem 0.55rem;
}

.app-action-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Shared card system for consistent section styling */
.app-card {
  border: 1px solid var(--app-card-border-color);
  border-radius: var(--app-card-radius);
  box-shadow: var(--app-card-shadow);
  background: var(--bs-body-bg, #fff);
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

.app-card-body {
  padding: var(--app-card-padding);
}

.app-card-title {
  margin-bottom: 1rem;
  font-size: var(--app-font-size-section-title);
  font-weight: 600;
  letter-spacing: 0.005em;
}

.app-card:hover {
  box-shadow: var(--app-shadow-md);
}

@media (min-width: 992px) {
  .app-card-body {
    padding: var(--app-card-padding-lg);
  }
}

/* Nested sections inside cards (forms, grouped fields) */
.app-panel {
  border: 1px solid var(--app-panel-border-color);
  border-radius: var(--app-panel-radius);
  background-color: var(--app-panel-bg);
  padding: var(--app-panel-padding);
  transition: border-color 140ms ease, background-color 140ms ease;
}

.app-panel--compact {
  padding: var(--app-panel-padding-compact);
}

.app-panel-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--bs-secondary-color);
}

/* Catalog service tracking type card picker */
.app-tracking-type-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  height: 100%;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--app-panel-border-color);
  border-radius: var(--app-panel-radius);
  background: var(--bs-body-bg);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.app-tracking-type-card:hover {
  border-color: rgba(var(--bs-primary-rgb), 0.45);
}

.app-tracking-type-card.is-selected,
.app-tracking-type-card:has(.app-tracking-type-input:checked) {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 1px var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.04);
}

.app-tracking-type-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.04);
  font-size: 1.1rem;
}

.app-tracking-type-card__title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.25;
  color: var(--bs-body-color);
}

.app-tracking-type-card__example {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--bs-secondary-color);
}

.app-tracking-type-card__detail {
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--bs-secondary-color);
}

/* === Patient Insight Panels === */
.app-insight-panel {
  border-top: 3px solid var(--insight-accent, var(--app-panel-border-color));
}

.app-insight-panel .app-panel-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.2rem;
}

.app-insight-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1.1rem;
  margin-bottom: 0.55rem;
  flex-shrink: 0;
  background-color: var(--insight-icon-bg, rgba(0, 0, 0, 0.06));
  color: var(--insight-accent, #6c757d);
}

.app-insight-panel__value {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.15rem;
  color: var(--bs-body-color);
}

.app-insight-panel--blue   { --insight-accent: #0d6efd; --insight-icon-bg: rgba(13, 110, 253, 0.09); }
.app-insight-panel--green  { --insight-accent: #198754; --insight-icon-bg: rgba(25, 135, 84, 0.09); }
.app-insight-panel--purple { --insight-accent: #6f42c1; --insight-icon-bg: rgba(111, 66, 193, 0.09); }
.app-insight-panel--amber  { --insight-accent: #fd7e14; --insight-icon-bg: rgba(253, 126, 20, 0.09); }
.app-insight-panel--teal   { --insight-accent: #0891b2; --insight-icon-bg: rgba(8, 145, 178, 0.09); }
.app-insight-panel--rose   { --insight-accent: #d63384; --insight-icon-bg: rgba(214, 51, 132, 0.09); }

/* Bordered list block (e.g. patient rows on client detail) */
.app-list-surface {
  border-radius: var(--app-panel-radius);
  overflow: hidden;
  border-color: var(--app-panel-border-color);
}

.app-list-surface .list-group-item {
  border-color: var(--app-panel-border-color);
}

/* Keep client patients card compact; scroll patient rows after ~3 items. */
.client-patients-card {
  overflow: hidden;
}

.client-patients-panel {
  min-height: 0;
}

/* Outer wrapper: fade is a sibling overlay so it stays pinned to the bottom of the viewport, not the scroll content. */
.client-patients-scroll-outer {
  position: relative;
  min-height: 0;
}

.client-patients-scroll {
  max-height: 18.5rem;
  overflow-y: auto;
  min-height: 0;
}

.client-patients-bottom-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.75rem;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    var(--bs-body-bg, #fff)
  );
}

/* Empty / placeholder region */
.app-empty-state {
  border: 2px dashed var(--app-panel-border-color);
  border-radius: var(--app-panel-radius);
  padding: 2.5rem 1rem;
  background-color: rgba(
    var(--bs-tertiary-bg-rgb, 233, 236, 239),
    0.5
  );
}

/* Common forms + controls */
.form-control,
.form-select {
  border-color: var(--app-color-border-soft);
  min-height: 2.5rem;
}

.form-control:focus,
.form-select:focus,
.btn:focus-visible,
a:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(0, 65, 89, 0.25);
}

.form-label {
  margin-bottom: 0.375rem;
  font-weight: 600;
  color: #253041;
}

.app-form-error {
  color: #b42318;
  font-size: 0.82rem;
  margin-top: 0.35rem;
}

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

.btn {
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

@media (hover: none) {
  .btn:hover {
    transform: none;
  }
}

/* Modal spacing consistency */
.modal-header {
  padding: 1rem 1.25rem 0.25rem;
}

.modal-body {
  padding: 0.75rem 1.25rem 1rem;
}

.modal-footer {
  padding: 0.5rem 1.25rem 1.1rem;
}

.app-modal-subtitle {
  margin: 0;
  color: var(--app-color-text-muted);
  font-size: 0.85rem;
}

@media (min-width: 576px) {
  .app-modal-dialog--exam-note {
    max-width: min(80rem, 90vw);
  }
}

/* Scrollable HTMX modals: partials use .modal-header + .app-modal-form(.modal-body/.modal-footer).
   Shells: #patient-modal, #exam-note-modal, #client-modal, #appointment-modal, #inventory-modal
   (patient/client list & detail, chart, calendar, inventory). */
.modal-dialog-scrollable .modal-content {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
}

.modal-dialog-scrollable .modal-content > .modal-header,
.modal-dialog-scrollable .modal-content > .app-modal-form > .modal-header {
  flex-shrink: 0;
}

.modal-dialog-scrollable .modal-content > .app-modal-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.modal-dialog-scrollable .modal-content > .app-modal-form > .modal-body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.modal-dialog-scrollable .modal-content > .app-modal-form > .modal-footer {
  flex-shrink: 0;
}

/* FullCalendar — compact event body (client / patient); content built in calendar.html.
 * Include After Hours (outside `.fc`) so all schedule chips share one type scale. */
.fc .app-cal-ev-wrap,
#calendar .app-cal-after-hours .app-cal-ev-wrap {
  min-width: 0;
  text-align: left;
  padding: 0 1px;
}

#calendar .fc-event.app-cal-ev--outside-hours .app-cal-ev-wrap,
#calendar .app-cal-after-hours .fc-event .app-cal-ev-wrap {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.fc .app-cal-ev-time,
#calendar .app-cal-after-hours .app-cal-ev-time {
  font-size: var(--app-cal-ev-time-size, 0.62rem);
  font-weight: 700;
  line-height: 1.05;
  margin-bottom: 0.1rem;
  opacity: 0.95;
}

.fc .app-cal-ev,
#calendar .app-cal-after-hours .app-cal-ev {
  font-size: var(--app-cal-ev-body-size, 0.68rem);
  line-height: 1.12;
  min-width: 0;
}

.fc .app-cal-ev-line,
#calendar .app-cal-after-hours .app-cal-ev-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fc .app-cal-ev-patient,
#calendar .app-cal-after-hours .app-cal-ev-patient {
  font-weight: 600;
  opacity: 0.95;
}

.fc .app-cal-ev-link,
#calendar .app-cal-after-hours .app-cal-ev-link {
  color: inherit;
  text-decoration: underline;
  font-weight: inherit;
}

.fc .app-cal-ev-link:hover,
#calendar .app-cal-after-hours .app-cal-ev-link:hover {
  opacity: 0.9;
}

.fc-daygrid-event .app-cal-ev {
  font-size: 0.62rem;
}

.fc-daygrid-event .app-cal-ev-time {
  font-size: 0.58rem;
}

/* Before Hours is daygrid-inside-timegrid — keep main timed-chip sizes, not month compact. */
#calendar .fc-timegrid .fc-daygrid-event.app-cal-ev--outside-hours .app-cal-ev {
  font-size: var(--app-cal-ev-body-size, 0.68rem);
}

#calendar .fc-timegrid .fc-daygrid-event.app-cal-ev--outside-hours .app-cal-ev-time {
  font-size: var(--app-cal-ev-time-size, 0.62rem);
}

.fc-event.app-cal-ev--cancelled .app-cal-ev-wrap,
.fc-event.app-cal-ev--cancelled .app-cal-ev-time,
.fc-event.app-cal-ev--cancelled .app-cal-ev-line,
.fc-event.app-cal-ev--cancelled .app-cal-ev-link {
  text-decoration: line-through;
}

/* Schedule — right-click context menu (primary row + flyout for Status, etc.) */
.app-cal-quick-status-menu {
  position: fixed;
  z-index: 3000;
  margin: 0;
  padding: 0;
  list-style: none;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.app-cal-quick-status-menu .app-cal-ctx-shell {
  min-width: 10.5rem;
  padding: 0.25rem 0;
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--app-color-border-soft);
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow-md);
}

.app-cal-ctx-parent {
  position: relative;
}

.app-cal-ctx-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--bs-body-color, #212529);
  cursor: default;
  user-select: none;
}

.app-cal-ctx-chevron {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.55;
}

@media (hover: hover) and (pointer: fine) {
  .app-cal-ctx-parent:hover .app-cal-ctx-primary,
  .app-cal-ctx-parent:focus-within .app-cal-ctx-primary {
    background-color: rgba(0, 65, 89, 0.07);
  }

  .app-cal-ctx-parent:hover .app-cal-ctx-flyout,
  .app-cal-ctx-parent:focus-within .app-cal-ctx-flyout {
    display: block;
  }
}

@media (hover: none) {
  .app-cal-ctx-parent--open .app-cal-ctx-flyout {
    display: block;
  }

  .app-cal-ctx-parent--open .app-cal-ctx-primary {
    background-color: rgba(0, 65, 89, 0.09);
  }
}

.app-cal-ctx-flyout {
  display: none;
  position: absolute;
  left: 100%;
  top: -0.25rem;
  margin-left: -1px;
  z-index: 3001;
  min-width: 11rem;
  padding: 0.25rem 0;
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--app-color-border-soft);
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow-md);
}

.app-cal-ctx--flip-flyout .app-cal-ctx-flyout {
  left: auto;
  right: 100%;
  margin-left: 0;
  margin-right: -1px;
}

.app-cal-quick-status-menu .app-cal-quick-status-item {
  display: block;
  border: 0;
  background: transparent;
  width: 100%;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  text-align: left;
  color: var(--bs-body-color, #212529);
}

.app-cal-quick-status-menu .app-cal-quick-status-item:hover,
.app-cal-quick-status-menu .app-cal-quick-status-item:focus {
  background-color: rgba(0, 65, 89, 0.08);
}

.app-cal-quick-status-menu .app-cal-ctx-flyout-link {
  display: block;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  text-align: left;
  color: var(--bs-body-color, #212529);
  text-decoration: none;
}

.app-cal-quick-status-menu .app-cal-ctx-flyout-link:hover,
.app-cal-quick-status-menu .app-cal-ctx-flyout-link:focus {
  background-color: rgba(0, 65, 89, 0.08);
  color: var(--bs-body-color, #212529);
}

.app-cal-quick-status-menu .app-cal-quick-status-item.active {
  background-color: rgba(0, 65, 89, 0.14);
  font-weight: 600;
}

/* Page shell */
main.app-main {
  padding-top: var(--app-page-pad-top) !important;
  padding-bottom: calc(var(--app-page-pad-bottom) + env(safe-area-inset-bottom, 0));
  padding-left: max(calc(var(--bs-gutter-x, 1.5rem) * 0.5), env(safe-area-inset-left, 0));
  padding-right: max(calc(var(--bs-gutter-x, 1.5rem) * 0.5), env(safe-area-inset-right, 0));
}

main.app-main > * + * {
  margin-top: var(--app-content-gap);
}

/* ── Reusable mobile card list ──────────────────────────────────────────────
   Rendered inside a d-md-none wrapper as the phone-only alternative to a wide
   d-none d-md-block table. Rows are either a tappable <a> (navigation) or a
   <div> containing explicit action buttons (CRUD). */
.app-mobile-list {
  border: 1px solid var(--app-color-border-soft);
  border-radius: var(--app-panel-radius);
  overflow: hidden;
}
.app-mobile-row {
  display: block;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--app-color-border-soft);
  text-decoration: none;
  color: inherit;
}
.app-mobile-row:last-child { border-bottom: 0; }
a.app-mobile-row:hover,
a.app-mobile-row:focus-visible {
  background: rgba(0, 65, 89, 0.05);
  color: inherit;
}
.app-mobile-row.is-hidden { display: none; }
.app-mobile-row__title { font-weight: 600; line-height: 1.3; }
.app-mobile-row__meta { font-size: 0.85rem; margin-top: 0.2rem; }
.app-mobile-row__meta .app-mobile-row__label { color: var(--app-color-text-muted); }
.app-mobile-row__badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.app-mobile-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}
.app-mobile-row__actions .btn { min-height: 2.75rem; }

@media (max-width: 767.98px) {
  :root {
    --app-page-pad-top: 1rem;
    --app-page-pad-bottom: 1.25rem;
    --app-content-gap: 0.85rem;
    --app-card-padding: 1rem;
  }

  header.app-header .brand {
    font-size: 0.98rem;
  }

  .app-page-title {
    font-size: clamp(1.15rem, 1.05rem + 0.7vw, 1.4rem);
  }

  .app-section-header {
    gap: 0.65rem;
  }

  .modal-footer {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .client-patients-scroll {
    max-height: none;
  }

  .client-patients-bottom-fade {
    display: none;
  }

  /* Larger touch targets on phones */
  .btn-sm {
    min-height: 2.75rem;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
  }

  .app-action-row .btn,
  .app-section-header > .btn,
  .app-section-header .app-action-row .btn {
    min-height: 2.75rem;
  }

  div.dataTables_wrapper div.dataTables_paginate .paginate_button {
    min-width: 2.75rem;
    min-height: 2.75rem;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Client list — mobile card rows */
  .app-client-mobile-row {
    display: block;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--app-color-border-soft);
    text-decoration: none;
    color: inherit;
  }

  .app-client-mobile-row:last-child {
    border-bottom: 0;
  }

  .app-client-mobile-row:hover,
  .app-client-mobile-row:focus-visible {
    background: rgba(0, 65, 89, 0.05);
    color: inherit;
  }

  .app-client-mobile-row.is-hidden {
    display: none;
  }

  /* FullCalendar — mobile readability */
  #calendar .fc-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  #calendar .fc-toolbar-title {
    font-size: 1rem;
  }

  #calendar .fc-timegrid-slot {
    min-height: 2rem;
  }

  #calendar {
    --app-cal-ev-time-size: 0.72rem;
    --app-cal-ev-body-size: 0.78rem;
  }

  .fc .app-cal-ev-time,
  #calendar .app-cal-after-hours .app-cal-ev-time {
    font-size: var(--app-cal-ev-time-size);
  }

  .fc .app-cal-ev,
  #calendar .app-cal-after-hours .app-cal-ev {
    font-size: var(--app-cal-ev-body-size);
  }

  .fc .fc-button {
    min-height: 2.5rem;
    padding: 0.35rem 0.65rem;
  }

  /* Stack calendar quick-action flyouts on narrow screens */
  .app-cal-ctx-flyout {
    position: static;
    left: auto;
    right: auto;
    top: auto;
    margin: 0;
    min-width: 0;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: 0 0 0.25rem 0.75rem;
  }

  .app-cal-ctx--flip-flyout .app-cal-ctx-flyout {
    left: auto;
    right: auto;
    margin: 0;
    padding: 0 0 0.25rem 0.75rem;
  }

  .app-cal-ctx-primary {
    min-height: 2.75rem;
    cursor: pointer;
  }

  .app-cal-quick-status-menu .app-cal-quick-status-item,
  .app-cal-quick-status-menu .app-cal-ctx-flyout-link {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
  }

  /* FullCalendar list/agenda — touch sizing */
  #calendar .fc-list-event { min-height: 2.75rem; }
  #calendar .fc-list-event-title a { padding: 0.15rem 0; }
}

@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;
  }
}

/* HTMX loading affordances */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
}

.htmx-request button[type="submit"],
.htmx-request .btn[type="submit"] {
  opacity: 0.75;
  pointer-events: none;
}

/* DataTables — match app tokens inside list cards */
div.dataTables_wrapper {
  padding-top: 0.25rem;
}

div.dataTables_wrapper .row {
  --bs-gutter-x: 1rem;
  --bs-gutter-y: 0.75rem;
  align-items: end;
}

div.dataTables_wrapper div.dataTables_length label,
div.dataTables_wrapper div.dataTables_filter label {
  font-size: var(--app-font-size-meta);
  font-weight: 600;
  color: var(--app-color-text-muted);
  margin-bottom: 0.25rem;
}

div.dataTables_wrapper div.dataTables_length select {
  border: 1px solid var(--app-color-border-soft);
  border-radius: var(--app-radius-sm);
  padding: 0.35rem 2rem 0.35rem 0.6rem;
  min-height: 2.25rem;
  font-size: 0.9rem;
  background-color: var(--bs-body-bg, #fff);
  color: var(--bs-body-color);
}

div.dataTables_wrapper div.dataTables_filter input {
  border: 1px solid var(--app-color-border-soft);
  border-radius: var(--app-radius-sm);
  padding: 0.4rem 0.75rem;
  min-height: 2.25rem;
  font-size: 0.9rem;
  margin-left: 0.5rem;
  max-width: 16rem;
}

div.dataTables_wrapper div.dataTables_filter input:focus {
  outline: none;
  border-color: var(--app-color-brand);
  box-shadow: 0 0 0 0.2rem rgba(0, 65, 89, 0.25);
}

div.dataTables_wrapper div.dataTables_info {
  padding-top: 0.75rem;
  font-size: var(--app-font-size-meta);
  color: var(--app-color-text-muted);
}

div.dataTables_wrapper div.dataTables_paginate {
  padding-top: 0.75rem;
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button {
  border: 1px solid var(--app-color-border-soft) !important;
  border-radius: var(--app-radius-sm) !important;
  background: var(--bs-body-bg, #fff) !important;
  color: var(--bs-body-color) !important;
  margin: 0 0.15rem !important;
  padding: 0.35rem 0.65rem !important;
  font-size: 0.875rem !important;
  line-height: 1.25 !important;
  min-width: 2.25rem;
  text-align: center;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button:hover:not(.disabled) {
  background: rgba(0, 65, 89, 0.08) !important;
  border-color: rgba(0, 65, 89, 0.35) !important;
  color: var(--app-color-brand-strong) !important;
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button.current {
  background: var(--app-color-brand) !important;
  border-color: var(--app-color-brand) !important;
  color: #fff !important;
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button.disabled,
div.dataTables_wrapper div.dataTables_paginate .paginate_button.disabled:hover {
  opacity: 0.45;
  cursor: not-allowed !important;
  background: var(--bs-body-bg, #fff) !important;
  color: var(--app-color-text-muted) !important;
}

@media (max-width: 767.98px) {
  div.dataTables_wrapper div.dataTables_filter input {
    max-width: 100%;
    margin-left: 0;
    margin-top: 0.35rem;
  }

  div.dataTables_wrapper div.dataTables_filter label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
}

/* Client / patient — internal alerts callout (high-visibility) */
.app-alerts-callout {
  border-radius: var(--app-radius-md);
  border: 2px solid rgba(220, 53, 69, 0.55);
  background: linear-gradient(
    135deg,
    rgba(255, 243, 205, 0.95) 0%,
    rgba(255, 248, 225, 0.98) 100%
  );
  box-shadow: 0 0.35rem 1.25rem rgba(220, 53, 69, 0.12);
}

.app-alerts-callout__inner {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 1.25rem;
}

.app-alerts-callout__icon {
  flex-shrink: 0;
  font-size: 1.5rem;
  line-height: 1;
  color: #b02a37;
}

.app-alerts-callout__label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #842029;
  margin-bottom: 0.35rem;
}

.app-alerts-callout__text {
  font-size: 1.05rem;
  line-height: 1.45;
  color: #58151c;
  white-space: pre-wrap;
}

/* Keep Tom Select dropdown above Bootstrap modals */
.ts-dropdown {
  z-index: 2000 !important;
}

/* Whole-dollar discount fields: plain text entry, no number spinners */
.app-discount-input {
  -moz-appearance: textfield;
  appearance: textfield;
}

.app-discount-input::-webkit-outer-spin-button,
.app-discount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Generic no-spinner number input */
.app-no-spinners {
  -moz-appearance: textfield;
  appearance: textfield;
}

.app-no-spinners::-webkit-outer-spin-button,
.app-no-spinners::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
