/* Element defaults and Bootstrap surfaces, light and dark. */
html {
  font-size: 100%;
}

/* Almarai for text, Readex Pro for headings (fonts linked in layouts/base.php). Arabic is never
   tracked: the theme's letter-spacing goes. */
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: normal;
  background-color: var(--uh-bg);
  color: var(--uh-text);
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--font-display);
  color: var(--uh-heading);
}

a {
  color: var(--uh-link);
}

/* Focus: a 2px ring on every interactive element, on every surface. */
:focus-visible {
  outline: 2px solid var(--uh-focus);
  outline-offset: 2px;
}

/* Bootstrap's own focus glow (nav links, close buttons...) in the theme's colour, and the parts
   that draw a blue glow or nothing get the same 2px ring as everything else. */
:root {
  --bs-focus-ring-color: rgb(var(--uh-primary-rgb) / 0.25);
}

.nav-link:focus-visible,
.btn-close:focus-visible,
.page-link:focus-visible,
.dropdown-item:focus-visible {
  outline: 2px solid var(--uh-focus);
  outline-offset: 2px;
  box-shadow: none;
}

.page-link:focus-visible,
.dropdown-item:focus-visible {
  outline-offset: -2px;
}

/* Selected text: the sea tint, opaque so it still shows on hovered (primary-tint) rows. */
::selection {
  background-color: var(--uh-selection);
  color: var(--uh-selection-text);
}

/* Scrollbars, on every scroller: a slim pill thumb on a clear track. The page is
   `color-scheme: only light`, so without this dark mode kept the browser's light bar.
   Chromium and Safari draw the ::-webkit-scrollbar parts; Firefox takes scrollbar-color.
   Chromium 121+ drops the ::-webkit parts once scrollbar-color is set, hence the @supports. */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background-color: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--uh-scroll-thumb);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: var(--uh-radius-pill);
}

::-webkit-scrollbar-thumb:hover,
::-webkit-scrollbar-thumb:active {
  background-color: var(--uh-scroll-thumb-hover);
}

@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-color: var(--uh-scroll-thumb) transparent;
    scrollbar-width: thin;
  }
}

/* Numbers line up in tables. */
.table {
  font-variant-numeric: tabular-nums;
}

/* Keyboard keys (design-system uh-kbd): a small cap on the surface, a heavier bottom edge.
   Bootstrap's kbd is a dark chip; this replaces it wherever the class is set. */
.uh-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  padding: 1px 6px;
  font: 600 11px/1.4 var(--font-numeric);
  color: var(--uh-muted);
  background: var(--uh-kbd-bg);
  border: 1px solid var(--uh-kbd-border);
  border-bottom-width: 2px;
  border-radius: 5px;
  box-shadow: none;
}

/* Reduced motion: transitions and animations collapse, spinners slow down instead of stopping. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 1ms !important; /* over every component's and vendor's transitions */
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }

  .spinner-border,
  .spinner-grow,
  .uh-spinner {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}

.page-content img,
.page-content video,
.page-content canvas,
.page-content svg {
  max-width: 100%;
}

html.dark-theme body {
  --bs-body-color: var(--uh-text); /* buttons and form controls read it */
  background-color: var(--uh-bg);
  color: var(--uh-text);
}

html.dark-theme h1,
html.dark-theme h2,
html.dark-theme h3,
html.dark-theme h4,
html.dark-theme h5,
html.dark-theme h6,
html.dark-theme .h1,
html.dark-theme .h2,
html.dark-theme .h3,
html.dark-theme .h4,
html.dark-theme .h5,
html.dark-theme .h6 {
  color: var(--uh-heading);
}

/* A box that sets its own text colour (text-bg-*, text-white, text-light) keeps it for its
   headings too: the two rules above made them --uh-heading, dark on a coloured header.
   :root outranks html.dark-theme h1. */
:root :is([class*="text-bg-"], .text-white, .text-light) :is(h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6) {
  color: inherit;
}

/* Tables never wrap a cell (the theme's rule, kept on purpose): a long cell scrolls the table
   sideways. A column that should wrap says so in its page CSS (white-space: normal). */
.table-responsive {
  white-space: nowrap;
}

