/* Components of the new layout (templates/layouts/app.html). Colors come from tokens.css only. */

/* Keeps in-page jumps from landing under the sticky top bar. */
html {
  scroll-padding-top: 80px;
}

.vm-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* Mobile browsers count their collapsing toolbars in vh; dvh follows what is actually visible. */
  min-height: 100dvh;
  background: var(--vm-bg);
  color: var(--vm-text);
  font-family: var(--vm-font);
  font-size: 14px;
  line-height: 1.5;
}

.vm-skip {
  position: absolute;
  top: -60px;
  left: var(--vm-space-3);
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--vm-radius);
  background: var(--vm-primary);
  color: var(--vm-on-primary);
  font-weight: 600;
  text-decoration: none;
}

.vm-skip:focus {
  top: var(--vm-space-3);
  color: var(--vm-on-primary);
}

/* ---- App shell ---- */

.vm-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: var(--vm-space-3);
  height: 64px;
  /* viewport-fit=cover lets the page run under the notch in landscape; keep controls out of it. */
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--vm-border);
  background: var(--vm-surface);
}

.vm-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--vm-radius);
  color: var(--vm-text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  .vm-brand:hover {
    color: var(--vm-text);
  }
}

.vm-company-btn {
  display: flex;
  align-items: center;
  gap: var(--vm-space-2);
  max-width: 260px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--vm-input-border);
  border-radius: var(--vm-radius);
  background: var(--vm-surface);
  color: var(--vm-text);
}

.vm-company-btn.is-static {
  border-color: transparent;
}

.vm-company-name {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vm-spacer {
  flex: 1;
}

.vm-iconbtn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--vm-radius);
  background: none;
  color: inherit;
}

@media (hover: hover) and (pointer: fine) {
  .vm-iconbtn:hover {
    background: var(--vm-surface-2);
  }
}

.vm-iconbtn:disabled {
  opacity: .6;
}

.vm-dot {
  position: absolute;
  top: 6px;
  right: 5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--vm-danger-ink);
  color: var(--vm-surface);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

[data-theme="dark"] .vm-show-light,
[data-theme="light"] .vm-show-dark {
  display: none;
}

.vm-user-btn {
  display: flex;
  align-items: center;
  gap: var(--vm-space-2);
  min-height: 44px;
  padding: 0 8px 0 4px;
  border: 0;
  border-radius: var(--vm-radius);
  background: none;
  color: var(--vm-text);
}

@media (hover: hover) and (pointer: fine) {
  .vm-user-btn:hover {
    background: var(--vm-surface-2);
  }
}

.vm-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--vm-primary-soft);
  color: var(--vm-primary-ink);
  font-size: 13px;
  font-weight: 700;
}

.vm-menu {
  min-width: 240px;
  padding: 6px;
  border-color: var(--vm-border);
  border-radius: 12px;
  background: var(--vm-surface);
  box-shadow: var(--vm-shadow-menu);
}

/* The column and filter pickers of the grid reports: a dropdown holding checkboxes. */
.dropdown-checkbox-menu {
  min-width: 250px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
  border-color: var(--vm-border);
  background-color: var(--vm-surface);
  color: var(--vm-text);
}

.dropdown-checkbox-menu .form-check {
  margin-bottom: 8px;
}

.dropdown-checkbox-menu .form-check-label {
  color: var(--vm-text);
}

.dropdown-checkbox-menu hr {
  margin: 8px 0;
  border-color: var(--vm-border);
  opacity: .25;
}

/* Popper positions the menu with an inline transform. A scale would multiply that translation and
   swoop the menu in from a displaced spot, so the entrance is a fade plus a small additive translate. */
.vm-menu.show,
.dropdown-checkbox-menu.show {
  opacity: 1;
  translate: 0 0;
  transition:
    opacity var(--vm-dur-fast) var(--vm-ease-out),
    translate var(--vm-dur-fast) var(--vm-ease-out);
}

@starting-style {
  .vm-menu.show,
  .dropdown-checkbox-menu.show {
    opacity: 0;
    translate: 0 calc(var(--vm-enter-distance) * -.5);
  }
}

.vm-menu-wide {
  width: min(380px, calc(100vw - 32px));
}

.vm-menu .dropdown-header {
  margin: 0;
  padding: 8px 10px 4px;
  color: var(--vm-text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.vm-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border-radius: 8px;
  color: var(--vm-text);
}

.vm-menu-item:focus-visible {
  background: var(--vm-surface-2);
  color: var(--vm-text);
}

@media (hover: hover) and (pointer: fine) {
  .vm-menu-item:hover {
    background: var(--vm-surface-2);
    color: var(--vm-text);
  }
}

.vm-menu-item[aria-checked="true"]::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--vm-primary-ink);
}

.vm-check {
  color: var(--vm-primary-ink);
}

.vm-menu-header {
  display: flex;
  flex-direction: column;
  margin-bottom: 4px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--vm-border);
}

.vm-menu-header span,
.vm-menu-empty {
  color: var(--vm-text-muted);
  font-size: 13px;
}

.vm-menu-empty {
  margin: 0;
  padding: 10px;
}

.vm-body {
  display: flex;
  flex: 1;
  align-items: stretch;
  min-height: calc(100vh - 64px);
}

/* Bootstrap's responsive offcanvas forces a transparent background on .vm-sidebar above the
   breakpoint, so the visible panel is the inner element. */
.vm-sidebar {
  --bs-offcanvas-width: min(300px, 86vw);
  --bs-offcanvas-transition: transform var(--vm-dur-drawer) var(--vm-ease-drawer);
  flex: none;
  width: 248px;
}

