/*
 * mvui: the Workspace+ (rtviewer-3) look on Bootstrap 5.3 (docs/SPEC.md §9.2, §9.3).
 * Colours come only from tokens.css (var(--mv-*)); this file restyles Bootstrap's classes, so existing
 * markup picks the look up, and adds mvui's own layout and components. Mobile first.
 */

/* ---------------------------------------------------------------- base and type */

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--mv-scrollbar-thumb) transparent;
}

:where(*) {
  scrollbar-width: thin;
}

/* Sticky offsets: mvui.js keeps --mv-header-h (the header) and --mv-subheader-h (the part of the
   sub-header that sticks, 0px when none) current. In-page sticky navs use top: var(--mv-sticky-top). */
:root {
  --mv-subheader-h: 0px;
  --mv-sticky-top: calc(var(--mv-header-h) + var(--mv-subheader-h));
  scroll-padding-top: calc(var(--mv-sticky-top) + 8px);
}

body {
  font-size: 0.875rem;
  line-height: 1.5;
}

.mv-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--mv-ground);
  color: var(--mv-text);
}

::selection {
  background-color: var(--mv-accent);
  color: var(--mv-on-primary);
}

h1, .h1, .mv-page-title { font-size: 19px; font-weight: 500; line-height: 1.3; }
h2, .h2 { font-size: 16px; font-weight: 500; line-height: 1.35; }
h3, .h3 { font-size: 14px; font-weight: 600; line-height: 1.4; }
h4, .h4 { font-size: 14px; font-weight: 500; line-height: 1.4; }
h5, .h5 { font-size: 13px; font-weight: 500; line-height: 1.4; }
h6, .h6 { font-size: 12px; font-weight: 500; line-height: 1.4; }
.lead { font-size: 15px; font-weight: 400; }

.text-mono, code, kbd, samp, pre, .mv-num {
  font-family: var(--mv-font-mono);
  font-variant-numeric: tabular-nums;
}
code { font-size: 0.9em; }
kbd {
  padding: 1px 4px;
  font-size: 11px;
  color: var(--mv-text);
  background-color: var(--mv-raised);
  border: 1px solid var(--mv-border);
  border-radius: var(--mv-radius);
}
pre {
  padding: 8px 12px;
  font-size: 12px;
  background-color: var(--mv-ground);
  border: 1px solid var(--mv-border);
  border-radius: var(--mv-radius);
}

a { text-underline-offset: 2px; }
hr { color: var(--mv-border); border-color: var(--mv-border); opacity: 1; }
.text-primary { color: var(--mv-accent) !important; }
.link-primary { color: var(--mv-accent) !important; text-decoration-color: var(--mv-accent) !important; }
.text-muted, .text-body-secondary { color: var(--mv-text-secondary) !important; }

/* Status text in the -text-emphasis colours (>= 4.5:1 on the surface and the ground in both themes);
   Bootstrap's plain tones are not (light info #0288d1 is 3.9:1 on white). Link hovers likewise, which
   Bootstrap gives raw colours of its own palette. */
.text-success { color: var(--bs-success-text-emphasis) !important; }
.text-warning { color: var(--bs-warning-text-emphasis) !important; }
.text-danger { color: var(--bs-danger-text-emphasis) !important; }
.text-info { color: var(--bs-info-text-emphasis) !important; }
.link-success, .link-success:hover, .link-success:focus { color: var(--bs-success-text-emphasis) !important; text-decoration-color: var(--bs-success-text-emphasis) !important; }
.link-warning, .link-warning:hover, .link-warning:focus { color: var(--bs-warning-text-emphasis) !important; text-decoration-color: var(--bs-warning-text-emphasis) !important; }
.link-danger, .link-danger:hover, .link-danger:focus { color: var(--bs-danger-text-emphasis) !important; text-decoration-color: var(--bs-danger-text-emphasis) !important; }
.link-info, .link-info:hover, .link-info:focus { color: var(--bs-info-text-emphasis) !important; text-decoration-color: var(--bs-info-text-emphasis) !important; }
.link-primary:hover, .link-primary:focus { color: var(--bs-link-hover-color) !important; text-decoration-color: var(--bs-link-hover-color) !important; }
.link-secondary:hover, .link-secondary:focus { color: var(--mv-text) !important; text-decoration-color: var(--mv-text) !important; }

.mv-icon {
  display: inline-block;
  flex: none;
  vertical-align: -0.125em;
}

.mv-readable { max-width: 72ch; }
.mv-readable-form { max-width: 720px; }

/* ---------------------------------------------------------------- focus */

:focus-visible {
  outline: 2px solid var(--mv-focus);
  outline-offset: 2px;
}

.btn:focus-visible,
.btn-check:focus-visible + .btn,
.nav-link:focus-visible,
.page-link:focus-visible,
.form-check-input:focus-visible,
.form-range:focus-visible,
.btn-close:focus-visible,
.accordion-button:focus-visible,
.list-group-item-action:focus-visible,
.mv-nav__link:focus-visible,
.mv-icon-btn:focus-visible,
.mv-account__button:focus-visible,
.mv-segmented__option:focus-visible,
.mv-kpi--link:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--mv-focus);
  outline-offset: 2px;
  box-shadow: none;
}

.dropdown-item:focus-visible {
  outline: 2px solid var(--mv-focus);
  outline-offset: -2px;
  box-shadow: none;
}

.page-link:focus,
.accordion-button:focus,
.btn-close:focus,
.form-range:focus { box-shadow: none; }

#content:focus { outline: none; }

/* Bootstrap focuses an opening drawer or dialog panel itself (tabindex -1): no outline along its edge.
   Focusable elements inside keep theirs. */
.offcanvas:focus,
.offcanvas:focus-visible,
.modal:focus,
.modal:focus-visible { outline: 0; }

.mv-skip-link:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2100;
  padding: 8px 12px;
  color: var(--mv-on-primary);
  background-color: var(--mv-primary-fill);
  border-radius: var(--mv-radius);
  text-decoration: none;
}

/* ---------------------------------------------------------------- navigation progress (mvui.js) */

.mv-nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000;
  width: 0;
  height: 2px;
  background-color: var(--mv-accent);
  opacity: 0;
  pointer-events: none;
}

.mv-nav-progress.is-active {
  width: 85%;
  opacity: 1;
  transition: width 8s cubic-bezier(0.1, 0.7, 0.2, 1), opacity 0.2s;
}

/* ---------------------------------------------------------------- header */

.mv-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  padding-top: env(safe-area-inset-top);
  color: var(--mv-text);
  background-color: var(--mv-surface);
  border: 0;
  box-shadow: none;
}

.mv-header__inner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding-right: max(8px, env(safe-area-inset-right));
  padding-left: max(12px, env(safe-area-inset-left));
}

.mv-header__menu { margin-left: -4px; }

/* A grid, so the brand's minimum width is the logo's: only the app-name column may shrink (to 0, with an
   ellipsis) before the header fit compacts the row. */
.mv-header__brand {
  display: grid;
  flex: 0 1 auto;
  grid-auto-columns: minmax(0, max-content);
  grid-auto-flow: column;
  grid-template-columns: max-content;
  column-gap: 10px;
  align-items: center;
  margin-right: 8px;
  color: var(--mv-text);
  text-decoration: none;
}

.mv-header__brand:hover { color: var(--mv-text); }

.mv-logo {
  display: block;
  flex: none;
  flex-shrink: 0;
  width: auto;
  height: 22px;
}

.mv-logo--on-light,
[data-bs-theme="light"] .mv-logo--on-dark { display: none; }
[data-bs-theme="light"] .mv-logo--on-light { display: block; }

.mv-header__app {
  min-width: 0;
  padding-left: 10px;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  line-height: 22px;
  white-space: nowrap;
  text-overflow: ellipsis;
  border-left: 1px solid var(--mv-border);
}

.mv-header__nav {
  flex: 1 1 auto;
  align-self: stretch;
  align-items: stretch;
  min-width: 0;
}

.mv-header__end {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
}

/* (0.5.0) rtviewer-3's outlined warning chip: weight 400, 11px of padding (its chip's 4px and its label's 7px), the
   border at 70% of the tone, the text in the status text colour */
.mv-env-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  max-width: 40vw;
  padding: 0 11px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--bs-warning-text-emphasis);
  border: 1px solid color-mix(in srgb, var(--mv-warning) 70%, transparent);
  border-radius: var(--mv-radius);
}

/* (0.5.0) The signed-in name before the icon buttons and the account menu, as rtviewer-3: 12px in the secondary colour,
   at most 180px with an ellipsis. From md up; the compact header drops it (with the app name) before the nav collapses
   into the drawer, and the collapsed header, with room again, shows it. */