/* Buttons with an icon (icon() prints <i class="bx">): one gap between icon and text instead of
   the theme's `.btn i { margin-left: 7px }`, which pushed the icon of an icon-only button
   (row_actions) off-centre and put the space on the wrong side of an icon after the text.
   The spacing used to vary (7px, a space, or a me-1 / me-2 on the icon); the gap replaces all
   three, so the icon's margin is reset over Bootstrap's !important utilities. The theme's
   negative block margins go too (in a flex box they cancel the icon's height); the min-height
   is one line of button text, so icon-only buttons stay as tall as the others. */
.btn:has(> .bx) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: calc(var(--bs-btn-font-size) * var(--bs-btn-line-height) + 2 * var(--bs-btn-padding-y) + 2 * var(--bs-btn-border-width));
}

.btn > .bx {
  margin: 0 !important; /* over Bootstrap's me-* / ms-* on the icon */
}

html.dark-theme .text-dark,
html.dark-theme .text-body {
  color: var(--uh-text) !important;
}

/* Muted text: Bootstrap's grey is under 4.5:1 on the sand page and the dark card. */
.text-muted,
.text-secondary {
  color: var(--uh-muted) !important; /* over Bootstrap's !important utilities */
}

/* Coloured text: the tokens' text strengths, which read on the card in both themes
   (theme/bootstrap-extended.css fixes the theme's bright colours). */
.text-primary { color: var(--uh-primary-emphasis) !important; } /* over the theme's and Bootstrap's !important utilities */
.text-success { color: var(--uh-success-emphasis) !important; }
.text-danger { color: var(--uh-danger-text) !important; }
.text-warning { color: var(--uh-warning-emphasis) !important; }
.text-info { color: var(--uh-info-emphasis) !important; }

/* Sunken boxes (bg-body-tertiary: a logo placeholder, a code sample) and a coloured card edge. */
.bg-body-tertiary {
  background-color: var(--uh-surface) !important; /* over Bootstrap's !important utility */
}

.border-success {
  border-color: var(--uh-success) !important; /* over Bootstrap's !important utility */
}

html.dark-theme .bg-white,
html.dark-theme .bg-light {
  background-color: var(--uh-surface) !important;
  color: var(--uh-text) !important;
}

/* Surfaces, in both themes: content on --uh-card with a hairline, the page on --uh-bg. */
.card,
.modal-content,
.dropdown-menu,
.list-group-item,
.offcanvas,
.toast {
  background-color: var(--uh-card);
  color: var(--uh-text);
  border-color: var(--uh-border);
}

/* Cards: a hairline, the 10px radius and a whisper of shadow (the theme's grey border and shadow). */
.card {
  --bs-card-border-color: var(--uh-border);
  --bs-card-border-radius: var(--uh-radius-md);
  --bs-card-inner-border-radius: calc(var(--uh-radius-md) - 1px);
  --bs-card-cap-bg: transparent;
  border: 1px solid var(--uh-border);
  box-shadow: var(--uh-shadow-card);
}

.card-footer {
  background-color: var(--uh-surface);
}

/* Modals: the 16px radius and the raised shadow; header and footer on hairlines. */
.modal {
  --bs-modal-bg: var(--uh-card);
  --bs-modal-color: var(--uh-text);
  --bs-modal-border-color: var(--uh-border);
  --bs-modal-border-radius: var(--uh-radius-lg);
  --bs-modal-inner-border-radius: calc(var(--uh-radius-lg) - 1px);
  --bs-modal-box-shadow: var(--uh-shadow-raised);
  --bs-modal-header-border-color: var(--uh-border);
  --bs-modal-footer-border-color: var(--uh-border);
}

.modal-content {
  box-shadow: var(--uh-shadow-raised);
}

/* Backdrop: the design's overlay (navy-tinted in light, black in dark), carrying its own alpha. */
.modal-backdrop {
  --bs-backdrop-bg: var(--uh-overlay);
  --bs-backdrop-opacity: 1;
}