.vm-sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 16px 12px 16px max(12px, env(safe-area-inset-left));
  border-right: 1px solid var(--vm-border);
  background: var(--vm-surface);
  overflow-y: auto;
}

.vm-nav-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.vm-nav-title {
  padding: 14px 12px 6px;
  color: var(--vm-text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.vm-nav-item,
.vm-nav-collapse {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--vm-radius);
  background: none;
  color: var(--vm-text);
  font-weight: 500;
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  .vm-nav-item:hover,
  .vm-nav-collapse:hover {
    background: var(--vm-surface-2);
    color: var(--vm-text);
  }
}

.vm-nav-item.is-active {
  background: var(--vm-primary-soft);
  color: var(--vm-primary-ink);
  font-weight: 600;
}

.vm-nav-collapse {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--vm-border);
  border-radius: var(--vm-radius) var(--vm-radius) 0 0;
  color: var(--vm-text-muted);
}

.vm-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 28px max(32px, env(safe-area-inset-right)) 48px 32px;
  outline: none;
}

.vm-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1360px;
  margin: 0 auto;
}

.vm-bottomnav {
  display: none;
}

/* Their display rules would otherwise win over the hidden attribute. */
.vm-iconbtn[hidden],
.vm-menu-item[hidden] {
  display: none;
}

@media (min-width: 768px) {
  /* Collapsed: icons only. Labels stay in the accessibility tree, so links keep their names. */
  [data-nav-collapsed="true"] .vm-sidebar {
    width: 76px;
  }

  [data-nav-collapsed="true"] .vm-nav-title {
    display: none;
  }

  [data-nav-collapsed="true"] .vm-nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  [data-nav-collapsed="true"] .vm-nav-item,
  [data-nav-collapsed="true"] .vm-nav-collapse {
    justify-content: center;
    padding: 0;
  }

  [data-nav-collapsed="true"] .vm-nav-collapse .icon {
    transform: scaleX(-1);
  }
}

@media (max-width: 767.98px) {
  .vm-topbar {
    gap: 2px;
    padding: 0 max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
  }

  .vm-brand {
    padding: 4px;
  }

  .vm-brand-name {
    display: none;
  }

  /* Only the company name gives way, so a long one cannot squeeze the icons on a 320px screen. */
  .vm-topbar > * {
    flex-shrink: 0;
  }

  .vm-topbar > .vm-company {
    flex-shrink: 1;
    min-width: 0;
  }

  /* Top bar menus open downwards; on a short phone they must stop above the bottom bar. */
  .vm-menu {
    max-height: calc(100dvh - 140px - env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  .vm-company-btn {
    max-width: 100%;
  }

  .vm-sidebar-inner {
    border-right: 0;
  }

  .vm-sidebar {
    touch-action: pan-y;
  }

  .vm-main {
    padding: 18px max(14px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .vm-bottomnav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1020;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    border-top: 1px solid var(--vm-border);
    background: var(--vm-surface);
  }

  .vm-bn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: none;
    color: var(--vm-text-muted);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
  }

  .vm-bn.is-active {
    color: var(--vm-primary-ink);
    font-weight: 700;
  }

  .vm-bn .icon {
    transition: scale var(--vm-dur-press) var(--vm-ease-out);
  }

  .vm-bn:active .icon {
    scale: var(--vm-press-scale);
  }
}

/* ---- Press feedback ---- */

.btn,
.vm-iconbtn,
.vm-user-btn,
.vm-company-btn,
.vm-seg-btn,
.vm-nav-item,
.vm-nav-collapse {
  transition:
    scale var(--vm-dur-press) var(--vm-ease-out),
    background-color var(--vm-dur-fast) ease,
    color var(--vm-dur-fast) ease,
    border-color var(--vm-dur-fast) ease,
    box-shadow var(--vm-dur-fast) ease;
}

.btn:active:not(:disabled),
.vm-iconbtn:active:not(:disabled),
.vm-user-btn:active,
.vm-company-btn:active,
.vm-seg-btn:active,
.vm-nav-item:active,
.vm-nav-collapse:active {
  scale: var(--vm-press-scale);
}

/* A tap leaves :hover on, so Bootstrap's hover colours would stick; touch screens get the resting colours. */
@media (hover: none) {
  .btn:hover:not(:active, .active, .show, .btn-check:checked + .btn) {
    background-color: var(--bs-btn-bg);
    border-color: var(--bs-btn-border-color);
    color: var(--bs-btn-color);
  }
}

/* ---- Page building blocks ---- */

.vm-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--vm-space-4);
}

.vm-page-head-actions {
  align-items: center;
}

/* On a phone the buttons wrap into rows; a label that wraps in one must not leave its neighbour shorter. */
@media (max-width: 575.98px) {
  .vm-page-head-actions {
    align-items: stretch;
  }
}

/* Page help: a side panel with a list of hints, full width on a phone. */
.vm-help-panel {
  --bs-offcanvas-width: min(420px, 100vw);
  --bs-offcanvas-transition: transform var(--vm-dur-drawer) var(--vm-ease-drawer);
  --bs-offcanvas-bg: var(--vm-surface);
  --bs-offcanvas-color: var(--vm-text);
  --bs-offcanvas-border-color: var(--vm-border);
  padding-bottom: env(safe-area-inset-bottom);
}

.vm-help-panel .offcanvas-header {
  justify-content: space-between;
}

.vm-help-list {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: var(--vm-space-3);
}

@media (max-width: 575.98px) {
  .vm-help-panel {
    --bs-offcanvas-width: 100vw;
  }
}