.mv-header__user {
  display: none;
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 400;
  line-height: 20px;
  color: var(--mv-text-secondary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (min-width: 768px) {
  .mv-header__user { display: block; }
}

/* nav: the same markup in the header and in the drawer */

.mv-nav {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mv-nav__item { position: relative; display: flex; }

.mv-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--mv-text-secondary);
  text-decoration: none;
  background: none;
  border: 0;
  border-radius: var(--mv-radius);
  transition: color 150ms, background-color 150ms;
}

.mv-nav__link:hover,
.mv-nav__link:focus-visible,
.mv-nav__link[aria-expanded="true"] { color: var(--mv-text); }

.mv-nav__link[aria-current="page"],
.mv-nav__link.active {
  color: var(--mv-text);
}

.mv-header__nav .mv-nav {
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.mv-header__nav .mv-nav__link { border-radius: 0; }

.mv-header__nav .mv-nav__link::before {
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 2px;
  content: "";
  background-color: transparent;
  border-radius: 1px 1px 0 0;
}

.mv-header__nav .mv-nav__link[aria-current="page"]::before,
.mv-header__nav .mv-nav__link.active::before { background-color: var(--mv-accent); }

/* Header fit (mvui.js): when the header row does not fit, --compact drops the app name and tightens the
   nav links; when it still does not fit, --collapsed hands the nav to the drawer at any width.
   --measuring holds every part at its natural width for the moment mvui.js measures. */
.mv-header--measuring .mv-header__brand,
.mv-header--measuring .mv-header__nav,
.mv-header--measuring .mv-header__end,
.mv-header--measuring .mv-header__app { flex-shrink: 0; }

.mv-header--compact .mv-header__app { display: none; }
.mv-header--compact .mv-header__brand { margin-right: 4px; }
.mv-header--compact .mv-header__nav .mv-nav { gap: 0; }
.mv-header--compact .mv-header__nav .mv-nav__link { padding: 0 7px; }
.mv-header--compact .mv-header__nav .mv-nav__link::before { right: 7px; left: 7px; }

.mv-header--collapsed .mv-header__nav { display: none !important; }
.mv-header--collapsed .mv-header__menu { display: inline-flex !important; }
.mv-header--collapsed .mv-header__app { display: block; }
.mv-header--compact .mv-header__user { display: none; }
.mv-header--collapsed .mv-header__user { display: block; }

/* Sub-header (block subheader): a box-less slot between the header and <main>, so it takes no space when
   empty and a sticky bar in it sticks to the page rather than to the slot. */
.mv-subheader { display: contents; }

/* A bar that sticks under the header, e.g. a context bar in block subheader. */
.mv-sticky-bar {
  position: sticky;
  top: var(--mv-header-h);
  z-index: 1029;
  color: var(--mv-text);
  background-color: var(--mv-surface);
  border-bottom: 1px solid var(--mv-border);
}

/* Bootstrap's caret as a chevron that turns while its menu is open */
.dropdown-toggle::after {
  width: 6px;
  height: 6px;
  margin-left: 6px;
  vertical-align: 0.2em;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  transition: transform 150ms;
}
.dropdown-toggle[aria-expanded="true"]::after,
.dropup .dropdown-toggle::after { transform: translateY(3px) rotate(-135deg); }
.dropend .dropdown-toggle::after { vertical-align: 0.1em; transform: rotate(-45deg); }
.dropdown-toggle-split::after { margin-left: 0; }

/* ---------------------------------------------------------------- drawer (below NAV_BREAKPOINT) */

.mv-drawer {
  --bs-offcanvas-width: min(320px, 85vw);
  --bs-offcanvas-bg: var(--mv-surface);
  --bs-offcanvas-color: var(--mv-text);
  --bs-offcanvas-border-color: var(--mv-border);
  --bs-offcanvas-padding-x: 8px;
  --bs-offcanvas-padding-y: 8px;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

.mv-drawer .offcanvas-header {
  min-height: 56px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--mv-border);
}

.mv-drawer__title { font-size: 14px; font-weight: 500; }

.mv-drawer .mv-nav { display: flex; flex-direction: column; gap: 2px; }
.mv-drawer .mv-nav__item { flex-direction: column; align-items: stretch; }

.mv-drawer .mv-nav__link {
  justify-content: flex-start;
  width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  text-align: start;
}

.mv-drawer .mv-nav__link:hover { background-color: var(--mv-hover-tint); }
.mv-drawer .mv-nav__link.dropdown-toggle::after { margin-left: auto; }
[dir="rtl"] .mv-drawer .mv-nav__link.dropdown-toggle::after { margin-right: auto; margin-left: 0; }

.mv-drawer .mv-nav__link[aria-current="page"],
.mv-drawer .mv-nav__link.active {
  background-color: var(--mv-selected);
  box-shadow: inset 3px 0 0 var(--mv-accent);
}

.mv-drawer .dropdown-menu {
  position: static !important;
  inset: auto !important;
  float: none;
  width: 100%;
  min-width: 0;
  margin: 2px 0 4px !important;
  padding: 0 0 0 12px;
  background: transparent;
  border: 0;
  box-shadow: none;
  transform: none !important;
}

/* ---------------------------------------------------------------- header controls */

.mv-icon-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--mv-text-secondary);
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: var(--mv-radius);
  transition: background-color 250ms, border-color 250ms, color 250ms;
}

.mv-icon-btn:hover { color: var(--mv-text); background-color: var(--mv-hover-tint); }
.mv-icon-btn[aria-pressed="true"] { color: var(--mv-text); background-color: var(--mv-pressed); }
.mv-icon-btn:disabled { color: var(--mv-text-disabled); background-color: transparent; }

/* (0.5.0) The header's icon buttons as rtviewer-3's: 28px square with an 18px icon, in the text colour (44px on a touch
   screen: the device rules come later). :where() keeps the size at .mv-icon-btn's own weight, so an app's class on a
   header button with a word beside its icon (width: auto) still wins. */
:where(.mv-header) .mv-icon-btn { width: 28px; height: 28px; }
:where(.mv-header) .mv-icon-btn:not(:disabled) { color: var(--mv-text); }
:where(.mv-header) .mv-icon-btn > .mv-icon { width: 18px; height: 18px; }

.mv-account__button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--mv-radius);
}

.mv-account__button:hover,
.mv-account__button[aria-expanded="true"] { background-color: var(--mv-hover-tint); }

.mv-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 14px; /* (0.5.0) rtviewer-3's avatar initial: 14px/400 (was 12px/600) */
  font-weight: 400;
  line-height: 1;
  color: var(--mv-on-primary);
  background-color: var(--mv-primary-fill);
  border-radius: var(--mv-radius);
}

.mv-account__menu {
  width: 260px;
  max-width: calc(100vw - 16px);
}

.mv-account__who {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 6px 8px 4px;
}

.mv-account__name { font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.mv-account__email { font-family: var(--mv-font-mono); font-size: 11px; color: var(--mv-text-secondary); overflow-wrap: anywhere; }
.mv-account__logout { margin: 0; }
/* (0.5.0) rtviewer-3's menus leave 4px between items: here in mvui's own menu (the app switcher and account links). */
.mv-account__menu > .dropdown-item + .dropdown-item { margin-top: 4px; }
.mv-account__logout .dropdown-item { width: 100%; text-align: start; }

.mv-theme-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  font-size: 12px;
}

.mv-theme-switch__label { color: var(--mv-text-secondary); }

/* rtviewer-3's ToggleButtonGroup */
.mv-segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--mv-border);
  border-radius: var(--mv-radius);
}

.mv-segmented__option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.2;
  color: var(--mv-text-secondary);
  background: transparent;
  border: 0;
  border-radius: var(--mv-radius);
  transition: background-color 150ms, color 150ms;
}

.mv-segmented__option:hover { background-color: var(--mv-hover-tint); }
.mv-segmented__option[aria-pressed="true"] { color: var(--mv-text); background-color: var(--mv-selected); }

/* ---------------------------------------------------------------- main and page header */

/* .mv-main's padding as custom properties (set per breakpoint below), so a band can bleed to the page edges
   with .mv-bleed. The left/right values include the safe-area insets. */
:root {
  --mv-main-pad-x: 16px;
  --mv-main-pad-top: 16px;
  --mv-main-pad-bottom: 24px;
}

.mv-main {
  --mv-main-pad-left: max(var(--mv-main-pad-x), env(safe-area-inset-left));
  --mv-main-pad-right: max(var(--mv-main-pad-x), env(safe-area-inset-right));
  flex: 1 0 auto;
  min-width: 0;
  padding: var(--mv-main-pad-top) var(--mv-main-pad-right) max(var(--mv-main-pad-bottom), env(safe-area-inset-bottom)) var(--mv-main-pad-left);
  background-color: var(--mv-ground);
}

/* A band (a toolbar, a full-width table) that reaches the page edges from inside .mv-main. */
.mv-bleed {
  margin-right: calc(-1 * var(--mv-main-pad-right));
  margin-left: calc(-1 * var(--mv-main-pad-left));
}

.mv-main--centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--mv-header-h));
  min-height: calc(100dvh - var(--mv-header-h));
  padding-top: 48px;
  padding-bottom: max(48px, env(safe-area-inset-bottom));
}

.mv-header--minimal { position: static; }

.mv-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.mv-page-heading {
  display: flex;
  flex: 1 1 100%;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mv-page-titlebar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  min-width: 0;
}

.mv-page-title { margin: 0; overflow-wrap: anywhere; }

/* (0.5.0) rtviewer-3's "128 patients": Poppins with normal figures (was Roboto Mono, tabular) */
.mv-page-count {
  font-family: var(--mv-font-sans);
  font-size: 14px;
  font-variant-numeric: normal;
  color: var(--mv-text-secondary);
}

.mv-page-subtitle { margin: 0; font-size: 13px; color: var(--mv-text-secondary); }

.mv-page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.mv-page-actions:empty { display: none; }

.mv-breadcrumbs .breadcrumb { margin-bottom: 8px; }

.mv-messages { margin-bottom: 4px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  --bs-btn-padding-x: 16px;
  --bs-btn-padding-y: 6px;
  --bs-btn-font-size: 14px;
  --bs-btn-font-weight: 500;
  --bs-btn-line-height: 1.2;
  --bs-btn-border-radius: var(--mv-radius);
  --bs-btn-focus-box-shadow: none;
  --bs-btn-disabled-opacity: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-transform: none;
  transition: color 250ms, background-color 250ms, border-color 250ms;
}

.btn-sm, .btn-group-sm > .btn {
  --bs-btn-padding-x: 8px;
  --bs-btn-padding-y: 4px;
  --bs-btn-font-size: 12px;
  --bs-btn-border-radius: var(--mv-radius);
  gap: 4px;
}

.btn-lg, .btn-group-lg > .btn {
  --bs-btn-padding-x: 20px;
  --bs-btn-padding-y: 8px;
  --bs-btn-font-size: 16px;
  --bs-btn-border-radius: var(--mv-radius);
}