/* Menus: card ground, raised shadow, tinted hover (the theme's white hover vanished in dark). */
.dropdown-menu {
  --bs-dropdown-bg: var(--uh-card);
  --bs-dropdown-color: var(--uh-text);
  --bs-dropdown-border-color: var(--uh-border);
  --bs-dropdown-link-color: var(--uh-text);
  --bs-dropdown-link-hover-color: var(--uh-heading);
  --bs-dropdown-link-hover-bg: var(--uh-primary-tint);
  --bs-dropdown-link-active-color: var(--uh-primary-contrast);
  --bs-dropdown-link-active-bg: var(--uh-primary);
  --bs-dropdown-divider-bg: var(--uh-border);
  border: 1px solid var(--uh-border);
  border-radius: var(--uh-radius-md);
  box-shadow: var(--uh-shadow-raised);
}

.breadcrumb {
  --bs-breadcrumb-item-active-color: var(--uh-muted);
}

/* Tables: card ground, hairlines, a sunken head, hovered rows in --uh-row-hover. */
.table {
  --bs-table-bg: var(--uh-card);
  --bs-table-color: var(--uh-text);
  --bs-table-border-color: var(--uh-border);
  --bs-table-hover-bg: var(--uh-row-hover);
  /* Striped, hovered and active rows take these, not --bs-table-color (Bootstrap: near-black). */
  --bs-table-striped-color: var(--uh-text);
  --bs-table-hover-color: var(--uh-text);
  --bs-table-active-color: var(--uh-text);
  color: var(--uh-text);
  border-color: var(--uh-border);
  font-size: 14px;
}

.table > thead {
  --bs-table-bg: var(--uh-surface);
  --bs-table-color: var(--uh-heading);
}

/* Dark: the striped rows sink below the card (a white wash read as a light band, 2026-10-12). */
html.dark-theme .table {
  --bs-table-striped-bg: rgb(var(--uh-black-rgb) / 0.2);
}

/* Form controls: card ground, a 3:1 control border, the focus ring on the border. */
.form-control,
.form-select,
textarea {
  background-color: var(--uh-input);
  color: var(--uh-text);
  border-color: var(--uh-control-border);
  border-radius: var(--uh-radius-sm);
}

.input-group-text {
  background-color: var(--uh-surface);
  color: var(--uh-muted);
  border-color: var(--uh-control-border);
}

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
  background-color: var(--uh-input-disabled);
  color: var(--uh-muted);
}

/* Over the theme's purple focus ring (bootstrap-extended.css). */
.form-control:focus,
.form-select:focus {
  background-color: var(--uh-input);
  color: var(--uh-text);
  border-color: var(--uh-focus);
  outline: 2px solid var(--uh-focus);
  outline-offset: 0;
  box-shadow: none;
}

.form-check-input:focus {
  border-color: var(--uh-focus);
  background-color: var(--uh-input);
  box-shadow: none;
  outline: 2px solid var(--uh-focus);
  outline-offset: 2px;
}

.form-check-input:checked {
  background-color: var(--uh-primary);
  border-color: var(--uh-primary);
}

::placeholder {
  color: var(--uh-placeholder) !important; /* over Bootstrap's .form-control::placeholder */
  opacity: 1 !important;
}

/* The border above outranks Bootstrap's .is-invalid, which hid the red border. */
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--uh-danger-text);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
  outline-color: var(--uh-danger-text);
}

/* Validation messages and invalid / valid checkbox labels. */
:root {
  --bs-form-invalid-color: var(--uh-danger-text);
  --bs-form-invalid-border-color: var(--uh-danger-text);
  --bs-form-valid-color: var(--uh-success-emphasis);
  --bs-form-valid-border-color: var(--uh-success);
}

/* A field marked valid: the success border, over the control border above (as .is-invalid). */
.form-control.is-valid,
.form-select.is-valid {
  border-color: var(--uh-success);
}

.form-control.is-valid:focus,
.form-select.is-valid:focus {
  outline-color: var(--uh-success);
}

/* Buttons. Every view's raw `btn btn-*` takes the design-system look here, in one place.
   theme/bootstrap-extended.css hard-codes colours per variant and state (so Bootstrap's
   --bs-btn-* variables don't reach them); each variant sets its colours as --uh-btn-*
   and the two rules after it paint them, after the theme. */