.vm-h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.vm-h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.vm-sub {
  margin: 4px 0 0;
  color: var(--vm-text-muted);
}

.vm-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vm-space-2);
}

.vm-card {
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-card);
  background: var(--vm-surface);
  box-shadow: var(--vm-shadow);
}

.vm-card-body {
  padding: 18px 20px;
}

.vm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--vm-space-4);
}

.vm-kpi {
  display: flex;
  flex-direction: column;
  gap: var(--vm-space-2);
  padding: 18px 20px;
}

.vm-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--vm-space-2);
}

.vm-kpi-label {
  font-weight: 500;
  color: var(--vm-text-muted);
}

.vm-kpi-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--vm-radius);
  background: var(--vm-primary-soft);
  color: var(--vm-primary-ink);
}

.vm-kpi-value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.vm-kpi-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--vm-text-muted);
}

.vm-kpi-foot.is-up {
  color: var(--vm-success-ink);
}

.vm-kpi-foot.is-down {
  color: var(--vm-danger-ink);
}

.vm-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.vm-tone-success { background: var(--vm-success-soft); color: var(--vm-success-ink); }
.vm-tone-warning { background: var(--vm-warning-soft); color: var(--vm-warning-ink); }
.vm-tone-danger { background: var(--vm-danger-soft); color: var(--vm-danger-ink); }
.vm-tone-info { background: var(--vm-primary-soft); color: var(--vm-primary-ink); }
.vm-tone-neutral { background: var(--vm-neutral-soft); color: var(--vm-neutral-ink); }

.vm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 24px;
  text-align: center;
}

.vm-empty p {
  max-width: 460px;
  margin: 0;
  color: var(--vm-text-muted);
}

.vm-empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--vm-surface-2);
  color: var(--vm-text-muted);
  font-size: 24px;
}

.vm-toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: var(--vm-space-2);
  max-width: min(420px, calc(100vw - 40px));
}

.vm-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 8px 12px 14px;
  border: 1px solid var(--vm-border);
  border-radius: 12px;
  background: var(--vm-surface);
  color: var(--vm-text);
  box-shadow: var(--vm-shadow-menu);
  transition:
    opacity var(--vm-dur-toast) ease,
    translate var(--vm-dur-toast) ease;
}

@starting-style {
  .vm-toast {
    opacity: 0;
    translate: 0 var(--vm-toast-distance);
  }
}

.vm-toast.is-leaving {
  opacity: 0;
  translate: 0 calc(var(--vm-enter-distance) * 2);
  transition-duration: var(--vm-dur-base);
  transition-timing-function: var(--vm-ease-out);
}

.vm-toast-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.vm-toast-text {
  flex: 1;
  padding-top: 3px;
}

.vm-seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--vm-input-border);
  border-radius: var(--vm-radius);
  background: var(--vm-surface);
}

.vm-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--vm-text-muted);
  font-weight: 500;
}

.vm-seg-btn[aria-checked="true"],
.vm-seg-btn[aria-pressed="true"] {
  background: var(--vm-primary);
  color: var(--vm-on-primary);
}

.vm-swatch {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--vm-border);
  font-size: 13px;
}

.vm-swatch code {
  color: inherit;
}

.vm-grid-icons {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.vm-icon-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius);
  background: var(--vm-surface);
  font-size: 12px;
  color: var(--vm-text-muted);
  text-align: center;
  word-break: break-word;
}

.vm-icon-cell code {
  color: var(--vm-text-muted);
}

.vm-icon-cell .icon {
  width: 24px;
  height: 24px;
  color: var(--vm-text);
}

/* ---- Dashboard ---- */

.vm-grid-kpi {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.vm-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: var(--vm-space-4);
}

.vm-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 16px 20px 0;
}

.vm-card-foot {
  margin: 0;
  padding: 0 20px 16px;
  color: var(--vm-text-muted);
  font-size: 13px;
}

a.vm-seg-btn {
  text-decoration: none;
}

.vm-seg-btn[aria-current="page"] {
  background: var(--vm-primary);
  color: var(--vm-on-primary);
}

.vm-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 8px 12px 12px;
  list-style: none;
}

.vm-attn,
.vm-row {
  display: flex;
  align-items: center;
  gap: var(--vm-space-3);
  padding: 10px 8px;
  border-bottom: 1px solid var(--vm-border);
}

.vm-attn:last-child,
.vm-row:last-child {
  border-bottom: 0;
}

.vm-row {
  justify-content: space-between;
}

.vm-attn-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--vm-radius);
}

.vm-attn-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.vm-attn-text strong {
  font-weight: 600;
}

.vm-attn-text span {
  color: var(--vm-text-muted);
  font-size: 13px;
}

.vm-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.vm-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 16px 20px 20px;
  list-style: none;
}

.vm-bar-top {
  display: flex;
  justify-content: space-between;
  gap: var(--vm-space-3);
  margin-bottom: 6px;
}

.vm-progress {
  display: block;
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 5px;
  background: var(--vm-surface-2);
  overflow: hidden;
  appearance: none;
}

.vm-progress::-webkit-progress-bar {
  background: var(--vm-surface-2);
}

.vm-progress::-webkit-progress-value {
  border-radius: 5px;
  background: var(--vm-chart);
}

.vm-progress::-moz-progress-bar {
  border-radius: 5px;
  background: var(--vm-chart);
}

.vm-chart {
  margin: 0;
  padding: 8px 20px 16px;
}

.vm-chart-plot {
  display: flex;
  gap: 10px;
}