.btn-primary {
  --bs-btn-color: var(--mv-on-primary);
  --bs-btn-bg: var(--mv-primary-fill);
  --bs-btn-border-color: var(--mv-primary-fill);
  --bs-btn-hover-color: var(--mv-on-primary);
  --bs-btn-hover-bg: var(--mv-primary-fill-hover);
  --bs-btn-hover-border-color: var(--mv-primary-fill-hover);
  --bs-btn-active-color: var(--mv-on-primary);
  --bs-btn-active-bg: var(--mv-primary-fill-hover);
  --bs-btn-active-border-color: var(--mv-primary-fill-hover);
  --bs-btn-disabled-color: var(--mv-text-disabled);
  --bs-btn-disabled-bg: var(--mv-border);
  --bs-btn-disabled-border-color: transparent;
}

.btn-secondary,
.btn-outline-secondary,
.btn-light,
.btn-outline-light,
.btn-dark,
.btn-outline-dark {
  --bs-btn-color: var(--mv-text-secondary);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: var(--mv-border);
  --bs-btn-hover-color: var(--mv-text-secondary);
  --bs-btn-hover-bg: var(--mv-hover-tint);
  --bs-btn-hover-border-color: var(--mv-accent);
  --bs-btn-active-color: var(--mv-text);
  --bs-btn-active-bg: var(--mv-pressed);
  --bs-btn-active-border-color: var(--mv-accent);
  --bs-btn-disabled-color: var(--mv-text-disabled);
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: var(--mv-border);
}

.btn-outline-primary {
  --bs-btn-color: var(--mv-accent);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: var(--mv-accent);
  --bs-btn-hover-color: var(--mv-accent);
  --bs-btn-hover-bg: var(--mv-hover-tint);
  --bs-btn-hover-border-color: var(--mv-accent);
  --bs-btn-active-color: var(--mv-accent);
  --bs-btn-active-bg: var(--mv-pressed);
  --bs-btn-active-border-color: var(--mv-accent);
  --bs-btn-disabled-color: var(--mv-text-disabled);
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: var(--mv-border);
}

.btn-danger {
  --bs-btn-color: var(--mv-on-primary);
  --bs-btn-bg: var(--mv-danger-fill);
  --bs-btn-border-color: var(--mv-danger-fill);
  --bs-btn-hover-color: var(--mv-on-primary);
  --bs-btn-hover-bg: var(--mv-danger-fill-hover);
  --bs-btn-hover-border-color: var(--mv-danger-fill-hover);
  --bs-btn-active-color: var(--mv-on-primary);
  --bs-btn-active-bg: var(--mv-danger-fill-hover);
  --bs-btn-active-border-color: var(--mv-danger-fill-hover);
  --bs-btn-disabled-color: var(--mv-text-disabled);
  --bs-btn-disabled-bg: var(--mv-border);
  --bs-btn-disabled-border-color: transparent;
}

/* Status buttons are outlined in their tone: white on the dark theme's light status colours fails 4.5:1. (0.5.0) Their
   text stays 55% toward the text colour (--mv-*-text-soft): over their hover and pressed fills the pure dark tones of
   the status text would drop under 4.5:1. */
.btn-success, .btn-outline-success { --mv-btn-tone: var(--mv-success); --mv-btn-tone-text: var(--mv-success-text-soft); }
.btn-warning, .btn-outline-warning { --mv-btn-tone: var(--mv-warning); --mv-btn-tone-text: var(--mv-warning-text-soft); }
.btn-info, .btn-outline-info { --mv-btn-tone: var(--mv-info); --mv-btn-tone-text: var(--mv-info-text-soft); }
.btn-outline-danger { --mv-btn-tone: var(--mv-danger); --mv-btn-tone-text: var(--mv-danger-text-soft); }

.btn-success, .btn-outline-success,
.btn-warning, .btn-outline-warning,
.btn-info, .btn-outline-info,
.btn-outline-danger {
  --bs-btn-color: var(--mv-btn-tone-text);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: var(--mv-btn-tone);
  --bs-btn-hover-color: var(--mv-btn-tone-text);
  --bs-btn-hover-bg: color-mix(in srgb, var(--mv-btn-tone) 10%, transparent);
  --bs-btn-hover-border-color: var(--mv-btn-tone);
  --bs-btn-active-color: var(--mv-btn-tone-text);
  --bs-btn-active-bg: color-mix(in srgb, var(--mv-btn-tone) 16%, transparent);
  --bs-btn-active-border-color: var(--mv-btn-tone);
  --bs-btn-disabled-color: var(--mv-text-disabled);
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: var(--mv-border);
}

/* (0.5.0) MUI's text button, as rtviewer-3's: weight 500, 8px side padding, no underline, an 8% accent tint under the
   pointer (12% pressed). The hover text is the link hover colour, which stays >= 4.5:1 on that tint over every ground
   (the accent itself drops to 4.2:1 over the raised fill in dark). Text links (<a> without .btn) keep their underline. */
.btn-link {
  --bs-btn-color: var(--mv-accent);
  --bs-btn-hover-color: var(--bs-link-hover-color);
  --bs-btn-hover-bg: color-mix(in srgb, var(--mv-accent) 8%, transparent);
  --bs-btn-active-color: var(--bs-link-hover-color);
  --bs-btn-active-bg: color-mix(in srgb, var(--mv-accent) 12%, transparent);
  --bs-btn-disabled-color: var(--mv-text-disabled);
  --bs-btn-font-weight: 500;
  --bs-btn-padding-x: 8px;
  text-decoration: none;
}

.btn .spinner-border { color: inherit; }
.btn[aria-busy="true"] { cursor: progress; }

.btn-close { --bs-btn-close-focus-shadow: none; }

/* ---------------------------------------------------------------- forms */

.form-label {
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--mv-text-secondary);
}

.form-text { margin-top: 4px; font-size: 12px; color: var(--mv-text-secondary); }
.invalid-feedback, .valid-feedback { font-size: 12px; }

.form-control,
.form-select {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--mv-text);
  background-color: var(--mv-ground);
  border-color: var(--mv-border);
  border-radius: var(--mv-radius);
  transition: border-color 250ms, background-color 250ms;
}

.form-select,
[data-bs-theme] .form-select {
  --bs-form-select-bg-img: var(--mv-select-chevron);
  padding-right: 28px;
  background-position: right 6px center;
  background-size: 16px 16px;
}

.form-select[multiple],
.form-select[size]:not([size="1"]) { padding-right: 8px; }

textarea.form-control { min-height: 64px; }

.form-control::placeholder { color: var(--mv-text-secondary); opacity: 0.8; }

.form-control:hover:not(:disabled):not([readonly]):not(:focus),
.form-select:hover:not(:disabled):not(:focus) {
  background-color: color-mix(in srgb, var(--mv-accent) 5%, var(--mv-ground));
  border-color: var(--mv-accent);
}

.form-control:focus,
.form-select:focus {
  color: var(--mv-text);
  background-color: var(--mv-ground);
  border-color: var(--mv-accent);
  outline: 2px solid var(--mv-focus);
  outline-offset: 1px;
  box-shadow: none;
}

.form-control:disabled,
.form-select:disabled {
  color: var(--mv-text-disabled);
  background-color: var(--mv-raised);
  border-color: var(--mv-border);
}

.form-control[readonly] { background-color: var(--mv-raised); }

.form-control.is-invalid, .form-select.is-invalid,
.was-validated .form-control:invalid, .was-validated .form-select:invalid { border-color: var(--mv-danger); }
.form-control.is-invalid:focus, .form-select.is-invalid:focus { border-color: var(--mv-danger); box-shadow: none; }
.form-control.is-valid:focus, .form-select.is-valid:focus { box-shadow: none; }

.form-control-sm, .form-select-sm { min-height: 28px; padding-top: 3px; padding-bottom: 3px; font-size: 12px; }
.form-select-sm { padding-right: 24px; }
.form-control-lg, .form-select-lg { min-height: 40px; font-size: 16px; }

.form-control-color { width: 48px; padding: 4px; }
.form-control-plaintext { font-size: 14px; color: var(--mv-text); }

.input-group-text {
  padding: 5px 8px;
  font-size: 14px;
  color: var(--mv-text-secondary);
  background-color: var(--mv-raised);
  border-color: var(--mv-border);
  border-radius: var(--mv-radius);
}

.form-check { min-height: 20px; }
.form-check-label { font-size: 14px; }

.form-check-input {
  width: 16px;
  height: 16px;
  margin-top: 0.15em;
  background-color: var(--mv-ground);
  border: 1px solid var(--mv-text-secondary);
}

.form-check-input[type="checkbox"] { border-radius: 3px; }

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

.form-check-input[type="checkbox"]:indeterminate {
  background-color: var(--mv-primary-fill);
  border-color: var(--mv-primary-fill);
}

.form-check-input:focus { border-color: var(--mv-accent); box-shadow: none; }
.form-check-input:disabled { opacity: 0.5; }

.form-switch .form-check-input { width: 28px; border-radius: 8px; }

.form-switch .form-check-input:not(:checked),
[data-bs-theme] .form-switch .form-check-input:not(:checked):not(:focus) { --bs-form-switch-bg: var(--mv-switch-knob); }

.form-range::-webkit-slider-thumb { background-color: var(--mv-accent); }
.form-range::-moz-range-thumb { background-color: var(--mv-accent); }
.form-range::-webkit-slider-runnable-track { background-color: var(--mv-border); }
.form-range::-moz-range-track { background-color: var(--mv-border); }
.form-range:focus::-webkit-slider-thumb { box-shadow: none; }
.form-range:focus::-moz-range-thumb { box-shadow: none; }

.form-floating > label { color: var(--mv-text-secondary); }

fieldset > legend.form-label { float: none; width: auto; font-size: 13px; }

/* Side-by-side fields (0.4.0, mvui/forms/field_horizontal.html): the label beside its field from md up, on the first
   line of a 32px control (44px on a touch screen), and above it on a phone. */