.btn {
  --bs-btn-font-family: var(--font-body);
  --bs-btn-font-size: 0.875rem;
  --bs-btn-font-weight: 700;
  --bs-btn-padding-x: 1rem;
  --bs-btn-border-radius: var(--uh-radius-sm);
  --bs-btn-focus-box-shadow: none;
  transition:
    background-color var(--uh-duration-fast) var(--uh-ease-standard),
    border-color var(--uh-duration-fast) var(--uh-ease-standard),
    color var(--uh-duration-fast) var(--uh-ease-standard),
    transform var(--uh-duration-fast) var(--uh-ease-standard),
    filter var(--uh-duration-fast) var(--uh-ease-standard);
}

.btn-sm {
  --bs-btn-font-size: 0.8125rem;
  --bs-btn-padding-x: 0.625rem;
  --bs-btn-border-radius: var(--uh-radius-sm);
}

.btn-lg {
  --bs-btn-border-radius: var(--uh-radius-md);
}

/* Press: 98% while held. */
.btn:active:not(:disabled):not(.disabled) {
  transform: scale(0.98);
  transition-duration: 60ms;
}

.btn:focus-visible {
  outline: 2px solid var(--uh-focus);
  outline-offset: 2px;
}

/* Primary: the one loud action. Hover darkens it, as Bootstrap (#0b5ed7 in both themes). */
.btn-primary {
  --uh-btn-bg: var(--uh-primary);
  --uh-btn-fg: var(--uh-primary-contrast);
  --uh-btn-border: var(--uh-primary);
  --uh-btn-hover-bg: var(--uh-primary-hover);
  --uh-btn-hover-fg: var(--uh-primary-contrast);
  --uh-btn-hover-border: var(--uh-primary-hover);
}

/* Secondary: card ground with the control border (grey, light and white buttons). */
.btn-secondary,
.btn-outline-secondary,
.btn-light,
.btn-white {
  --uh-btn-bg: var(--uh-card);
  --uh-btn-fg: var(--uh-heading);
  --uh-btn-border: var(--uh-control-border);
  --uh-btn-hover-bg: var(--uh-surface);
  --uh-btn-hover-fg: var(--uh-heading);
  --uh-btn-hover-border: var(--uh-muted);
}

/* Filled status buttons: hover only shades the fill. */
.btn-success { --uh-btn-bg: var(--uh-success); }
.btn-danger { --uh-btn-bg: var(--uh-danger); }
.btn-warning { --uh-btn-bg: var(--uh-warning); --uh-btn-on: var(--uh-warning-contrast); }
.btn-info { --uh-btn-bg: var(--uh-info); --uh-btn-on: var(--uh-info-contrast); }

.btn-success,
.btn-danger,
.btn-warning,
.btn-info {
  --uh-btn-fg: var(--uh-btn-on, var(--uh-primary-contrast)); /* black on yellow and cyan, as Bootstrap */
  --uh-btn-border: var(--uh-btn-bg);
  --uh-btn-hover-bg: var(--uh-btn-bg);
  --uh-btn-hover-fg: var(--uh-btn-fg);
  --uh-btn-hover-border: var(--uh-btn-bg);
  --uh-btn-hover-filter: brightness(0.92);
}

html.dark-theme :is(.btn-success, .btn-danger, .btn-warning, .btn-info) {
  --uh-btn-hover-filter: brightness(1.08);
}

/* Outline and soft buttons: the colour's tint as the ground and the colour as text, so the
   button reads as a button at rest; hover fills with the colour itself.
   Outline keeps a border in the colour; soft (row_actions) has a faint one, which keeps it
   visible on a hovered row (the same tint as btn-soft-primary). */
:is(.btn-outline-primary, .btn-soft-primary) {
  --uh-btn-bg: var(--uh-primary-tint);
  --uh-btn-fg: var(--uh-primary-emphasis);
  --uh-btn-solid: var(--uh-primary);
}

:is(.btn-outline-success, .btn-soft-success) {
  --uh-btn-bg: var(--uh-success-tint);
  --uh-btn-fg: var(--uh-success-emphasis);
  --uh-btn-solid: var(--uh-success);
}

:is(.btn-outline-danger, .btn-soft-danger) {
  --uh-btn-bg: var(--uh-danger-tint);
  --uh-btn-fg: var(--uh-danger-emphasis);
  --uh-btn-solid: var(--uh-danger);
}