.vm-chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 200px;
  color: var(--vm-text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.vm-chart-area {
  flex: 1;
  min-width: 0;
}

.vm-chart-svg {
  display: block;
  width: 100%;
  height: 200px;
  overflow: visible;
}

.vm-chart-grid {
  stroke: var(--vm-border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.vm-chart-fill {
  fill: var(--vm-chart-fill);
}

.vm-chart-line {
  fill: none;
  stroke: var(--vm-chart);
  stroke-width: 2.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.vm-chart-x {
  position: relative;
  height: 22px;
  margin-top: 6px;
  color: var(--vm-text-muted);
  font-size: 12px;
}

.vm-chart-x span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.vm-chart-x .is-start {
  transform: none;
}

.vm-chart-x .is-end {
  transform: translateX(-100%);
}

.vm-chart-table {
  margin-top: 8px;
}

.vm-chart-table summary {
  display: inline-block;
  padding: 6px 0;
  color: var(--vm-primary-ink);
  font-weight: 600;
  cursor: pointer;
}

.vm-chart-table table {
  margin-top: 8px;
}

/* ---- Result tables (static/js/result_table.js) ---- */

.vm-rt {
  display: flex;
  flex-direction: column;
  gap: var(--vm-space-3);
}

.vm-rt-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--vm-space-3);
}

.vm-rt-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-card);
  background: var(--vm-surface);
  box-shadow: var(--vm-shadow);
}

.vm-rt-stat-label {
  color: var(--vm-text-muted);
  font-size: 13px;
  font-weight: 500;
}

.vm-rt-stat-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.vm-rt-stat-detail {
  color: var(--vm-text-muted);
  font-size: 12px;
}

.vm-rt-split-bar {
  display: flex;
  height: 10px;
  margin: 8px 0 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--vm-surface-2);
}

.vm-rt-split-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin: 0;
  padding: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  list-style: none;
}

.vm-rt-split-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vm-rt-split-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.vm-rt-split-bar .vm-rt-split-0,
.vm-rt-split-0 .vm-rt-split-dot {
  background: var(--vm-success-ink);
}

.vm-rt-split-bar .vm-rt-split-1,
.vm-rt-split-1 .vm-rt-split-dot {
  background: var(--vm-chart);
}

.vm-rt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vm-space-2) var(--vm-space-3);
}

.vm-rt-search {
  position: relative;
  flex: 1 1 240px;
  max-width: 360px;
}

.vm-rt-search .icon {
  position: absolute;
  top: 50%;
  left: 12px;
  color: var(--vm-text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.vm-rt-search .form-control {
  padding-left: 36px;
}

.vm-rt-sortbar {
  display: none;
  align-items: center;
  gap: 4px;
}

.vm-rt-count {
  margin: 0;
  color: var(--vm-text-muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.vm-rt-tools {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vm-space-2);
  margin-left: auto;
}

.vm-rt-scroll {
  max-height: max(360px, calc(100dvh - 260px));
  overflow: auto;
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-card);
  background: var(--vm-surface);
}

.vm-rt-scroll:focus-visible {
  outline: 2px solid var(--vm-focus);
  outline-offset: 2px;
}

/* A server-paged table while the next page is on its way. */
.vm-rt[aria-busy="true"] .vm-rt-scroll {
  opacity: 0.55;
}

.vm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--vm-text);
  font-size: 14px;
}

.vm-table th,
.vm-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--vm-border);
  background: var(--vm-surface);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.vm-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--vm-surface-2);
  color: var(--vm-text-muted);
  font-size: 13px;
  font-weight: 600;
}

.vm-table .is-money,
.vm-table .is-count,
.vm-table .is-code {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.vm-table td.is-money {
  font-weight: 500;
}

.vm-table .is-wrap {
  min-width: 180px;
  white-space: normal;
}

/* The first column stays in view while a wide table scrolls sideways. */
.vm-table th:first-child,
.vm-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}

.vm-table thead th:first-child {
  z-index: 3;
}

@media (hover: hover) and (pointer: fine) {
  .vm-table tbody tr:hover > td {
    background: var(--vm-surface-2);
  }
}

/* For short reference tables whose cells hold long unbroken names. */
.vm-table-wrap td {
  overflow-wrap: anywhere;
  white-space: normal;
}

.vm-table tbody tr:last-child > td {
  border-bottom: 0;
}

.vm-table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  border-top: 2px solid var(--vm-border);
  border-bottom: 0;
  background: var(--vm-surface-2);
  font-weight: 700;
}

.vm-table tfoot td:first-child {
  z-index: 3;
}

.vm-rt-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  white-space: nowrap;
}

.vm-rt-sort .icon {
  opacity: .5;
}

[aria-sort] > .vm-rt-sort {
  color: var(--vm-text);
}

[aria-sort] > .vm-rt-sort .icon {
  color: var(--vm-primary-ink);
  opacity: 1;
}

.vm-table th.is-money .vm-rt-sort,
.vm-table th.is-count .vm-rt-sort,
.vm-table th.is-code .vm-rt-sort {
  flex-direction: row-reverse;
}

.vm-table .vm-rt-actions {
  width: 1%;
  padding-block: 4px;
  text-align: right;
}

.vm-table .vm-rt-actions .vm-iconbtn {
  width: 36px;
  height: 36px;
}

.vm-table .vm-rt-more {
  display: none;
}

.vm-rt-caption {
  margin: 0;
  color: var(--vm-text-muted);
}

.vm-table tr.vm-rt-group > th {
  background: var(--vm-primary-soft);
  color: var(--vm-primary-ink);
  font-weight: 700;
}