.mv-form-row > .col-form-label {
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 13px;
  line-height: 20px;
  color: var(--mv-text-secondary);
}

/* the legend keeps Bootstrap's float: left, which makes it a flex item of the row (a rendered legend would not be) */
fieldset.mv-form-row > legend.col-form-label { margin-bottom: 0; padding-top: 0; }

@media (max-width: 767.98px) {
  .mv-form-row > .col-form-label { padding-top: 0; padding-bottom: 4px; }
}

@media (pointer: coarse) and (min-width: 768px) {
  .mv-form-row > label.col-form-label { padding-top: 12px; padding-bottom: 12px; }
  fieldset.mv-form-row > legend.col-form-label { padding-top: 12px; }
}

/* 0.5.0: body-text labels (horizontal_label_style = "body"): 14px in the text colour, as the label | field rows the apps
   wrote by hand, on the same lines as the caption labels. */
.mv-form-row--body > .col-form-label { font-size: 14px; color: var(--mv-text); }

/* 0.5.0: a lone checkbox whose label is in the label column (horizontal_check_label = "column"): the box on the label's
   first line (32px controls; on a touch screen the 44px .form-check already puts it there). */
.mv-form-row__check { padding-top: 6px; margin-bottom: 0; }

@media (max-width: 767.98px) {
  .mv-form-row__check { padding-top: 0; }
}

@media (pointer: coarse) {
  .mv-form-row__check { padding-top: 0; }
}

/* 0.5.0: a required field's label, in a form with required_css_class (both renderers): weight 500 and a red asterisk,
   rtviewer-3's mark of a field an operation cannot run without. The asterisk is hidden from screen readers: the field's
   own required attribute says it. */
.mv-required { font-weight: 500; }
.mv-required::after {
  content: " *";
  content: " *" / "";
  color: var(--bs-danger-text-emphasis);
}

/* ---------------------------------------------------------------- tables */

.table {
  --bs-table-color: var(--mv-text);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--mv-border);
  --bs-table-striped-color: var(--mv-text);
  --bs-table-striped-bg: color-mix(in srgb, var(--mv-text) 3%, transparent);
  --bs-table-hover-color: var(--mv-text);
  --bs-table-hover-bg: var(--mv-row-hover);
  --bs-table-active-color: var(--mv-text);
  --bs-table-active-bg: var(--mv-selected);
  font-size: 12px;
}

/* Positioned, so absolutely positioned content (a .visually-hidden header) scrolls with the table
   instead of widening the page. */
.table-responsive { position: relative; }

.table > :not(caption) > * > * { padding: 4px 8px; }
.table-sm > :not(caption) > * > * { padding: 4px 8px; } /* (0.5.0) rtviewer-3's densest table (was 2px 6px) */

.table > thead > tr > th,
.table > thead > tr > td {
  height: 36px;
  font-size: 12px;
  font-weight: 400; /* (0.5.0) caption type, as rtviewer-3's PatientListHeadCell (was 500) */
  vertical-align: middle;
  color: var(--mv-text-secondary);
  background-color: var(--mv-table-head);
  border-bottom: 1px solid var(--mv-border);
}

.table > tbody > tr:hover > * {
  --bs-table-color-state: var(--bs-table-hover-color);
  --bs-table-bg-state: var(--bs-table-hover-bg);
}

.table > tbody > tr:last-child > * { border-bottom-width: 0; }

/* IDs, dates and counts stay on one line; the table scrolls instead. */
.table .text-mono, .table .mv-num, .table time { white-space: nowrap; }

.table > tbody > tr.table-active > *,
.table > tbody > tr[aria-selected="true"] > * {
  --bs-table-color-state: var(--mv-text);
  --bs-table-bg-state: var(--mv-selected);
}

.table > tbody > tr.table-active > :first-child,
.table > tbody > tr[aria-selected="true"] > :first-child {
  box-shadow: inset 3px 0 0 var(--mv-accent), inset 0 0 0 9999px var(--mv-selected);
}

.table-group-divider { border-top-color: var(--mv-border); border-top-width: 1px; }

.table caption { font-size: 12px; color: var(--mv-text-secondary); }

/* Status table variants: the tinted status surfaces (emphasis text on the subtle tint, >= 4.5:1 in both
   themes) instead of Bootstrap's pastel defaults, with hover, stripe and active shades of the same tint. (0.5.0) The
   status rows' text is --mv-*-text-soft (0.4.0's emphasis), which holds 4.5:1 on the deeper shades. */
.table-primary { --mv-table-tone-text: var(--bs-primary-text-emphasis); --mv-table-tone-bg: var(--bs-primary-bg-subtle); }
.table-success { --mv-table-tone-text: var(--mv-success-text-soft); --mv-table-tone-bg: var(--bs-success-bg-subtle); }
.table-warning { --mv-table-tone-text: var(--mv-warning-text-soft); --mv-table-tone-bg: var(--bs-warning-bg-subtle); }
.table-danger { --mv-table-tone-text: var(--mv-danger-text-soft); --mv-table-tone-bg: var(--bs-danger-bg-subtle); }
.table-info { --mv-table-tone-text: var(--mv-info-text-soft); --mv-table-tone-bg: var(--bs-info-bg-subtle); }

.table-primary,
.table-success,
.table-warning,
.table-danger,
.table-info {
  --bs-table-color: var(--mv-table-tone-text);
  --bs-table-bg: var(--mv-table-tone-bg);
  --bs-table-border-color: var(--mv-border);
  --bs-table-striped-color: var(--mv-table-tone-text);
  --bs-table-striped-bg: color-mix(in srgb, var(--mv-table-tone-text) 5%, var(--mv-table-tone-bg));
  --bs-table-hover-color: var(--mv-table-tone-text);
  --bs-table-hover-bg: color-mix(in srgb, var(--mv-table-tone-text) 8%, var(--mv-table-tone-bg));
  --bs-table-active-color: var(--mv-table-tone-text);
  --bs-table-active-bg: color-mix(in srgb, var(--mv-table-tone-text) 12%, var(--mv-table-tone-bg));
  color: var(--bs-table-color);
  border-color: var(--bs-table-border-color);
}

/* A link in a tinted status row (0.4.0) takes the row's emphasis colour, underlined so it still reads as a link: the
   accent link colour is under 4.5:1 on the dark theme's tints. A .link-* utility on the link wins (!important). */
.table-primary a:not(.btn),
.table-success a:not(.btn),
.table-warning a:not(.btn),
.table-danger a:not(.btn),
.table-info a:not(.btn) {
  color: inherit;
  text-decoration: underline;
}

/* Light and dark table variants are just the header band in either theme. */
.table-light,
.table-dark,
.table-secondary {
  --bs-table-color: var(--mv-text-secondary);
  --bs-table-bg: var(--mv-table-head);
  --bs-table-border-color: var(--mv-border);
  --bs-table-striped-bg: var(--mv-table-head);
  --bs-table-striped-color: var(--mv-text-secondary);
  --bs-table-active-bg: var(--mv-selected);
  --bs-table-active-color: var(--mv-text);
  --bs-table-hover-bg: var(--mv-row-hover);
  --bs-table-hover-color: var(--mv-text);
  color: var(--bs-table-color);
  border-color: var(--bs-table-border-color);
}

/* ---------------------------------------------------------------- cards */

.card {
  --bs-card-bg: var(--mv-surface);
  --bs-card-color: var(--mv-text);
  --bs-card-border-color: var(--mv-border);
  --bs-card-border-radius: var(--mv-radius);
  --bs-card-inner-border-radius: calc(var(--mv-radius) - 1px);
  --bs-card-cap-bg: transparent;
  --bs-card-cap-color: var(--mv-text);
  --bs-card-cap-padding-y: 10px;
  --bs-card-cap-padding-x: 16px;
  --bs-card-spacer-y: 16px;
  --bs-card-spacer-x: 16px;
  --bs-card-title-color: var(--mv-text);
  --bs-card-subtitle-color: var(--mv-text-secondary);
  --bs-card-box-shadow: none;
  box-shadow: none;
}

.card-header { font-size: 14px; font-weight: 500; }
.card-footer { background-color: var(--mv-raised); }
.card-title { font-size: 14px; font-weight: 500; }
.card-subtitle { font-size: 12px; }
.card > .table, .card > .table-responsive > .table, .card-body > .table:last-child { margin-bottom: 0; }

.mv-card-header { display: flex; flex-direction: column; gap: 2px; }
.mv-card-header__titlebar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mv-card-header__icon { color: var(--mv-accent); }
.mv-card-title { margin: 0; font-size: 14px; font-weight: 500; }
.mv-card-count { font-family: var(--mv-font-mono); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--mv-text-secondary); }
.mv-card-subtitle { margin: 0; font-size: 12px; font-weight: 400; color: var(--mv-text-secondary); }

/* ---------------------------------------------------------------- dropdowns, modals, popovers, tooltips */

/* (0.5.0) Menus float on --mv-float-bg: in dark the surface with MUI's elevation-1 overlay, as rtviewer-3's menus. */
.dropdown-menu {
  --bs-dropdown-bg: var(--mv-float-bg);
  --bs-dropdown-color: var(--mv-text);
  --bs-dropdown-border-color: var(--mv-border);
  --bs-dropdown-border-radius: var(--mv-radius-float);
  --bs-dropdown-inner-border-radius: calc(var(--mv-radius-float) - 1px);
  --bs-dropdown-padding-x: 4px;
  --bs-dropdown-padding-y: 4px;
  --bs-dropdown-spacer: 4px;
  --bs-dropdown-font-size: 12px;
  --bs-dropdown-min-width: 180px;
  --bs-dropdown-box-shadow: var(--mv-shadow-float);
  --bs-dropdown-divider-bg: var(--mv-border);
  --bs-dropdown-divider-margin-y: 4px;
  --bs-dropdown-link-color: var(--mv-text);
  --bs-dropdown-link-hover-color: var(--mv-text);
  --bs-dropdown-link-hover-bg: var(--mv-hover-tint);
  --bs-dropdown-link-active-color: var(--mv-text);
  --bs-dropdown-link-active-bg: var(--mv-selected);
  --bs-dropdown-link-disabled-color: var(--mv-text-disabled);
  --bs-dropdown-item-padding-x: 8px;
  --bs-dropdown-item-padding-y: 4px;
  --bs-dropdown-item-border-radius: var(--mv-radius);
  --bs-dropdown-header-color: var(--mv-text-secondary);
  --bs-dropdown-header-padding-x: 8px;
  --bs-dropdown-header-padding-y: 4px;
  box-shadow: var(--mv-shadow-float);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  font-size: 12px;
  border-radius: var(--mv-radius);
}