:is(.btn-outline-warning, .btn-soft-warning) {
  --uh-btn-bg: var(--uh-warning-tint);
  --uh-btn-fg: var(--uh-warning-emphasis);
  --uh-btn-solid: var(--uh-warning);
  --uh-btn-on: var(--uh-warning-contrast);
}

/* Info hovers to Bootstrap's cyan-700 with a white icon (the table's eye button): on the bright
   cyan the icon went from dark teal to black and seemed not to change. */
:is(.btn-outline-info, .btn-soft-info) {
  --uh-btn-bg: var(--uh-info-tint);
  --uh-btn-fg: var(--uh-info-emphasis);
  --uh-btn-solid: var(--uh-info-strong);
}

.btn-outline-primary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-warning,
.btn-outline-info,
.btn-soft-primary,
.btn-soft-success,
.btn-soft-danger,
.btn-soft-warning,
.btn-soft-info {
  --uh-btn-border: var(--uh-btn-solid);
  --uh-btn-hover-bg: var(--uh-btn-solid);
  --uh-btn-hover-fg: var(--uh-btn-on, var(--uh-primary-contrast));
  --uh-btn-hover-border: var(--uh-btn-solid);
}

.btn-soft-primary,
.btn-soft-success,
.btn-soft-danger,
.btn-soft-warning,
.btn-soft-info {
  --uh-btn-border: color-mix(in srgb, var(--uh-btn-solid) 30%, transparent);
}

.btn:is(.btn-primary, .btn-secondary, .btn-outline-secondary, .btn-light, .btn-white, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-outline-primary, .btn-outline-success, .btn-outline-danger, .btn-outline-warning, .btn-outline-info, .btn-soft-primary, .btn-soft-success, .btn-soft-danger, .btn-soft-warning, .btn-soft-info),
.btn:is(.btn-primary, .btn-secondary, .btn-outline-secondary, .btn-light, .btn-white, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-outline-primary, .btn-outline-success, .btn-outline-danger, .btn-outline-warning, .btn-outline-info, .btn-soft-primary, .btn-soft-success, .btn-soft-danger, .btn-soft-warning, .btn-soft-info):focus,
.btn:is(.btn-primary, .btn-secondary, .btn-outline-secondary, .btn-light, .btn-white, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-outline-primary, .btn-outline-success, .btn-outline-danger, .btn-outline-warning, .btn-outline-info, .btn-soft-primary, .btn-soft-success, .btn-soft-danger, .btn-soft-warning, .btn-soft-info):disabled,
.btn:is(.btn-primary, .btn-secondary, .btn-outline-secondary, .btn-light, .btn-white, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-outline-primary, .btn-outline-success, .btn-outline-danger, .btn-outline-warning, .btn-outline-info, .btn-soft-primary, .btn-soft-success, .btn-soft-danger, .btn-soft-warning, .btn-soft-info).disabled {
  color: var(--uh-btn-fg);
  background-color: var(--uh-btn-bg);
  border-color: var(--uh-btn-border);
  box-shadow: none;
}

.btn:is(.btn-primary, .btn-secondary, .btn-outline-secondary, .btn-light, .btn-white, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-outline-primary, .btn-outline-success, .btn-outline-danger, .btn-outline-warning, .btn-outline-info, .btn-soft-primary, .btn-soft-success, .btn-soft-danger, .btn-soft-warning, .btn-soft-info):is(:hover, :active, .active):not(:disabled):not(.disabled),
.show > .btn:is(.btn-primary, .btn-secondary, .btn-outline-secondary, .btn-light, .btn-white, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-outline-primary, .btn-outline-success, .btn-outline-danger, .btn-outline-warning, .btn-outline-info, .btn-soft-primary, .btn-soft-success, .btn-soft-danger, .btn-soft-warning, .btn-soft-info).dropdown-toggle,
.btn-check:checked + .btn:is(.btn-primary, .btn-secondary, .btn-outline-secondary, .btn-light, .btn-white, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-outline-primary, .btn-outline-success, .btn-outline-danger, .btn-outline-warning, .btn-outline-info, .btn-soft-primary, .btn-soft-success, .btn-soft-danger, .btn-soft-warning, .btn-soft-info) {
  color: var(--uh-btn-hover-fg);
  background-color: var(--uh-btn-hover-bg);
  border-color: var(--uh-btn-hover-border);
  filter: var(--uh-btn-hover-filter, none);
  box-shadow: none;
}