.vm-table tr.vm-rt-subtotal > td,
.vm-table tr.vm-rt-total > td {
  background: var(--vm-surface-2);
  font-weight: 600;
}

.vm-rt-meter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.vm-rt-bar {
  width: 80px;
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--vm-surface-2);
  overflow: hidden;
  appearance: none;
}

.vm-rt-bar::-webkit-progress-bar {
  background: var(--vm-surface-2);
}

.vm-rt-bar::-webkit-progress-value {
  border-radius: 999px;
  background: var(--vm-chart);
}

.vm-rt-bar::-moz-progress-bar {
  border-radius: 999px;
  background: var(--vm-chart);
}

.vm-rt-bar-value {
  min-width: 3ch;
  color: var(--vm-text-muted);
  font-size: 13px;
  text-align: right;
}

.vm-rt-nomatch td {
  padding: 32px 16px;
  color: var(--vm-text-muted);
  text-align: center;
  white-space: normal;
}

.vm-menu-danger,
.vm-menu-danger:focus-visible {
  color: var(--vm-danger-ink);
}

@media (hover: hover) and (pointer: fine) {
  .vm-menu-danger:hover {
    color: var(--vm-danger-ink);
  }
}

.vm-rt-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.vm-rt-summary[hidden],
.vm-rt-pager[hidden] {
  display: none;
}