.dropdown-header { font-size: 11px; font-weight: 500; }
.mv-menu-label { flex: 1 1 auto; min-width: 0; }
.mv-external { color: var(--mv-text-secondary); }

.modal {
  --bs-modal-bg: var(--mv-surface);
  --bs-modal-color: var(--mv-text);
  --bs-modal-border-color: var(--mv-border);
  --bs-modal-border-radius: var(--mv-radius);
  --bs-modal-inner-border-radius: calc(var(--mv-radius) - 1px);
  --bs-modal-box-shadow: none;
  --bs-modal-padding: 16px;
  --bs-modal-header-padding: 12px 16px;
  --bs-modal-header-border-color: var(--mv-border);
  --bs-modal-footer-border-color: var(--mv-border);
  --bs-modal-footer-gap: 8px;
}

.modal-content { box-shadow: none; }
.modal-title { font-size: 16px; font-weight: 500; }
/* 0.4.0: line breaks in data-mv-confirm (&#10;) or in mvui.confirm()'s message are kept */
.mv-confirm__message { margin: 0; font-size: 14px; white-space: pre-line; }
/* the copy dialog (0.4.0, mvui.copyText()): the text in a read-only field, selected when the dialog opens */
.mv-copy__hint { margin: 0 0 8px; font-size: 13px; color: var(--mv-text-secondary); }
.mv-copy__text { font-family: var(--mv-font-mono); font-size: 13px; word-break: break-all; resize: vertical; }

.popover {
  --bs-popover-bg: var(--mv-raised);
  --bs-popover-border-color: var(--mv-border);
  --bs-popover-border-radius: var(--mv-radius-float);
  --bs-popover-inner-border-radius: calc(var(--mv-radius-float) - 1px);
  --bs-popover-box-shadow: var(--mv-shadow-float);
  --bs-popover-font-size: 12px;
  --bs-popover-header-bg: var(--mv-raised);
  --bs-popover-header-color: var(--mv-text);
  --bs-popover-header-font-size: 13px;
  --bs-popover-body-color: var(--mv-text);
  --bs-popover-arrow-border: var(--mv-border);
}

.tooltip {
  --bs-tooltip-bg: var(--mv-tooltip-bg);
  --bs-tooltip-color: var(--mv-tooltip-text);
  --bs-tooltip-font-size: 11px;
  --bs-tooltip-max-width: 320px;
  --bs-tooltip-border-radius: var(--mv-radius);
  --bs-tooltip-padding-x: 8px;
  --bs-tooltip-padding-y: 4px;
  --bs-tooltip-opacity: 1;
  font-weight: 500;
}

/* ---------------------------------------------------------------- badges and chips */

.badge,
.mv-badge {
  --bs-badge-padding-x: 6px;
  --bs-badge-padding-y: 0;
  --bs-badge-font-size: 11px;
  --bs-badge-font-weight: 500;
  --bs-badge-border-radius: var(--mv-radius);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid transparent;
  border-radius: var(--mv-radius);
}

.mv-badge,
.mv-badge--neutral {
  color: var(--mv-text);
  background-color: var(--mv-ground);
  border-color: var(--mv-chip-border);
}

.mv-badge--teal { color: var(--bs-primary-text-emphasis); background-color: var(--bs-primary-bg-subtle); border-color: var(--bs-primary-border-subtle); }
.mv-badge--success { color: var(--bs-success-text-emphasis); background-color: var(--bs-success-bg-subtle); border-color: var(--bs-success-border-subtle); }
.mv-badge--warning { color: var(--bs-warning-text-emphasis); background-color: var(--bs-warning-bg-subtle); border-color: var(--bs-warning-border-subtle); }
.mv-badge--danger { color: var(--bs-danger-text-emphasis); background-color: var(--bs-danger-bg-subtle); border-color: var(--bs-danger-border-subtle); }
.mv-badge--info { color: var(--bs-info-text-emphasis); background-color: var(--bs-info-bg-subtle); border-color: var(--bs-info-border-subtle); }

/* rtviewer-3's outlined status chip; (0.5.0) at weight 400 with the border at 70% of the text colour, as its chips */
.mv-badge--outline { font-weight: 400; background-color: transparent; border-color: color-mix(in srgb, currentColor 70%, transparent); }
.mv-badge--outline.mv-badge--neutral, .mv-badge--outline:not([class*="mv-badge--"]) { color: var(--mv-text-secondary); border-color: var(--mv-border); }

/* Bootstrap's filled badges become the same tinted chips, readable in both themes. */
.badge.bg-primary, .badge.text-bg-primary { color: var(--bs-primary-text-emphasis) !important; background-color: var(--bs-primary-bg-subtle) !important; border-color: var(--bs-primary-border-subtle); }
.badge.bg-success, .badge.text-bg-success { color: var(--bs-success-text-emphasis) !important; background-color: var(--bs-success-bg-subtle) !important; border-color: var(--bs-success-border-subtle); }
.badge.bg-warning, .badge.text-bg-warning { color: var(--bs-warning-text-emphasis) !important; background-color: var(--bs-warning-bg-subtle) !important; border-color: var(--bs-warning-border-subtle); }
.badge.bg-danger, .badge.text-bg-danger { color: var(--bs-danger-text-emphasis) !important; background-color: var(--bs-danger-bg-subtle) !important; border-color: var(--bs-danger-border-subtle); }
.badge.bg-info, .badge.text-bg-info { color: var(--bs-info-text-emphasis) !important; background-color: var(--bs-info-bg-subtle) !important; border-color: var(--bs-info-border-subtle); }
.badge.bg-secondary, .badge.text-bg-secondary, .badge.bg-secondary.text-white,
.badge.bg-light, .badge.text-bg-light,
.badge.bg-dark, .badge.text-bg-dark { color: var(--mv-text) !important; background-color: var(--mv-ground) !important; border-color: var(--mv-chip-border); }

/* Solid status backgrounds used as surfaces with text on them (with .text-white, as .text-bg-*, or as a card
   header, card, alert, list item or dialog/toast header) become the tinted status surfaces: emphasis text on
   the subtle tint with the subtle border colour, >= 4.5:1 in both themes (white on the dark theme's light
   status tones is not). Primary surfaces stay the teal fill with white text (5.6:1). A bare .bg-* (a
   progress bar, a status dot) keeps its solid tone. */
.text-bg-success, .bg-success.text-white, .card.bg-success, .card-header.bg-success, .card-footer.bg-success, .alert.bg-success,
.list-group-item.bg-success, .modal-header.bg-success, .toast-header.bg-success, .offcanvas-header.bg-success {
  color: var(--bs-success-text-emphasis) !important;
  background-color: var(--bs-success-bg-subtle) !important;
  border-color: var(--bs-success-border-subtle) !important;
}

.text-bg-warning, .bg-warning.text-white, .card.bg-warning, .card-header.bg-warning, .card-footer.bg-warning, .alert.bg-warning,
.list-group-item.bg-warning, .modal-header.bg-warning, .toast-header.bg-warning, .offcanvas-header.bg-warning {
  color: var(--bs-warning-text-emphasis) !important;
  background-color: var(--bs-warning-bg-subtle) !important;
  border-color: var(--bs-warning-border-subtle) !important;
}

.text-bg-danger, .bg-danger.text-white, .card.bg-danger, .card-header.bg-danger, .card-footer.bg-danger, .alert.bg-danger,
.list-group-item.bg-danger, .modal-header.bg-danger, .toast-header.bg-danger, .offcanvas-header.bg-danger {
  color: var(--bs-danger-text-emphasis) !important;
  background-color: var(--bs-danger-bg-subtle) !important;
  border-color: var(--bs-danger-border-subtle) !important;
}

.text-bg-info, .bg-info.text-white, .card.bg-info, .card-header.bg-info, .card-footer.bg-info, .alert.bg-info,
.list-group-item.bg-info, .modal-header.bg-info, .toast-header.bg-info, .offcanvas-header.bg-info {
  color: var(--bs-info-text-emphasis) !important;
  background-color: var(--bs-info-bg-subtle) !important;
  border-color: var(--bs-info-border-subtle) !important;
}

.text-bg-secondary, .bg-secondary.text-white, .card.bg-secondary, .card-header.bg-secondary, .card-footer.bg-secondary, .alert.bg-secondary,
.list-group-item.bg-secondary, .modal-header.bg-secondary, .toast-header.bg-secondary, .offcanvas-header.bg-secondary {
  color: var(--mv-text) !important;
  background-color: var(--mv-raised) !important;
  border-color: var(--mv-border) !important;
}

.card.bg-primary, .card-header.bg-primary, .card-footer.bg-primary, .alert.bg-primary, .list-group-item.bg-primary,
.modal-header.bg-primary, .toast-header.bg-primary, .offcanvas-header.bg-primary { color: var(--mv-on-primary) !important; }

/* ---------------------------------------------------------------- alerts */

.alert {
  --bs-alert-padding-x: 12px;
  --bs-alert-padding-y: 8px;
  --bs-alert-margin-bottom: 12px;
  --bs-alert-border-radius: var(--mv-radius);
  font-size: 13px;
}