/* Ghost: no ground at rest, the primary tint on hover; for routine and tertiary actions
   (row_actions view / edit). Ghost-danger is the table's trash icon: red, never filled at rest. */
.btn-ghost { --uh-btn-fg: var(--uh-link); --uh-btn-hover-bg: var(--uh-primary-tint); }
.btn-ghost-danger { --uh-btn-fg: var(--uh-danger-text); --uh-btn-hover-bg: var(--uh-danger-tint); }

.btn:is(.btn-ghost, .btn-ghost-danger),
.btn:is(.btn-ghost, .btn-ghost-danger):focus,
.btn:is(.btn-ghost, .btn-ghost-danger):disabled {
  color: var(--uh-btn-fg);
  background-color: transparent;
  border-color: transparent;
}

.btn:is(.btn-ghost, .btn-ghost-danger):is(:hover, :active, .active):not(:disabled):not(.disabled) {
  color: var(--uh-btn-fg);
  background-color: var(--uh-btn-hover-bg);
  border-color: transparent;
}

/* Icon-only button: a 34px square (also when small). */
.btn.btn-icon {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
}

/* Alerts: the variant's tint, its emphasis text, no border, no shadow. Applies to the alert
   component and to the alerts page scripts build (alert alert-{variant}). */
.alert {
  --bs-alert-border-color: transparent;
  --bs-alert-border-radius: var(--uh-radius-md);
  box-shadow: none;
}

.alert-primary { --bs-alert-bg: var(--uh-primary-tint); --bs-alert-color: var(--uh-primary-emphasis); --bs-alert-link-color: var(--uh-primary-emphasis); }
.alert-secondary { --bs-alert-bg: var(--uh-neutral-tint); --bs-alert-color: var(--uh-text); --bs-alert-link-color: var(--uh-heading); }
.alert-info { --bs-alert-bg: var(--uh-info-tint); --bs-alert-color: var(--uh-info-emphasis); --bs-alert-link-color: var(--uh-info-emphasis); }
.alert-success { --bs-alert-bg: var(--uh-success-tint); --bs-alert-color: var(--uh-success-emphasis); --bs-alert-link-color: var(--uh-success-emphasis); }
.alert-warning { --bs-alert-bg: var(--uh-warning-tint); --bs-alert-color: var(--uh-warning-emphasis); --bs-alert-link-color: var(--uh-warning-emphasis); }
.alert-danger { --bs-alert-bg: var(--uh-danger-tint); --bs-alert-color: var(--uh-danger-emphasis); --bs-alert-link-color: var(--uh-danger-emphasis); }

html.dark-theme .alert .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Badges that pages write by hand (course codes, counts: badge text-bg-* or bg-*): the
   status_badge tints instead of Bootstrap's solid fills. */
.badge:is(.text-bg-primary, .text-bg-secondary, .text-bg-success, .text-bg-warning, .text-bg-danger, .text-bg-info, .bg-primary, .bg-secondary, .bg-success, .bg-warning, .bg-danger, .bg-info) {
  font-weight: 700;
}

.badge:is(.text-bg-primary, .bg-primary) { color: var(--uh-primary-emphasis) !important; background-color: var(--uh-primary-tint) !important; } /* over Bootstrap's !important text-bg-* */
.badge:is(.text-bg-secondary, .bg-secondary) { color: var(--uh-muted) !important; background-color: var(--uh-neutral-tint) !important; }
.badge:is(.text-bg-success, .bg-success) { color: var(--uh-success-emphasis) !important; background-color: var(--uh-success-tint) !important; }
.badge:is(.text-bg-warning, .bg-warning) { color: var(--uh-warning-emphasis) !important; background-color: var(--uh-warning-tint) !important; }
.badge:is(.text-bg-danger, .bg-danger) { color: var(--uh-danger-emphasis) !important; background-color: var(--uh-danger-tint) !important; }
.badge:is(.text-bg-info, .bg-info) { color: var(--uh-info-emphasis) !important; background-color: var(--uh-info-tint) !important; }
.badge.text-bg-light { color: var(--uh-text) !important; background-color: var(--uh-surface) !important; }