.vm-rt-range {
  min-width: 150px;
  color: var(--vm-text-muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

@media (pointer: coarse) {
  .vm-table .vm-rt-actions .vm-iconbtn {
    width: 44px;
    height: 44px;
  }
}

/* Finger-sized targets on a phone, whatever the size class of the button (WCAG 2.5.8 asks for 24px, the platforms for 44). */
@media (max-width: 767.98px) {
  .btn,
  .vm-iconbtn {
    min-width: 44px;
    min-height: 44px;
  }

  /* The extra height would otherwise sit under the label of an inline-block button. */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ---- Editable lists (inventory, products) ---- */

.vm-edit-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vm-space-3);
  margin-bottom: var(--vm-space-3);
}

.vm-edit-controls > div {
  flex: 0 1 280px;
}

.vm-edit-controls > div:nth-child(2) {
  flex-basis: 160px;
}

.vm-inventory-filter {
  align-self: flex-end;
  margin-left: auto;
}

.vm-inventory-filter .form-label {
  display: block;
}

.vm-inventory-filter .vm-seg-btn {
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  .vm-inventory-filter {
    flex: 1 1 100%;
    margin-left: 0;
  }

  .vm-inventory-filter .vm-seg {
    display: flex;
  }

  /* Bulgarian labels are longer, so the buttons share the row and wrap instead of widening the page. */
  .vm-inventory-filter .vm-seg-btn {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding-inline: 8px;
    white-space: normal;
    text-align: center;
  }
}

.vm-edit-status {
  align-self: center;
  margin: 0;
  color: var(--vm-text-muted);
  font-size: 14px;
}

.vm-edit-table th,
.vm-edit-table td {
  padding: 6px 8px;
}

.vm-edit-table .form-control,
.vm-edit-table .form-select {
  min-width: 80px;
}

.vm-edit-table td.is-stack .form-select,
.vm-edit-table td.is-stack .form-control {
  min-width: 180px;
}

.vm-stepper {
  display: inline-flex;
}

.vm-stepper .btn {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  padding-inline: 8px;
}

@media (max-width: 767.98px) {
  .vm-stepper .btn {
    min-width: 44px;
  }
}

.vm-stepper .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.vm-stepper .btn:last-child {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.vm-stepper .form-control {
  width: 76px;
  min-width: 0;
  margin-inline: -1px;
  border-radius: 0;
  text-align: center;
}

/* Save stays in reach at the end of a long list. */
.vm-edit-actions {
  position: sticky;
  bottom: 0;
  z-index: 4;
  padding: 10px 0;
  background: var(--vm-bg);
}

/* Products with sales: a stripe, not a fill, as most rows of a long-running shop have one. */
.vm-row-used > :first-child {
  box-shadow: inset 3px 0 0 var(--vm-warning-ink);
}

/* One card per row: title and amount on the first line, then label/value lines. */
@media (max-width: 767.98px) {
  .vm-rt-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vm-rt-stat {
    padding: 12px 14px;
  }

  .vm-rt-stat:has(.vm-rt-split) {
    grid-column: 1 / -1;
  }

  .vm-rt-stat-value {
    font-size: 18px;
  }

  .vm-rt-search {
    flex-basis: 100%;
    max-width: none;
  }

  .vm-rt-sortbar {
    display: flex;
    flex: 1 1 auto;
  }

  .vm-rt-count {
    flex-basis: 100%;
    order: 5;
  }

  .vm-rt-tools {
    margin-left: 0;
  }

  .vm-rt-scroll {
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: none;
  }

  .vm-rt .vm-table,
  .vm-rt .vm-table tbody,
  .vm-rt .vm-table tfoot {
    display: flex;
    flex-direction: column;
    gap: var(--vm-space-2);
  }

  .vm-rt .vm-table thead {
    display: none;
  }

  /* Totals come first on a phone, where the list is long and has no sticky footer. */
  .vm-rt .vm-table tfoot {
    order: -1;
  }

  .vm-rt .vm-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    column-gap: var(--vm-space-3);
    padding: 12px 14px;
    border: 1px solid var(--vm-border);
    border-radius: var(--vm-radius-card);
    background: var(--vm-surface);
    box-shadow: var(--vm-shadow);
  }

  .vm-rt .vm-table td {
    display: flex;
    grid-column: 1 / -1;
    justify-content: space-between;
    gap: var(--vm-space-3);
    position: static;
    padding: 3px 0;
    border: 0;
    background: none;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .vm-rt .vm-table td::before {
    content: attr(data-label);
    flex: none;
    max-width: 50%;
    color: var(--vm-text-muted);
    font-weight: 500;
    text-align: left;
  }

  .vm-rt .vm-table td.is-empty,
  .vm-rt .vm-table tbody td.is-zero:not(.is-amount),
  .vm-rt .vm-table tr:not(.is-open) > td.is-detail {
    display: none;
  }

  .vm-rt .vm-table td.vm-rt-more {
    display: block;
    margin-top: 2px;
    text-align: left;
  }

  .vm-rt .vm-table td.vm-rt-more::before {
    content: none;
  }

  .vm-rt-more .btn {
    padding: 4px 0;
  }

  .vm-rt .vm-table :is(td, th).is-title,
  .vm-rt .vm-table td.is-amount,
  .vm-rt .vm-table td.is-subtitle,
  .vm-rt .vm-table td.vm-rt-actions {
    display: block;
  }

  .vm-rt .vm-table :is(td, th).is-title::before,
  .vm-rt .vm-table td.is-amount::before,
  .vm-rt .vm-table td.is-subtitle::before,
  .vm-rt .vm-table td.vm-rt-actions::before {
    content: none;
  }

  .vm-rt .vm-table :is(td, th).is-title {
    position: static;
    padding: 0;
    border: 0;
    background: none;
    grid-row: 1;
    grid-column: 1;
    align-self: center;
    font-size: 16px;
    font-weight: 600;
    text-align: left;
  }

  .vm-rt .vm-table td.is-amount {
    grid-row: 1;
    grid-column: 2;
    align-self: center;
    font-size: 17px;
    font-weight: 700;
  }

  .vm-rt .vm-table td.vm-rt-actions {
    grid-row: 1;
    grid-column: 3;
    width: auto;
    margin: -8px -8px -8px 0;
    padding: 0;
  }

  .vm-rt .vm-table td.is-subtitle {
    grid-row: 2;
    margin-bottom: 6px;
    color: var(--vm-text-muted);
    font-size: 13px;
    text-align: left;
  }

  @media (hover: hover) and (pointer: fine) {
    .vm-rt .vm-table tr:hover > td {
      background: none;
    }
  }

  .vm-rt .vm-edit-table td {
    align-items: center;
  }

  .vm-rt .vm-edit-table td > .form-control,
  .vm-rt .vm-edit-table td > .form-select {
    width: 55%;
    min-width: 0;
  }

  .vm-rt .vm-edit-table td.is-stack {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .vm-rt .vm-edit-table td.is-stack > .form-control,
  .vm-rt .vm-edit-table td.is-stack > .form-select {
    width: 100%;
  }

  .vm-rt .vm-table tr.vm-row-used {
    box-shadow: inset 3px 0 0 var(--vm-warning-ink), var(--vm-shadow);
  }

  .vm-rt .vm-table tr.vm-row-used > :first-child {
    box-shadow: none;
  }

  .vm-edit-actions {
    bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .vm-rt .vm-table tr.vm-rt-group {
    display: block;
    padding: 12px 2px 0;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .vm-rt .vm-table tr.vm-rt-group > th {
    display: block;
    position: static;
    padding: 0;
    border: 0;
    background: none;
    color: var(--vm-text);
    font-size: 16px;
  }

  .vm-rt .vm-table tr.vm-rt-subtotal,
  .vm-rt .vm-table tr.vm-rt-total {
    background: var(--vm-surface-2);
  }

  .vm-rt .vm-rt-nomatch {
    display: block;
  }

  .vm-rt .vm-rt-nomatch td {
    display: block;
    text-align: center;
  }

  .vm-rt .vm-rt-nomatch td::before {
    content: none;
  }

  .vm-rt-pager .vm-iconbtn {
    border: 1px solid var(--vm-border);
    background: var(--vm-surface);
  }

  .vm-rt-range {
    flex: 1;
    min-width: 0;
  }
}

/* ---- Top bar menus ---- */

.vm-notice {
  align-items: flex-start;
  white-space: normal;
}

/* ---- Sign-in ---- */

.vm-auth {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: calc(100vh - 50px);
}

.vm-auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--vm-space-3);
  padding: 48px 64px;
  background: var(--vm-primary-soft);
  color: var(--vm-primary-ink);
}

.vm-auth-brand-name {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.vm-auth-brand-text {
  max-width: 360px;
  margin: 0;
  font-size: 17px;
}

.vm-auth-panel {
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.vm-auth-lang {
  display: flex;
  justify-content: flex-end;
  gap: var(--vm-space-2);
}

.vm-auth-lang [aria-current="true"] {
  border-color: var(--vm-primary-ink);
  color: var(--vm-primary-ink);
  font-weight: 600;
}

.vm-auth-card {
  display: flex;
  flex-direction: column;
  gap: var(--vm-space-4);
  width: 100%;
  max-width: 400px;
  margin: auto;
  padding: 32px 0;
}

.vm-form {
  display: flex;
  flex-direction: column;
  gap: var(--vm-space-4);
}

.vm-field .form-control {
  min-height: 44px;
}

/* A page made of one form: its cards stack like the cards of a page; a fieldset lets a read-only role disable them all. */
.vm-form-stack,
.vm-form-stack > fieldset {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.vm-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--vm-space-4);
}

.vm-fields > .vm-field-wide {
  grid-column: 1 / -1;
}

@media (max-width: 767.98px) {
  .vm-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A single-form card (password change) is as wide as the sign-in card. */
.vm-card-narrow {
  width: 100%;
  max-width: 440px;
}

.vm-field-required {
  color: var(--vm-danger-ink);
}

.vm-password {
  position: relative;
}

.vm-password .form-control {
  padding-right: 52px;
}

.vm-password .vm-iconbtn {
  position: absolute;
  top: 0;
  right: 0;
}

[data-password-toggle][aria-pressed="false"] .vm-when-shown,
[data-password-toggle][aria-pressed="true"] .vm-when-hidden {
  display: none;
}

.vm-messages {
  display: flex;
  flex-direction: column;
  gap: var(--vm-space-2);
  max-width: 1360px;
  margin: 0 auto var(--vm-space-4);
}

.vm-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
}

.vm-auth-note {
  display: flex;
  gap: 6px;
  font-size: 13px;
}

@media (max-width: 1180px) {
  .vm-grid-kpi {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vm-grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 767.98px) {
  .vm-h1 {
    font-size: 22px;
  }

  .vm-kpi {
    padding: 14px;
  }

  .vm-kpi-value {
    font-size: 20px;
  }

  /* The comparison wraps to several lines in a half-width card; keep the arrow on the first. */
  .vm-kpi-foot {
    align-items: flex-start;
  }

  .vm-kpi-foot .icon {
    margin-top: 2px;
  }

  .vm-kpi-icon {
    display: none;
  }

  .vm-chart {
    padding: 8px 12px 16px;
  }

  /* The brand strip keeps its own height; the spare height goes to the form, not split between them. */
  .vm-auth {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .vm-auth-brand {
    flex-direction: row;
    align-items: center;
    padding: 16px 20px;
  }

  .vm-auth-brand img {
    width: 36px;
    height: 36px;
  }

  .vm-auth-brand-name {
    font-size: 20px;
  }

  .vm-auth-brand-text {
    display: none;
  }

  .vm-auth-card {
    padding: 16px 0;
  }

  .vm-toasts {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: 12px;
    max-width: none;
  }

  .vm-actions > .btn {
    flex: 1 1 calc(50% - var(--vm-space-2));
  }
}

@media (pointer: coarse) {
  .vm-seg-btn,
  .vm-nav-item,
  .vm-menu-item {
    min-height: 44px;
  }

  .vm-chart-table summary {
    padding: 12px 0;
  }
}

/* ---- Motion ---- */

/* Bootstrap slides the dialog down 50px; a small scale reads better and stays centred.
   Under reduced motion tokens.css removes the movement instead. */
@media (prefers-reduced-motion: no-preference) {
  .modal.fade .modal-dialog {
    transform: scale(.97);
    opacity: 0;
    transition:
      transform var(--vm-dur-base) var(--vm-ease-out),
      opacity var(--vm-dur-base) var(--vm-ease-out);
  }

  .modal.show .modal-dialog {
    transform: none;
    opacity: 1;
  }

  .modal.modal-static .modal-dialog {
    transform: scale(1.02);
  }
}

/* Phone: dialogs are bottom sheets. The full-screen dialogs (modal-fullscreen-sm-down) keep their layout. */
@media (max-width: 575.98px) {
  .modal {
    overscroll-behavior: contain;
  }

  .modal-dialog:not(.modal-fullscreen-sm-down) {
    display: flex;
    align-items: flex-end;
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    margin: 0;
  }

  .modal-dialog:not(.modal-fullscreen-sm-down) .modal-content {
    position: relative;
    width: 100%;
    max-height: 90dvh;
    padding-bottom: env(safe-area-inset-bottom);
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
  }

  .modal-dialog:not(.modal-fullscreen-sm-down) .modal-content::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--vm-border);
    translate: -50% 0;
  }

  .modal-dialog:not(.modal-fullscreen-sm-down) .modal-header {
    padding-top: 22px;
    /* The header carries the grab handle, so the browser must not turn a drag on it into a scroll. */
    touch-action: none;
  }

  .modal-dialog:not(.modal-fullscreen-sm-down) .modal-body {
    overflow-y: auto;
  }

  .modal.fade .modal-dialog:not(.modal-fullscreen-sm-down),
  .modal.show .modal-dialog:not(.modal-fullscreen-sm-down) {
    transform: none;
  }

  /* Under reduced motion the sheet only fades in. */
  @media (prefers-reduced-motion: no-preference) {
    /* Bootstrap ends the closing by the transition of .modal itself, so it must last as long as the slide. */
    .modal.fade {
      transition: opacity var(--vm-dur-drawer) linear;
    }

    .modal.fade .modal-dialog:not(.modal-fullscreen-sm-down) {
      transform: translateY(100%);
      transition:
        transform var(--vm-dur-drawer) var(--vm-ease-drawer),
        opacity var(--vm-dur-drawer) var(--vm-ease-drawer);
    }

    .modal.show .modal-dialog:not(.modal-fullscreen-sm-down) {
      transform: none;
    }
  }
}

#dashboard-body.htmx-request {
  opacity: .6;
  transition: opacity var(--vm-dur-fast) ease;
}

.vm-grid-kpi > .vm-card {
  transition:
    opacity var(--vm-dur-base) var(--vm-ease-out),
    translate var(--vm-dur-base) var(--vm-ease-out);
}

.vm-grid-kpi > .vm-card:nth-child(2) { transition-delay: 30ms; }
.vm-grid-kpi > .vm-card:nth-child(3) { transition-delay: 60ms; }
.vm-grid-kpi > .vm-card:nth-child(4) { transition-delay: 90ms; }

@starting-style {
  .vm-grid-kpi > .vm-card {
    opacity: 0;
    translate: 0 var(--vm-enter-distance);
  }
}

/* The shimmer is a gradient that slides across the block, so it only moves a composited layer. */
.vm-skeleton {
  position: relative;
  height: 40px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--vm-skeleton);
}

.vm-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
  translate: -100% 0;
  animation: vm-shimmer 1.2s linear infinite;
}

[data-bs-theme="dark"] .vm-skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .08), transparent);
}