.alert-dismissible { padding-right: 40px; }
.alert-dismissible .btn-close { padding: 12px; }
.alert-link { font-weight: 500; }
.alert-debug, .alert-secondary, .alert-light, .alert-dark {
  --bs-alert-color: var(--mv-text);
  --bs-alert-bg: var(--mv-raised);
  --bs-alert-border-color: var(--mv-border);
  --bs-alert-link-color: var(--mv-text);
}
.alert-primary {
  --bs-alert-color: var(--mv-text);
  --bs-alert-bg: var(--bs-primary-bg-subtle);
  --bs-alert-border-color: var(--bs-primary-border-subtle);
  --bs-alert-link-color: var(--mv-accent);
}

.alert:has(> .mv-alert__icon) { display: flex; align-items: flex-start; gap: 8px; }
.mv-alert__icon { margin-top: 2px; }
.mv-alert__body { flex: 1 1 auto; min-width: 0; }

/* ---------------------------------------------------------------- toasts */

.mv-toasts {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: auto;
  max-width: min(500px, calc(100vw - 32px));
  pointer-events: none;
}

.mv-toasts > * { pointer-events: auto; }
.mv-toasts > :not(:last-child) { margin-bottom: 0; }

.toast {
  --bs-toast-bg: var(--mv-raised);
  --bs-toast-color: var(--mv-text);
  --bs-toast-border-color: var(--mv-border);
  --bs-toast-border-radius: var(--mv-radius);
  --bs-toast-box-shadow: var(--mv-shadow-float);
  --bs-toast-max-width: 500px;
  --bs-toast-font-size: 13px;
  --bs-toast-padding-x: 12px;
  --bs-toast-padding-y: 8px;
  --bs-toast-header-bg: transparent;
  --bs-toast-header-color: var(--mv-text-secondary);
  --bs-toast-header-border-color: var(--mv-border);
}

.mv-toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: auto;
  max-width: 100%;
  padding: 10px 8px 10px 12px;
  box-shadow: inset 3px 0 0 var(--mv-toast-tone, var(--mv-accent)), var(--mv-shadow-float);
}

.mv-toast:not(.show):not(.showing) { display: none; }
.mv-toast__icon { margin-top: 2px; color: var(--mv-toast-tone-text, var(--mv-accent)); }
.mv-toast__text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.mv-toast .btn-close { flex: none; width: 10px; height: 10px; margin: 2px 0 0 4px; padding: 4px; background-size: 10px; }
.mv-toast--info { --mv-toast-tone: var(--mv-info); --mv-toast-tone-text: var(--bs-info-text-emphasis); }
.mv-toast--success { --mv-toast-tone: var(--mv-success); --mv-toast-tone-text: var(--bs-success-text-emphasis); }
.mv-toast--warning { --mv-toast-tone: var(--mv-warning); --mv-toast-tone-text: var(--bs-warning-text-emphasis); }
.mv-toast--danger { --mv-toast-tone: var(--mv-danger); --mv-toast-tone-text: var(--bs-danger-text-emphasis); }

/* ---------------------------------------------------------------- tabs, pills, pagination, breadcrumbs, lists */

.nav {
  --bs-nav-link-padding-x: 12px;
  --bs-nav-link-padding-y: 6px;
  --bs-nav-link-font-size: 13px;
  --bs-nav-link-font-weight: 500;
  --bs-nav-link-color: var(--mv-text-secondary);
  --bs-nav-link-hover-color: var(--mv-text);
  --bs-nav-link-disabled-color: var(--mv-text-disabled);
}

.nav-link { text-transform: none; transition: color 150ms, background-color 150ms, border-color 150ms; }

.nav-tabs {
  --bs-nav-tabs-border-width: 1px;
  --bs-nav-tabs-border-color: var(--mv-border);
  --bs-nav-tabs-border-radius: 0;
  --bs-nav-tabs-link-hover-border-color: transparent;
  --bs-nav-tabs-link-active-color: var(--mv-text);
  --bs-nav-tabs-link-active-bg: transparent;
  --bs-nav-tabs-link-active-border-color: transparent;
  gap: 4px;
}

.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link:hover { background-color: var(--mv-hover-tint); }
.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link { color: var(--mv-text); background-color: transparent; border-bottom-color: var(--mv-accent); }

.nav-pills {
  --bs-nav-pills-border-radius: var(--mv-radius);
  --bs-nav-pills-link-active-color: var(--mv-text);
  --bs-nav-pills-link-active-bg: var(--mv-selected);
  gap: 2px;
}

.nav-pills .nav-link:hover { background-color: var(--mv-hover-tint); }
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { box-shadow: inset 0 -2px 0 var(--mv-accent); }

.pagination {
  --bs-pagination-padding-x: 8px;
  --bs-pagination-padding-y: 4px;
  --bs-pagination-font-size: 12px;
  --bs-pagination-color: var(--mv-text-secondary);
  --bs-pagination-bg: transparent;
  --bs-pagination-border-width: 1px;
  --bs-pagination-border-color: var(--mv-border);
  --bs-pagination-border-radius: var(--mv-radius);
  --bs-pagination-hover-color: var(--mv-text);
  --bs-pagination-hover-bg: var(--mv-hover-tint);
  --bs-pagination-hover-border-color: var(--mv-accent);
  --bs-pagination-focus-color: var(--mv-text);
  --bs-pagination-focus-bg: var(--mv-hover-tint);
  --bs-pagination-focus-box-shadow: none;
  --bs-pagination-active-color: var(--mv-on-primary);
  --bs-pagination-active-bg: var(--mv-primary-fill);
  --bs-pagination-active-border-color: var(--mv-primary-fill);
  --bs-pagination-disabled-color: var(--mv-text-disabled);
  --bs-pagination-disabled-bg: transparent;
  --bs-pagination-disabled-border-color: var(--mv-border);
  gap: 4px;
}

.pagination .page-item .page-link { min-width: 28px; text-align: center; border-radius: var(--mv-radius); font-variant-numeric: tabular-nums; }
.pagination .page-item:not(:first-child) .page-link { margin-left: 0; }

.breadcrumb {
  --bs-breadcrumb-font-size: 12px;
  --bs-breadcrumb-margin-bottom: 8px;
  --bs-breadcrumb-item-padding-x: 6px;
  --bs-breadcrumb-divider-color: var(--mv-text-secondary);
  --bs-breadcrumb-item-active-color: var(--mv-text-secondary);
  --bs-breadcrumb-divider: "›";
}