/* Highlighted rows (row_class 'table-warning', 'table-danger'...): Bootstrap's pale fills
   with black text glare on the dark page (pink, yellow, blue bands); the dark tint of the
   same colour keeps the highlight. Striped and hovered rows stay on that tint. */
html.dark-theme .table-warning { --uh-row-tint: var(--uh-warning-tint); }
html.dark-theme .table-danger { --uh-row-tint: var(--uh-danger-tint); }
html.dark-theme .table-success { --uh-row-tint: var(--uh-success-tint); }
html.dark-theme .table-primary { --uh-row-tint: var(--uh-primary-tint); }
html.dark-theme .table-info { --uh-row-tint: var(--uh-info-tint); }

html.dark-theme :is(.table-warning, .table-danger, .table-success, .table-primary, .table-info) {
  --bs-table-color: var(--uh-text);
  --bs-table-bg: var(--uh-row-tint);
  --bs-table-border-color: var(--uh-border);
  --bs-table-striped-bg: var(--uh-row-tint);
  --bs-table-striped-color: var(--uh-text);
  --bs-table-hover-bg: var(--uh-row-tint);
  --bs-table-hover-color: var(--uh-text);
  --bs-table-active-bg: var(--uh-row-tint);
  --bs-table-active-color: var(--uh-text);
}

/* Total rows (row_class 'table-secondary'): the same, in the surface grey. */
html.dark-theme .table-secondary {
  --bs-table-color: var(--uh-heading);
  --bs-table-bg: var(--uh-surface);
  --bs-table-border-color: var(--uh-border);
  --bs-table-striped-bg: var(--uh-surface);
  --bs-table-striped-color: var(--uh-heading);
  --bs-table-hover-bg: var(--uh-surface);
  --bs-table-hover-color: var(--uh-heading);
  --bs-table-active-bg: var(--uh-surface);
  --bs-table-active-color: var(--uh-heading);
}

/* Pager: card ground, the current page filled in primary. The theme hard-codes its colours
   on .page-link (bootstrap-extended.css), so the properties are set here, after it. */
.page-link,
.page-link:hover,
.page-link:focus {
  color: var(--uh-text);
  background-color: var(--uh-card);
  border-color: var(--uh-border);
  box-shadow: none;
}

.page-link:hover {
  background-color: var(--uh-surface);
}

.active > .page-link,
.page-link.active,
.page-link.active:hover {
  color: var(--uh-primary-contrast);
  background-color: var(--uh-primary);
  border-color: var(--uh-primary);
}

.page-item.disabled .page-link {
  color: var(--uh-muted);
  background-color: var(--uh-surface);
  border-color: var(--uh-border);
}

hr,
.border,
.border-top,
.border-bottom,
.border-start,
.border-end {
  border-color: var(--uh-border) !important; /* over Bootstrap's !important border utilities */
}

/* A coloured border utility (library book_card's border-success) keeps its colour. */
.border-primary { border-color: var(--uh-primary) !important; }
.border-success { border-color: var(--uh-success) !important; }
.border-danger { border-color: var(--uh-danger) !important; }
.border-warning { border-color: var(--uh-warning) !important; }
.border-info { border-color: var(--uh-info) !important; }

/* Badges: pills. */
.badge {
  border-radius: var(--uh-radius-pill);
}

/* File inputs: Bootstrap's light button, and its hover rule (light background) outranks a
   plain rule, so hover needs its own. */
.form-control::file-selector-button {
  background-color: var(--uh-surface);
  color: var(--uh-text);
  border-color: var(--uh-control-border);
}

.form-control:hover:not(:disabled):not([readonly])::file-selector-button {
  background-color: var(--uh-border);
  color: var(--uh-heading);
}

/* Boxicons' back arrow points left, as in LTR. In this RTL app "back" is to the right
   (used by every "العودة" button, migrated or not). */
[dir="rtl"] .bx-arrow-back {
  transform: scaleX(-1);
}

/* Bootstrap's grey help text is unreadable on the dark card (also help text outside a form field). */
.form-text {
  color: var(--uh-muted);
}