.vm-skeleton-rows {
  display: flex;
  flex-direction: column;
  gap: var(--vm-space-2);
  padding: var(--vm-space-4) 0;
}

@keyframes vm-shimmer {
  to {
    translate: 100% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vm-skeleton::after {
    animation: none;
  }
}

/* ---- Operations: confirm dialog, drawer, openable table rows ---- */

.vm-confirm .modal-header .vm-iconbtn,
.vm-drawer .modal-header .vm-iconbtn {
  margin-left: auto;
}

/* A question can open over a drawer, so its dialog and its backdrop sit above the drawer's. */
.vm-confirm {
  z-index: 1065;
}

.modal-backdrop.show ~ .modal-backdrop.show {
  --bs-backdrop-zindex: 1060;
}

.vm-confirm-details {
  margin-top: var(--vm-space-3);
}

.vm-confirm-details ul {
  margin: 0;
  padding-left: 1.25rem;
}

/* Side panel on a desktop; below 576px the phone sheet rules above apply unchanged. */
@media (min-width: 576px) {
  .vm-drawer .modal-dialog {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(28rem, 100vw);
    max-width: none;
    height: 100dvh;
    margin: 0;
  }

  .vm-drawer .modal-content {
    height: 100%;
    border-width: 0 0 0 1px;
    border-radius: 0;
    box-shadow: var(--vm-shadow-menu);
  }

  .vm-drawer .modal-body {
    overflow-y: auto;
  }

  .vm-drawer .modal-footer {
    padding-bottom: calc(var(--bs-modal-footer-padding-y, .75rem) + env(safe-area-inset-bottom));
  }

  @media (prefers-reduced-motion: no-preference) {
    /* Bootstrap ends the closing by the transition of .modal itself, so it must last as long as the slide. */
    .vm-drawer.fade {
      transition: opacity var(--vm-dur-drawer) linear;
    }

    .vm-drawer.fade .modal-dialog {
      transform: none;
      opacity: 1;
      translate: 100% 0;
      transition: translate var(--vm-dur-drawer) var(--vm-ease-drawer);
    }

    .vm-drawer.show .modal-dialog {
      translate: 0 0;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .vm-drawer.fade .modal-dialog {
      translate: none;
    }
  }
}

.vm-drawer-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--vm-space-2) var(--vm-space-4);
  margin: 0;
}