.breadcrumb a { color: var(--mv-accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.list-group {
  --bs-list-group-color: var(--mv-text);
  --bs-list-group-bg: var(--mv-surface);
  --bs-list-group-border-color: var(--mv-border);
  --bs-list-group-border-radius: var(--mv-radius);
  --bs-list-group-item-padding-x: 12px;
  --bs-list-group-item-padding-y: 8px;
  --bs-list-group-action-color: var(--mv-text);
  --bs-list-group-action-hover-color: var(--mv-text);
  --bs-list-group-action-hover-bg: var(--mv-hover-tint);
  --bs-list-group-action-active-color: var(--mv-text);
  --bs-list-group-action-active-bg: var(--mv-pressed);
  --bs-list-group-disabled-color: var(--mv-text-disabled);
  --bs-list-group-disabled-bg: var(--mv-surface);
  --bs-list-group-active-color: var(--mv-text);
  --bs-list-group-active-bg: var(--mv-selected);
  --bs-list-group-active-border-color: var(--mv-border);
  font-size: 13px;
}

.accordion {
  --bs-accordion-color: var(--mv-text);
  --bs-accordion-bg: var(--mv-surface);
  --bs-accordion-border-color: var(--mv-border);
  --bs-accordion-border-radius: var(--mv-radius);
  --bs-accordion-inner-border-radius: calc(var(--mv-radius) - 1px);
  --bs-accordion-btn-padding-x: 12px;
  --bs-accordion-btn-padding-y: 10px;
  --bs-accordion-btn-color: var(--mv-text);
  --bs-accordion-btn-bg: var(--mv-surface);
  --bs-accordion-btn-focus-box-shadow: none;
  --bs-accordion-body-padding-x: 12px;
  --bs-accordion-body-padding-y: 12px;
  --bs-accordion-active-color: var(--mv-text);
  --bs-accordion-active-bg: var(--mv-selected);
}

.accordion-button { font-size: 14px; font-weight: 500; }
.accordion-button::after,
[data-bs-theme] .accordion-button::after {
  --bs-accordion-btn-icon: var(--mv-select-chevron);
  --bs-accordion-btn-active-icon: var(--mv-select-chevron);
  --bs-accordion-btn-icon-width: 16px;
}

.progress, .progress-stacked {
  --bs-progress-height: 6px;
  --bs-progress-font-size: 10px;
  --bs-progress-bg: var(--mv-border);
  --bs-progress-border-radius: var(--mv-radius);
  --bs-progress-bar-color: var(--mv-on-primary);
  --bs-progress-bar-bg: var(--mv-accent);
}

/* Labelled progress bars (0.4.0, {% mvui_progress %}): 20px tall, the label centred over the bar on a chip of the
   surface colour, so it reads whatever the fill under it (white text on a light status bar does not). The chip,
   .mv-progress__label, also works on its own over any positioned .progress. */
.mv-progress { --bs-progress-height: 20px; position: relative; }

.mv-progress__label {
  display: inline-block;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 16px;
  color: var(--mv-text);
  white-space: nowrap;
  background-color: var(--mv-surface);
  border-radius: var(--mv-radius);
}

.mv-progress > .mv-progress__label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

details > summary { cursor: pointer; }

/* ---------------------------------------------------------------- busy and loading */

.spinner-border, .spinner-grow { color: var(--mv-accent); }
.spinner-border { --bs-spinner-border-width: 2px; }
.mv-spinner--14 { --bs-spinner-width: 14px; --bs-spinner-height: 14px; --bs-spinner-border-width: 2px; }
.mv-spinner--22 { --bs-spinner-width: 22px; --bs-spinner-height: 22px; --bs-spinner-border-width: 2px; }
.mv-spinner--40 { --bs-spinner-width: 40px; --bs-spinner-height: 40px; --bs-spinner-border-width: 3px; }

.mv-spin { animation: mv-spin 1s linear infinite; }
@keyframes mv-spin { to { transform: rotate(360deg); } }

/* content being refreshed: a 40% veil of the page ground over it */
.mv-dim { position: relative; pointer-events: none; }
.mv-dim::after {
  position: absolute;
  inset: 0;
  content: "";
  background-color: var(--mv-ground);
  opacity: 0.4;
}

.mv-skeleton { display: flex; flex-direction: column; gap: 8px; }
.mv-skeleton__line {
  display: block;
  height: 12px;
  background: linear-gradient(90deg, var(--mv-raised) 0%, var(--mv-border) 50%, var(--mv-raised) 100%);
  background-size: 200% 100%;
  border-radius: var(--mv-radius);
  animation: mv-shimmer 1.4s ease-in-out infinite;
}
.mv-skeleton__line:nth-child(3n + 2) { width: 86%; }
.mv-skeleton__line:nth-child(3n) { width: 62%; }
@keyframes mv-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* htmx: the target of a running request keeps its content, dimmed under a veil with a 22px spinner, both
   after 150ms so a quick refresh does not flash. Give it a block element (a card, a div). */
.mv-loading { position: relative; pointer-events: none; cursor: progress; }

.mv-loading::after,
.mv-loading::before {
  position: absolute;
  content: "";
  opacity: 0;
}

.mv-loading::after {
  inset: 0;
  z-index: 1;
  background-color: var(--mv-ground);
  border-radius: inherit;
  animation: mv-loading-veil 150ms ease 150ms forwards;
}

.mv-loading::before {
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid var(--mv-accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: mv-loading-in 150ms ease 150ms forwards, mv-spin 0.75s linear infinite;
}

@keyframes mv-loading-in { to { opacity: 1; } }
@keyframes mv-loading-veil { to { opacity: 0.45; } }

/* DataTables SearchPanes on phones (mvui.js): folded behind a "Filters (n)" button below md. */
.mv-panes-toggle { display: none; }

@media (max-width: 767.98px) {
  .mv-panes-toggle { display: inline-flex; margin-bottom: 8px; }
}

@media (min-width: 768px) {
  .mv-panes-collapse.collapse:not(.show) { display: block; }
}

/* Lazy panes (0.3.0, mvui/includes/_lazy_pane.html): skeleton lines while loading; a failed load says so with "Try again". */
.mv-lazy__failed {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
}

.mv-lazy__failed[hidden],
.mv-lazy__loading[hidden] { display: none; }
.mv-lazy__text { margin: 0; font-size: 13px; color: var(--mv-text-secondary); }

/* Refresh controls (0.3.0, mvui/includes/_refresh_controls.html) */
.mv-refresh-controls { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mv-refresh-controls .btn,
.mv-lazy__failed .btn { display: inline-flex; align-items: center; gap: 6px; }

.mv-refresh-toggle[aria-pressed="true"] {
  color: var(--mv-text);
  background-color: var(--mv-selected);
  border-color: var(--mv-accent);
}

/* 0.4.0: the "Auto-refresh ON/OFF" toggle (onoff=True) says its state in words and colour: ON on the success tint,
   OFF the plain outline. */
.mv-refresh-toggle--onoff[aria-pressed="true"],
.mv-refresh-toggle--onoff[aria-pressed="true"]:hover {
  color: var(--bs-success-text-emphasis);
  background-color: var(--bs-success-bg-subtle);
  border-color: var(--mv-success);
}

/* 0.5.0: outline=True, ON as a success outline (a .btn-outline-success: the success text and border on no fill, tinted
   under the pointer) instead of the tint. */
.mv-refresh-toggle--onoff.mv-refresh-toggle--outline[aria-pressed="true"] { background-color: transparent; }
.mv-refresh-toggle--onoff.mv-refresh-toggle--outline[aria-pressed="true"]:hover { background-color: color-mix(in srgb, var(--mv-success) 10%, transparent); }

/* Chart.js wrappers (options.maintainAspectRatio: false): the chart takes the wrapper's height. */
.mv-chart { position: relative; width: 100%; height: clamp(220px, 35vh, 320px); }
.mv-chart--sm { height: clamp(180px, 30vh, 250px); }
.mv-chart--md { height: clamp(220px, 35vh, 320px); }
.mv-chart--lg { height: clamp(260px, 50vh, 520px); height: clamp(260px, 50dvh, 520px); }
.mv-chart--xl { height: clamp(300px, 70vh, 760px); height: clamp(300px, 70dvh, 760px); }
.mv-chart > canvas { display: block; max-width: 100%; }

/* Cards in as many 320px+ columns as fit (280px+ on workstation screens, which fit more); --mv-grid-min, set on the
   grid or an ancestor, sets the track minimum at every width (e.g. 420px for charts).
   .mv-grid-auto is auto-fit: empty tracks collapse, so three panels on a 1920px page share the row between them.
   .mv-grid-fill (0.3.0) is auto-fill: the empty tracks stay, so one or two cards keep a card's width instead of
   stretching across the row (a card grid of documents or videos). */
.mv-grid-auto,
.mv-grid-fill {
  --mv-grid-track: var(--mv-grid-min, 320px);
  display: grid;
  gap: 16px;
}

.mv-grid-auto { grid-template-columns: repeat(auto-fit, minmax(min(var(--mv-grid-track), 100%), 1fr)); }
.mv-grid-fill { grid-template-columns: repeat(auto-fill, minmax(min(var(--mv-grid-track), 100%), 1fr)); }

@media (min-width: 1920px) {
  .mv-grid-auto,
  .mv-grid-fill { --mv-grid-track: var(--mv-grid-min, 280px); gap: 20px; }
}

/* Workstation columns (0.3.0): Bootstrap's grid stops at xxl (1400px); these are the step above it, from 1920px,
   named like Bootstrap's (.col-ws-*, .row-cols-ws-*) and used beside them, e.g. class="col-lg-6 col-ws-3". */
@media (min-width: 1920px) {
  .col-ws { flex: 1 0 0%; }
  .row-cols-ws-auto > * { flex: 0 0 auto; width: auto; }
  .row-cols-ws-1 > * { flex: 0 0 auto; width: 100%; }
  .row-cols-ws-2 > * { flex: 0 0 auto; width: 50%; }
  .row-cols-ws-3 > * { flex: 0 0 auto; width: 33.33333333%; }
  .row-cols-ws-4 > * { flex: 0 0 auto; width: 25%; }
  .row-cols-ws-5 > * { flex: 0 0 auto; width: 20%; }
  .row-cols-ws-6 > * { flex: 0 0 auto; width: 16.66666667%; }
  .col-ws-auto { flex: 0 0 auto; width: auto; }
  .col-ws-1 { flex: 0 0 auto; width: 8.33333333%; }
  .col-ws-2 { flex: 0 0 auto; width: 16.66666667%; }
  .col-ws-3 { flex: 0 0 auto; width: 25%; }
  .col-ws-4 { flex: 0 0 auto; width: 33.33333333%; }
  .col-ws-5 { flex: 0 0 auto; width: 41.66666667%; }
  .col-ws-6 { flex: 0 0 auto; width: 50%; }
  .col-ws-7 { flex: 0 0 auto; width: 58.33333333%; }
  .col-ws-8 { flex: 0 0 auto; width: 66.66666667%; }
  .col-ws-9 { flex: 0 0 auto; width: 75%; }
  .col-ws-10 { flex: 0 0 auto; width: 83.33333333%; }
  .col-ws-11 { flex: 0 0 auto; width: 91.66666667%; }
  .col-ws-12 { flex: 0 0 auto; width: 100%; }
}

/* ---------------------------------------------------------------- KPI cards */

.mv-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(176px, 100%), 1fr));
  gap: 12px;
}

.mv-kpi {
  --mv-kpi-tone: transparent;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 16px;
  color: var(--mv-text);
  text-decoration: none;
  background-color: var(--mv-surface);
  border: 1px solid var(--mv-border);
  border-radius: var(--mv-radius);
  box-shadow: inset 3px 0 0 var(--mv-kpi-tone);
  transition: border-color 250ms, background-color 250ms;
}

.mv-kpi--teal { --mv-kpi-tone: var(--mv-accent); --mv-kpi-tone-text: var(--mv-accent); }
.mv-kpi--success { --mv-kpi-tone: var(--mv-success); --mv-kpi-tone-text: var(--bs-success-text-emphasis); }
.mv-kpi--warning { --mv-kpi-tone: var(--mv-warning); --mv-kpi-tone-text: var(--bs-warning-text-emphasis); }
.mv-kpi--danger { --mv-kpi-tone: var(--mv-danger); --mv-kpi-tone-text: var(--bs-danger-text-emphasis); }
.mv-kpi--info { --mv-kpi-tone: var(--mv-info); --mv-kpi-tone-text: var(--bs-info-text-emphasis); }

.mv-kpi--link:hover {
  color: var(--mv-text);
  background-color: color-mix(in srgb, var(--mv-accent) 5%, var(--mv-surface));
  border-color: var(--mv-accent);
}

.mv-kpi__label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--mv-text-secondary);
}

.mv-kpi__label > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mv-kpi__icon { color: var(--mv-kpi-tone-text); }
.mv-kpi--neutral .mv-kpi__icon { color: var(--mv-text-secondary); }
.mv-kpi__value { font-size: 22px; font-weight: 500; line-height: 1.2; overflow-wrap: anywhere; }
.mv-kpi__secondary { font-size: 12px; color: var(--mv-text-secondary); }

/* ---------------------------------------------------------------- error page, empty state, key-value list */

.mv-error {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 560px;
}