.vm-drawer-facts dt {
  color: var(--vm-text-muted);
  font-weight: 500;
}

.vm-drawer-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.vm-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--vm-space-2) var(--vm-space-4);
  margin: 0 0 var(--vm-space-4);
}

.vm-facts dt {
  color: var(--vm-text-muted);
  font-weight: 500;
}

.vm-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* The settings page: links to its sections, and a section made of several cards. */
.vm-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vm-space-2) var(--vm-space-4);
}

.vm-section-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--vm-primary-ink);
  font-weight: 500;
}

.vm-section,
.vm-section-body {
  display: flex;
  flex-direction: column;
  gap: var(--vm-space-4);
}

.vm-section {
  scroll-margin-top: var(--vm-space-4);
}

.vm-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.vm-fieldset > legend {
  float: none;
  width: auto;
  margin-bottom: var(--vm-space-1);
  padding: 0;
  font-size: inherit;
}

.vm-choices {
  display: flex;
  flex-direction: column;
  gap: var(--vm-space-2);
}

.vm-select-inline {
  width: auto;
  min-width: 180px;
  min-height: 44px;
}

.vm-drawer-section {
  margin-top: var(--vm-space-4);
  padding-top: var(--vm-space-4);
  border-top: 1px solid var(--vm-border);
}

.vm-drawer-section > .vm-field-label {
  display: block;
  margin-bottom: var(--vm-space-2);
}

/* The title of an openable row is a button that reads as the row's name. */
.vm-rt-open {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--vm-primary-ink);
  font: inherit;
  font-weight: 600;
  text-align: inherit;
  cursor: pointer;
}

.vm-rt-open:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--vm-primary-ink);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .vm-rt-open:hover {
    text-decoration: underline;
  }
}

.vm-rt-flag {
  display: inline-flex;
  margin-left: 6px;
  color: var(--vm-warning-ink);
  vertical-align: middle;
}

.vm-rt-empty td {
  padding: 0;
  white-space: normal;
}

@media (max-width: 767.98px) {
  .vm-rt .vm-table tr.is-activatable {
    cursor: pointer;
  }
}

/* A menu action that cannot be used stays in the tab order, so its reason can be read. */
.vm-menu-item[aria-disabled="true"] {
  color: var(--vm-text-muted);
  cursor: not-allowed;
}

/* The confirm message keeps the paragraph breaks of the text it is given. */
.vm-confirm #vm-confirm-message {
  white-space: pre-line;
}

/* The phone layout gives rows display: grid, which would show a row the filter hid. */
.vm-rt .vm-edit-table tr[hidden] {
  display: none;
}