.mv-error-card {
  overflow: hidden;
  background-color: var(--mv-raised);
  border: 1px solid var(--mv-border);
  border-radius: var(--mv-radius);
  box-shadow: var(--mv-shadow-float);
}

.mv-error-card__head { display: flex; flex-direction: column; gap: 6px; padding: 24px 24px 20px; }
.mv-error-card__code { margin: 0; font-size: 19px; font-weight: 500; line-height: 1.6; color: var(--mv-text-secondary); } /* (0.5.0) rtviewer-3's 19px/500 (was 13px/400) */
.mv-error-card__title { margin: 0; font-size: 19px; font-weight: 500; }
.mv-error-card__message, .mv-error-card__text { margin: 0; font-size: 13px; color: var(--mv-text-secondary); }
.mv-error-card__message { color: var(--mv-text); }

.mv-error-card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 24px 24px;
}

.mv-error__support { margin: 0; font-size: 12px; line-height: 1.6; color: var(--mv-text-secondary); text-align: center; }

/* (0.5.0) A server-error card holds four buttons ("Copy details" and "Email support" too): 720px, so they share a row.
   (0.5.1) So does a card with the app's own actions, whose wrapper lays them out as the card's other buttons. */
.mv-error:has(.mv-error-card__actions [data-mv-copy]),
.mv-error:has(.mv-error-card__app-actions) { max-width: 720px; }
.mv-error-card__app-actions { display: contents; }

/* (0.5.0) mvui's error pages in dark stand on the surface, as rtviewer-3's (the card is the raised fill). */
html[data-bs-theme="dark"] .mv-body--minimal.mv-body--error,
html[data-bs-theme="dark"] .mv-body--minimal.mv-body--error .mv-main { background-color: var(--mv-surface); }
.mv-error__support .mv-icon { vertical-align: -0.15em; }

.mv-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 16px;
  text-align: center;
}

.mv-empty-state__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: var(--mv-text-secondary);
  background-color: var(--mv-ground);
  border: 1px solid var(--mv-border);
  border-radius: var(--mv-radius);
}

.mv-empty-state__title { margin: 0; font-size: 15px; font-weight: 500; }
.mv-empty-state__text { max-width: 420px; margin: 0; font-size: 13px; line-height: 1.5; color: var(--mv-text-secondary); }

.mv-kv {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 16px;
  margin: 0;
  font-size: 13px;
}

.mv-kv > dt { font-weight: 400; color: var(--mv-text-secondary); }
.mv-kv > dd { min-width: 0; margin: 0 0 8px; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- breakpoints */

@media (max-width: 575.98px) {
  .mv-header__app { display: none; }
  .mv-page-actions { width: 100%; }
}

@media (min-width: 576px) {
  .mv-page-heading { flex-basis: auto; }
  .mv-kv { grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); row-gap: 8px; }
  .mv-kv > dd { margin: 0; }
}

@media (min-width: 768px) {
  :root { --mv-main-pad-x: 28px; --mv-main-pad-top: 20px; }
  .mv-header__inner { padding-left: max(12px, env(safe-area-inset-left)); } /* (0.5.0) rtviewer-3's 12px (was 16px) */
}

/* workstation screens */
@media (min-width: 1920px) {
  :root { --mv-main-pad-x: 40px; --mv-main-pad-top: 24px; --mv-main-pad-bottom: 32px; }
  .mv-header__inner { padding-right: 16px; padding-left: 24px; }
  .mv-kpi-grid { gap: 16px; }
}

/* ---------------------------------------------------------------- device rules */

@media (pointer: coarse) {
  .btn,
  .btn-sm,
  .form-control,
  .form-select,
  .page-link,
  .dropdown-item,
  .nav-link,
  .mv-nav__link,
  .list-group-item-action { min-height: 44px; }

  .pagination .page-item .page-link { display: flex; align-items: center; justify-content: center; min-width: 44px; }
  .mv-icon-btn, .mv-account__button { width: 44px; height: 44px; }
  /* 0.3.0: the logo link and the theme switch's options reach 44px too (the switch was 36px) */
  .mv-header__brand { min-height: 44px; }
  .mv-segmented__option { min-height: 44px; }
  .form-check-input { width: 20px; height: 20px; }
  /* 0.4.0: a range slider's track centred in a 44px box */
  .form-range { height: 44px; }
  .form-switch .form-check-input { width: 36px; }

  /* 0.3.0, from mvui.testing's touch-target check: icon-only buttons, close buttons, breadcrumb links and the label
     of a checkbox, radio or switch (with the box beside it, the target) reach 44px as well. */
  .btn, .btn-sm, .mv-segmented__option { min-width: 44px; justify-content: center; }
  .btn-close { box-sizing: border-box; width: 44px; height: 44px; padding: 0; }
  .mv-toast .btn-close { width: 44px; height: 44px; margin: -14px -8px -14px 0; padding: 0; }
  .breadcrumb-item { display: flex; align-items: center; }
  .breadcrumb-item + .breadcrumb-item::before { float: none; }
  .breadcrumb-item > a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  .form-check { min-height: 44px; }
  .form-check .form-check-input { margin-top: 12px; }
  .form-check:not(.form-check-reverse) { padding-left: 28px; }
  .form-check:not(.form-check-reverse) .form-check-input { margin-left: -28px; }
  .form-switch:not(.form-check-reverse) { padding-left: 44px; }
  .form-switch:not(.form-check-reverse) .form-check-input { margin-left: -44px; }
  .form-check-label { padding: 11.5px 0; }
  /* a <details> summary: zero specificity, so an app's own summary padding wins; (0.4.0) and 44px at any text size */
  :where(summary) { box-sizing: border-box; min-height: 44px; padding-top: 11.5px; padding-bottom: 11.5px; }

  /* 0.4.0: the small controls (Bootstrap's -sm sizes, a small input group) and a link alone in a table cell reach 44px
     too; the row grows to fit. (A link beside other content in its cell: 0.5.0, below.) */
  .form-control-sm,
  .form-select-sm,
  .input-group-sm > .form-control,
  .input-group-sm > .form-select,
  .input-group-sm > .input-group-text,
  .input-group-sm > .btn { min-height: 44px; }

  .table > tbody > tr > :is(td, th) > a:only-child:not(.btn),
  .table > tfoot > tr > :is(td, th) > a:only-child:not(.btn) {
    display: inline-flex;
    align-items: center;
    min-width: 44px;
    min-height: 44px;
  }

  /* the rest of such a row centred on the link's line, not left at the top of the taller row. (0.5.1) Every body and footer
     row's cells: 0.4.0 picked the rows holding such a link with a :has() on the row, which made every restyle of a
     table's rows dearer while DataTables built and redrew them (about 160ms of a load of ai.dashboard's customers on a
     slow phone, a fifth of its blocking time). */
  .table > :is(tbody, tfoot) > tr > * { vertical-align: middle; }

  /* 0.5.0: links that share their cell with other elements (several chips or links in one cell, a name above its badge)
     reach 44px too: the cell's own links, and the links of a flex row in the cell (.d-flex, .d-inline-flex, .hstack,
     .vstack: chips in a wrapper). They stay inline-level, so they keep their places among the cell's other content and
     wrap as before; the row grows to fit. Links inside a text element of the cell (a <p>, a <span>: running text) are
     left as they are, as mvui.testing's touch check leaves links in running text. */
  .table > tbody > tr > :is(td, th) > a:not(.btn):not(:only-child),
  .table > tfoot > tr > :is(td, th) > a:not(.btn):not(:only-child),
  .table > tbody > tr > :is(td, th) > :is(.d-flex, .d-inline-flex, .hstack, .vstack) > a:not(.btn),
  .table > tfoot > tr > :is(td, th) > :is(.d-flex, .d-inline-flex, .hstack, .vstack) > a:not(.btn) {
    display: inline-flex;
    align-items: center;
    min-width: 44px;
    min-height: 44px;
  }

  /* 0.5.1: a link that is the whole value of an .mv-kv detail list (a scan's patient) reaches 44 x 44, as a link alone in a
     table cell does; its text stays at the top of the box, level with its label. */
  .mv-kv > dd > a:only-child:not(.btn) {
    display: inline-flex;
    align-items: flex-start;
    min-width: 44px;
    min-height: 44px;
  }

  /* 16px stops iOS zooming into a focused field */
  .form-control, .form-select { font-size: 16px; }
}

.mv-reveal-on-hover { transition: opacity 150ms; }

@media (hover: hover) {
  .mv-reveal-scope .mv-reveal-on-hover { opacity: 0; }
  .mv-reveal-scope:hover .mv-reveal-on-hover,
  .mv-reveal-scope:focus-within .mv-reveal-on-hover { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { transition-duration: 0s !important; transition-delay: 0s !important; }
  .mv-skeleton__line { animation: none; }
  .mv-loading::before { animation: mv-loading-in 150ms ease 150ms forwards, mv-spin 3s linear infinite; }
  .mv-nav-progress.is-active { width: 100%; }
  .mv-spin { animation-duration: 3s; }
}

/* ---------------------------------------------------------------- print (light tokens: tokens.css) */

@media print {
  .mv-header,
  .mv-drawer,
  .mv-toasts,
  .mv-nav-progress,
  .mv-skip-link,
  .mv-confirm,
  .mv-copy,
  .offcanvas-backdrop,
  .modal-backdrop,
  .alert .btn-close { display: none !important; }

  *, ::before, ::after { box-shadow: none !important; text-shadow: none !important; }
  .mv-body, .mv-main { background-color: var(--mv-surface) !important; }
  .mv-main { padding: 0; }
  .card, .mv-kpi, .table > tbody > tr { break-inside: avoid; }
  thead { display: table-header-group; }

  a[href^="http://"]::after,
  a[href^="https://"]::after {
    content: " (" attr(href) ")";
    font-size: 11px;
    color: var(--mv-text-secondary);
    overflow-wrap: anywhere;
  }
}
