/* =============================================================================
   App components.

   The six standing decisions in docs/design-system.md §7 need something to
   replace what they retire. This file is that replacement. It is linked on
   every page by _head_css.cshtml, after the identity, with its script in
   _vendor_scripts.cshtml; no view links either itself.

   Rules it holds itself to:
     * every colour is an --app-* token, so both themes come free;
     * no gradients anywhere, including the loading shimmer;
     * every rule is class-based, so load order against Bootstrap cannot decide
       who wins, and it must not depend on coming last.
   ========================================================================== */

/* -----------------------------------------------------------------------------
   1. Modal — replaces Bootstrap's .modal

   Scroll lock is the detail that gives a hand-rolled modal away: hiding the
   page's scrollbar reclaims its width and every fixed element jumps. The width
   is measured in JS and paid back as padding, so nothing moves.

   Stack order, bottom to top — each layer can be opened FROM the one below it:
     1080  .app-modal          the modal and its scrim
     1090  .app-select__popup  a dropdown inside a modal must cover the modal
     1095  .swal2-container    a SweetAlert raised from inside an App modal
     1100  .app-toaster        a toast reports on whatever is open, so it is
                               never hidden behind the thing it reports on
   -------------------------------------------------------------------------- */
.app-modal {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--app-space-4);
}

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

.app-modal__scrim {
  position: absolute;
  inset: 0;
  /* Flat, not a vignette — the no-gradient rule applies to scrims too. Not
     --app-scrim: that one is the loading screen's light veil. The fallback is
     built from a palette primitive, so it stays dark in both themes. */
  background-color: var(--app-modal-scrim, rgba(var(--app-gray-900-rgb), 0.55));
  animation: app-fade 0.16s var(--app-ease);
}

.app-modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: calc(100vh - var(--app-space-8));
  background-color: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-lg);
  animation: app-rise 0.18s var(--app-ease);
}

/* The panel takes tabindex="-1" as the fallback focus target of a modal with
   nothing focusable in it; the ring would outline the whole panel for no gain. */
.app-modal__panel:focus {
  outline: none;
}

.app-modal__panel--wide {
  width: min(840px, 100%);
}

/* The tone strip says what the modal is for, in the same colours as the row
   action that opened it (section 4): adding is green, editing the Accent
   (Bootstrap's "warning" button), deleting or stopping red, viewing the brand.
   App.Modal.open({ tone }) sets it, with the title's icon and the colour of the
   primary button. The old modals carried a full gradient header for this;
   three pixels of solid colour say the same thing and leave the title legible
   as ink. */
.app-modal__panel::before {
  content: "";
  display: block;
  height: 3px;
  background-color: var(--app-tone, var(--app-brand));
  border-radius: var(--app-radius-lg) var(--app-radius-lg) 0 0;
}

.app-modal__panel--add {
  --app-tone: var(--app-success);
}
.app-modal__panel--edit {
  --app-tone: var(--app-accent);
}
.app-modal__panel--danger {
  --app-tone: var(--app-danger);
}

.app-modal__head {
  display: flex;
  align-items: center;
  gap: var(--app-space-3);
  padding: var(--app-space-4);
  border-bottom: 1px solid var(--app-line);
}

.app-modal__title {
  display: flex;
  align-items: center;
  gap: var(--app-space-2);
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--app-text-subtitle);
  line-height: var(--app-text-subtitle-lh);
  font-weight: var(--app-weight-semibold);
  color: var(--app-ink-strong);
}

.app-modal__title i {
  color: var(--app-tone, var(--app-brand-ink));
}

.app-modal__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--app-radius-md);
  background-color: transparent;
  color: var(--app-ink-faint);
  cursor: pointer;
  transition:
    background-color 0.16s var(--app-ease),
    color 0.16s var(--app-ease);
}

.app-modal__close:hover {
  background-color: var(--app-surface-sunken);
  color: var(--app-ink);
}

/* A finger needs 44px; a mouse is happy with the compact 32px above. */
@media (pointer: coarse) {
  .app-modal__close {
    width: 44px;
    height: 44px;
  }
}

.app-modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--app-space-4);
  color: var(--app-ink);
  font-size: var(--app-text-body);
  line-height: var(--app-text-body-lh);
}

/* A modal whose head, body and foot sit inside a <form> (every data-structure-form
   modal): the form takes the panel's column, so a body taller than the screen
   scrolls inside it and the footer — the submit button — stays in view. Without
   it the form grew past the panel's max-height and the footer fell off a short
   screen (the operational plan's item modal, 16 Oct 2026). */
.app-modal__panel > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.app-modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--app-space-2);
  padding: var(--app-space-3) var(--app-space-4);
  border-top: 1px solid var(--app-line);
  background-color: var(--app-surface-sunken);
  border-radius: 0 0 var(--app-radius-lg) var(--app-radius-lg);
}

/* Set on <body> while any modal is open; the inline padding is written by JS. */
.app-scroll-locked {
  overflow: hidden;
}

@keyframes app-fade {
  from {
    opacity: 0;
  }
}

@keyframes app-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* -----------------------------------------------------------------------------
   2. Dialog & toast — replace SweetAlert2

   The dialog is the modal with a fixed body: an icon, a title, a line of text.
   The toast is not a modal at all — it takes no focus and blocks nothing, which
   is the entire reason a save confirmation should never be one.
   -------------------------------------------------------------------------- */
.app-dialog__panel {
  width: min(420px, 100%);
  text-align: center;
}

.app-dialog__body {
  padding: var(--app-space-6) var(--app-space-4) var(--app-space-4);
}

.app-dialog__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: var(--app-space-3);
  border-radius: var(--app-radius-full);
  font-size: 1.75rem;
  color: rgb(var(--app-dialog-rgb, var(--app-brand-ink-rgb)));
  background-color: rgba(var(--app-dialog-rgb, var(--app-brand-ink-rgb)), 0.14);
}

.app-dialog--success {
  --app-dialog-rgb: var(--app-success-rgb);
}
.app-dialog--danger {
  --app-dialog-rgb: var(--app-danger-rgb);
}
.app-dialog--warning {
  --app-dialog-rgb: var(--app-accent-rgb);
}

.app-dialog__title {
  margin: 0 0 var(--app-space-2);
  font-size: var(--app-text-h2);
  line-height: var(--app-text-h2-lh);
  font-weight: var(--app-weight-semibold);
  color: var(--app-ink-strong);
}

.app-dialog__text {
  margin: 0;
  color: var(--app-ink-muted);
}

.app-dialog__foot {
  justify-content: center;
}

.app-toaster {
  position: fixed;
  inset-block-start: var(--app-space-4);
  inset-inline-start: var(--app-space-4);
  z-index: 1100; /* above the select popup and SweetAlert — see section 1 */
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

/* The two live regions (polite and assertive) stack as one column. Not
   display: contents — older engines drop such an element from the
   accessibility tree, and a live region nobody can hear is no region at all. */
.app-toaster__region {
  display: flex;
  flex-direction: column;
  gap: var(--app-space-2);
}

.app-toaster__region:not(:empty) + .app-toaster__region:not(:empty) {
  margin-top: var(--app-space-2);
}

/* SweetAlert can still be raised from inside an App modal while screens are
   converted; its default 1060 would open it underneath. See section 1. */
.swal2-container {
  z-index: 1095;
}

.app-toast {
  display: flex;
  align-items: center;
  gap: var(--app-space-2);
  min-width: 260px;
  max-width: 380px;
  padding: var(--app-space-3) var(--app-space-4);
  border: 1px solid var(--app-line);
  border-inline-start: 3px solid
    rgb(var(--app-dialog-rgb, var(--app-brand-ink-rgb)));
  border-radius: var(--app-radius-md);
  background-color: var(--app-surface);
  box-shadow: var(--app-shadow-md);
  color: var(--app-ink);
  font-size: var(--app-text-body);
  pointer-events: auto;
  animation: app-toast-in 0.2s var(--app-ease);
}

.app-toast i {
  color: rgb(var(--app-dialog-rgb, var(--app-brand-ink-rgb)));
  font-size: 1.1rem;
}

.app-toast--out {
  animation: app-toast-out 0.18s var(--app-ease) forwards;
}

@keyframes app-toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes app-toast-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* -----------------------------------------------------------------------------
   3. Searchable select — replaces the bare <select>

   The native element stays in the DOM and keeps carrying the value, so forms,
   validation and model binding are untouched; this is only a face over it.
   -------------------------------------------------------------------------- */
.app-select {
  position: relative;
}

/* Out of sight, still in the DOM, still the element carrying the value.
   `opacity: 0` alone was not enough and the gap showed only on DISABLED
   selects: Bootstrap's reboot ships `select:disabled { opacity: 1 }`, which at
   (0,1,1) outranks a single class, so the bare <select> came back at full size
   and drew its own chevron and text across the face of the control. The clip
   is what actually hides it now — nothing else in the app sets clip-path — and
   the zeroed box is what keeps it a real 1×1: a border-box element cannot
   shrink below its own padding, and .form-select carries a min-height from the
   identity, so width/height on their own were being floored at ~60×40. */
.app-select__native {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  opacity: 0;
  pointer-events: none;
}

.app-select__control {
  display: flex;
  align-items: center;
  gap: var(--app-space-2);
  width: 100%;
  min-height: var(--app-control-height);
  padding: var(--app-space-2) var(--app-space-3);
  border: 1px solid var(--app-line-strong);
  border-radius: var(--app-radius-md);
  background-color: var(--app-surface);
  color: var(--app-ink);
  font-family: inherit;
  font-size: var(--app-text-body);
  text-align: start;
  cursor: pointer;
  transition:
    border-color 0.16s var(--app-ease),
    box-shadow 0.16s var(--app-ease);
}

.app-select__control:hover:not(:disabled) {
  border-color: var(--app-brand-ink);
}

/* The outline is the identity's own :focus-visible ring, restated because the
   box-shadow halo alone vanishes in forced-colors mode — a shadow is not drawn
   there, an outline is. */
.app-select__control:focus-visible {
  outline: 2px solid var(--app-brand-ink);
  outline-offset: 2px;
  border-color: var(--app-brand-ink);
  box-shadow: var(--app-focus-ring);
}

.app-select.is-invalid .app-select__control {
  border-color: var(--tb-form-invalid-border-color, var(--tb-danger));
}

.app-select.is-open .app-select__control {
  border-color: var(--app-brand-ink);
  box-shadow: var(--app-focus-ring);
}

/* Multiple: the chips and the control share one bordered field. The chips are
   the control's SIBLINGS, not its children — a remove button nested inside the
   opening button is invalid HTML and unreachable by keyboard. */
.app-select__field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--app-space-1);
  min-height: var(--app-control-height);
  padding: 0.2rem var(--app-space-2);
  border: 1px solid var(--app-line-strong);
  border-radius: var(--app-radius-md);
  background-color: var(--app-surface);
  transition:
    border-color 0.16s var(--app-ease),
    box-shadow 0.16s var(--app-ease);
}

.app-select__field:hover {
  border-color: var(--app-brand-ink);
}

.app-select.is-open .app-select__field {
  border-color: var(--app-brand-ink);
  box-shadow: var(--app-focus-ring);
}

.app-select__field .app-select__control {
  flex: 1;
  width: auto;
  min-width: 6rem;
  min-height: 0;
  padding: var(--app-space-1);
  border: 0;
  background-color: transparent;
  box-shadow: none;
}

.app-select__field .app-select__control:focus-visible {
  outline-offset: 0;
  box-shadow: none;
}

.app-select__field:has(.app-select__control:disabled) {
  background-color: var(--app-surface-sunken);
}

.app-select__chips {
  display: contents;
}

.app-select__control:disabled {
  background-color: var(--app-surface-sunken);
  color: var(--app-ink-faint);
  cursor: not-allowed;
}

.app-select__value {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--app-space-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-select__value--empty {
  color: var(--app-ink-faint);
}

.app-select__caret {
  flex: none;
  color: var(--app-ink-faint);
  font-size: 0.8rem;
  transition: transform 0.16s var(--app-ease);
}

.app-select.is-open .app-select__caret {
  transform: rotate(180deg);
}

.app-select__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  max-width: 100%;
  padding: 0.05rem 0.4rem;
  border-radius: var(--app-radius-sm);
  background-color: var(--app-brand-soft);
  color: var(--app-brand-ink);
  font-size: var(--app-text-caption);
}

/* 24px is the WCAG 2.2 minimum target; the × glyph alone was about 10px. */
.app-select__chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  border: 0;
  border-radius: var(--app-radius-sm);
  padding: 0;
  background: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.16s var(--app-ease);
}

.app-select__chip-remove:hover {
  background-color: rgba(var(--app-brand-ink-rgb), 0.14);
}

.app-select__chip-remove:focus-visible {
  outline: 2px solid var(--app-brand-ink);
  outline-offset: 1px;
}

/* Fixed and placed by the script, not absolute inside .app-select.

   An absolutely positioned popup is clipped by the nearest scrolling ancestor,
   and .app-modal__body is one — every select in a modal had its list cut off
   at the footer, with the options below the cut unreachable. Fixed escapes
   every overflow and every stacking context on the way up; the price is that
   the coordinates have to be measured, which Select.position() does on open and
   again on scroll and resize. Left/top/width are always written by JS. */
.app-select__popup {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1090; /* above the modal it may sit in — see section 1 */
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-md);
  background-color: var(--app-surface);
  box-shadow: var(--app-shadow-md);
  overflow: hidden;
}

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

/* State only — the script carries the geometry. Kept as a hook so a screen can
   tell an upward list from a downward one without re-measuring. */
.app-select__popup--up {
  transform-origin: bottom;
}

.app-select__search {
  display: flex;
  align-items: center;
  gap: var(--app-space-2);
  padding: var(--app-space-2) var(--app-space-3);
  border-bottom: 1px solid var(--app-line);
  color: var(--app-ink-faint);
}

/* The row carries the ring for the input inside it: an outline on the bare
   input would hug the text and leave the icon outside it. Inset, because the
   popup clips its overflow. */
.app-select__search:focus-within {
  outline: 2px solid var(--app-brand-ink);
  outline-offset: -2px;
}

.app-select__input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  background: none;
  color: var(--app-ink);
  font-family: inherit;
  font-size: var(--app-text-body);
}

/* Transparent rather than none: the row above shows the ring, and in
   forced-colors mode a transparent outline is painted in the system colour. */
.app-select__input:focus {
  outline: 2px solid transparent;
}

.app-select__list {
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: var(--app-space-1);
  list-style: none;
}

.app-select__option {
  display: flex;
  align-items: center;
  gap: var(--app-space-2);
  padding: var(--app-space-2) var(--app-space-3);
  border-radius: var(--app-radius-sm);
  color: var(--app-ink);
  font-size: var(--app-text-body);
  cursor: pointer;
}

/* "الكل" — or an optional field's «بلا …» — is not one of the choices, it is
   the absence of one, so it sits above the list with a rule under it rather
   than pretending to be the first name. */
.app-select__option--all {
  color: var(--app-ink-muted);
  border-bottom: 1px solid var(--app-line);
}

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

/* Keyboard cursor and pointer hover are the same state on purpose: two
   different highlights in one list is the fastest way to lose your place. */
.app-select__option.is-active {
  background-color: var(--app-surface-sunken);
}

.app-select__option.is-selected {
  color: var(--app-brand-ink);
  font-weight: var(--app-weight-medium);
}

.app-select__option.is-selected::after {
  content: "\f26e"; /* bootstrap-icons check-lg */
  font-family: bootstrap-icons;
  margin-inline-start: auto;
  font-size: 0.85rem;
}

.app-select__option[aria-disabled="true"] {
  color: var(--app-ink-faint);
  cursor: not-allowed;
}

.app-select__empty {
  padding: var(--app-space-4);
  text-align: center;
  color: var(--app-ink-faint);
  font-size: var(--app-text-body);
}

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

/* -----------------------------------------------------------------------------
   4. Row action — the squared, icon-only successor to .btn-action

   Same --action-rgb contract, so the semantic variants port across unchanged.
   The only real change is geometry: a square, because there is no label left to
   pad around.

   THE COLOUR IS THE MEANING, on every screen — pick the variant by what the
   button does, never by what looks good in the row:
     --view / --open      brand   look at it, go into it
     --add / --enable     green   create, activate, unblock
     --edit               Accent  change it (Bootstrap's "warning" button)
     --delete / --remove  red     delete, and --disable: deactivate, block, end
     --print              ink     print, export
   The modal a row action opens carries the same tone (section 1). A row action
   is never a grey .btn-light: DesignSystemParityTests fails on one.
   -------------------------------------------------------------------------- */
.app-action {
  --action-rgb: var(--app-ink-rgb);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--app-radius-sm);
  font-size: 0.95rem;
  line-height: 1;
  /* --action-ink when the variant needs a deeper label than its fill: the
     Accent is 2.3:1 on its own tint, its ink 6.1:1. */
  color: var(--action-ink, rgb(var(--action-rgb)));
  background-color: rgba(var(--action-rgb), 0.12);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
  transition:
    background-color 0.16s var(--app-ease),
    color 0.16s var(--app-ease);
}

/* Both spellings of "off", because both shapes are legitimate here: a row action
   that navigates is an <a> and can only carry the class, one that acts is a
   <button> and carries the attribute. Styling only the class left every disabled
   button looking live. */
.app-action:hover:not(.disabled):not(:disabled),
.app-action:focus-visible:not(.disabled):not(:disabled) {
  /* --app-on-brand when the identity defines it; the light surface is the same
     white today, and the dark theme overrides this colour below regardless. */
  color: var(--app-on-brand, var(--app-surface));
  background-color: rgb(var(--action-rgb));
}

/* A finger needs 44px; the 30px square stays for pointer devices, where a
   row of them has to fit in a table cell. */
@media (pointer: coarse) {
  .app-action {
    width: 44px;
    height: 44px;
  }
}

.app-action.disabled,
.app-action:disabled {
  color: var(--app-ink-faint);
  background-color: var(--app-surface-sunken);
  cursor: not-allowed;
}

/* Waiting on its request (app-base.js): disabled, but still its own colour —
   greyed out it would read as refused rather than working. */
.app-action.is-busy:disabled {
  color: var(--action-ink, rgb(var(--action-rgb)));
  background-color: rgba(var(--action-rgb), 0.12);
}
.app-action.is-busy::before {
  margin: 0;
}

.app-action--view,
.app-action--open {
  --action-rgb: var(--app-brand-ink-rgb);
}
.app-action--edit {
  --action-rgb: var(--app-accent-rgb);
  --action-ink: var(--app-accent-ink);
}
.app-action--add,
.app-action--enable {
  /* The ink step, not the fill: the raw green label is 2.3:1 on its own 12% tint. */
  --action-rgb: var(--app-success-ink-rgb);
}
.app-action--delete,
.app-action--remove,
.app-action--disable {
  --action-rgb: var(--app-danger-ink-rgb);
}
.app-action--print {
  --action-rgb: var(--app-ink-rgb);
}

/* White on a dark-mode fill is unreadable; the hover colour flips to the canvas. */
[data-bs-theme="dark"] .app-action:hover:not(.disabled):not(:disabled),
[data-bs-theme="dark"] .app-action:focus-visible:not(.disabled):not(:disabled) {
  color: var(--app-canvas);
}

/* White is 2.6:1 on the orange Accent, so the edit action's filled state takes
   the Accent's own label instead — in both themes, since the orange never moves. */
.app-action--edit:hover:not(.disabled):not(:disabled),
.app-action--edit:focus-visible:not(.disabled):not(:disabled),
[data-bs-theme="dark"] .app-action--edit:hover:not(.disabled):not(:disabled),
[data-bs-theme="dark"]
  .app-action--edit:focus-visible:not(.disabled):not(:disabled) {
  color: var(--app-on-accent);
}

.app-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--app-space-1);
}

/* -----------------------------------------------------------------------------
   5. Skeleton — the same placeholder without the travelling gradient

   The old shimmer was a gradient sliding across the element, which the
   no-gradient rule retires. An opacity pulse on a solid fill reads as "not
   ready yet" just as well, costs one property instead of a moving background,
   and has an honest still frame when motion is turned off.
   -------------------------------------------------------------------------- */
.app-skeleton {
  background-color: var(--app-surface-sunken);
  border-radius: var(--app-radius-sm);
  animation: app-skeleton-pulse 1.4s ease-in-out infinite;
}

.app-skeleton--text {
  height: 0.85rem;
  margin-bottom: var(--app-space-2);
}

.app-skeleton--title {
  height: 1.25rem;
  width: 40%;
  margin-bottom: var(--app-space-3);
}

.app-skeleton--button {
  height: var(--app-control-height);
  width: 140px;
  border-radius: var(--app-radius-md);
}

.app-skeleton--circle {
  width: 40px;
  height: 40px;
  border-radius: var(--app-radius-full);
}

@keyframes app-skeleton-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

/* Spinner, for the cases where nothing about the shape of the content is known.

   One indeterminate indicator for the whole product. A bordered ring: a faint
   full track with one solid quarter as the head. It was a masked
   conic-gradient, which the no-gradient rule retires; the border ring's
   corner at small sizes is the accepted price.

   currentColor is the whole colour contract. Dropped into a .btn-primary it
   turns white, into a table cell it turns ink, and it needs no variant for the
   dark theme or for a coloured ground -- the track is currentColor at low
   opacity (color-mix), so it follows the ground as well.

   Sizes: default 20px, --sm 14px (inline, beside text), --lg 32px (a block that
   owns its area). A spinner that is the only thing on screen must carry an
   accessible name -- role="status" plus a visually-hidden label, or aria-label
   on the element -- or a screen reader announces nothing at all while the user
   waits. .app-loading below pairs it with that sentence. */
.app-spinner {
  --app-spinner-size: 20px;
  --app-spinner-track: 2px;
  display: inline-block;
  flex-shrink: 0;
  width: var(--app-spinner-size);
  height: var(--app-spinner-size);
  box-sizing: border-box;
  border: var(--app-spinner-track) solid;
  /* Track first as a fallback for engines without color-mix: a transparent
     track still leaves a readable spinning head. */
  border-color: transparent;
  border-color: color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: currentColor;
  border-radius: var(--app-radius-full);
  animation: app-spin 0.7s linear infinite;
}

.app-spinner--sm {
  --app-spinner-size: 14px;
  --app-spinner-track: 2px;
}

.app-spinner--lg {
  --app-spinner-size: 32px;
  --app-spinner-track: 3px;
}

/* The spinner with the sentence saying what is being waited for. A bare spinner
   tells the user that something is happening and never what, which is the
   difference between a wait and a stall. */
.app-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--app-space-3);
  padding: var(--app-space-8) var(--app-space-4);
  color: var(--app-ink-muted);
}

.app-loading--inline {
  display: inline-flex;
  gap: var(--app-space-2);
  padding: 0;
}

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

/* -----------------------------------------------------------------------------
   6. Roles picker — the restructured permissions menu

   What was wrong with the accordion, in order of severity: the "select all"
   control was a <button> nested inside the accordion's own <button>, which is
   invalid HTML and only worked through event.stopPropagation(); collapsing a
   group hid whether anything in it was selected; and with fifty-odd roles there
   was no way to find one by name.

   The replacement keeps groups but stops hiding them. Every group is open, its
   header is a row of real siblings, the counter is always visible, and one
   search field filters every group at once.
   -------------------------------------------------------------------------- */
.app-roles {
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-md);
  background-color: var(--app-surface);
  overflow: hidden;
}

.app-roles__bar {
  display: flex;
  align-items: center;
  gap: var(--app-space-3);
  flex-wrap: wrap;
  padding: var(--app-space-3) var(--app-space-4);
  border-bottom: 1px solid var(--app-line);
  background-color: var(--app-surface-sunken);
}

.app-roles__search {
  display: flex;
  align-items: center;
  gap: var(--app-space-2);
  flex: 1;
  min-width: 200px;
  padding: var(--app-space-2) var(--app-space-3);
  border: 1px solid var(--app-line-strong);
  border-radius: var(--app-radius-md);
  background-color: var(--app-surface);
  color: var(--app-ink-faint);
}

.app-roles__search:focus-within {
  border-color: var(--app-brand-ink);
  box-shadow: var(--app-focus-ring);
}

.app-roles__search input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  background: none;
  color: var(--app-ink);
  font-family: inherit;
  font-size: var(--app-text-body);
}

.app-roles__search input:focus {
  outline: none;
}

.app-roles__total {
  flex: none;
  font-size: var(--app-text-body);
  color: var(--app-ink-muted);
}

.app-roles__total b {
  color: var(--app-brand-ink);
  font-weight: var(--app-weight-semibold);
}

.app-roles__group {
  border-bottom: 1px solid var(--app-line);
}

.app-roles__group:last-child {
  border-bottom: 0;
}

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

.app-roles__head {
  display: flex;
  align-items: center;
  gap: var(--app-space-2);
  padding: var(--app-space-2) var(--app-space-4);
  background-color: var(--app-surface);
}

/* A real disclosure button that owns nothing but the twisty and the title —
   the group's other controls are its siblings, not its children. */
.app-roles__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--app-space-2);
  flex: 1;
  min-width: 0;
  padding: var(--app-space-2) 0;
  border: 0;
  background: none;
  color: var(--app-ink);
  font-family: inherit;
  font-size: var(--app-text-body);
  font-weight: var(--app-weight-medium);
  text-align: start;
  cursor: pointer;
}

.app-roles__toggle i {
  color: var(--app-ink-faint);
  font-size: 0.75rem;
  transition: transform 0.16s var(--app-ease);
}

.app-roles__toggle[aria-expanded="false"] i {
  transform: rotate(90deg);
}

.app-roles__count {
  flex: none;
  padding: 0.05rem 0.5rem;
  border-radius: var(--app-radius-full);
  background-color: var(--app-surface-sunken);
  color: var(--app-ink-muted);
  font-size: var(--app-text-caption);
  font-variant-numeric: tabular-nums;
}

.app-roles__count.is-full {
  background-color: var(--app-brand-soft);
  color: var(--app-brand-ink);
}

.app-roles__all {
  flex: none;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--app-line-strong);
  border-radius: var(--app-radius-sm);
  background: none;
  color: var(--app-ink-muted);
  font-family: inherit;
  font-size: var(--app-text-caption);
  cursor: pointer;
  transition:
    border-color 0.16s var(--app-ease),
    color 0.16s var(--app-ease);
}

.app-roles__all:hover {
  border-color: var(--app-brand-ink);
  color: var(--app-brand-ink);
}

.app-roles__body {
  display: grid;
  gap: var(--app-space-1);
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  padding: 0 var(--app-space-4) var(--app-space-3);
}

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

/* The whole row is the target: a 14px checkbox is a poor hit area, and fifty of
   them is fifty chances to miss. */
.app-roles__item {
  display: flex;
  align-items: center;
  gap: var(--app-space-2);
  padding: var(--app-space-2);
  border: 1px solid transparent;
  border-radius: var(--app-radius-sm);
  color: var(--app-ink-muted);
  font-size: var(--app-text-body);
  cursor: pointer;
}

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

.app-roles__item:hover {
  background-color: var(--app-surface-sunken);
}

.app-roles__item:has(input:checked) {
  border-color: var(--app-brand-border);
  background-color: var(--app-brand-soft);
  color: var(--app-brand-ink);
  font-weight: var(--app-weight-medium);
}

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

.app-roles__item input {
  flex: none;
  accent-color: var(--app-brand);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.app-roles__empty {
  padding: var(--app-space-6);
  text-align: center;
  color: var(--app-ink-faint);
}

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

/* -----------------------------------------------------------------------------
   7. Pagination — the flat active pill

   Opt-in with .app-pagination alongside .pagination, so the app's own paging is
   untouched until the gradient rule is applied for real.

   Worth recording why this one is easy to give up. The current active pill paints
   `linear-gradient(135deg, #006677, #33A7BA)` across a 30x30 box: two teals of
   near-identical luminance with 30px to travel. It is invisible — the element
   reads as flat teal already, and measuring it is what prompted this block. The
   coloured glow goes with it: the system has three shadow steps and none of them
   is a brand-tinted halo on a 30px control.
   -------------------------------------------------------------------------- */
.app-pagination .page-item.active .page-link {
  background-image: none;
  background-color: var(--app-brand);
  box-shadow: none;
}

/* The pager every paged list renders (Views/Shared/_Pager.cshtml): the row range at the
   start, the pages in the middle, the jump and the page size at the end. It wraps to
   stacked, centred rows on a narrow screen rather than scrolling sideways. */
.app-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--app-space-3) var(--app-space-4);
  margin-top: var(--app-space-4);
}

.app-pager__summary {
  margin: 0;
  color: var(--app-ink-muted);
  font-size: var(--app-text-caption);
}

.app-pager__pages {
  flex-wrap: wrap;
  justify-content: center;
  margin: 0;
}

.app-pager__gap .page-link {
  border-color: transparent;
  background: none;
}

.app-pager__tools,
.app-pager__jump,
.app-pager__size {
  display: flex;
  align-items: center;
  gap: var(--app-space-2);
}

.app-pager__tools {
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--app-space-3) var(--app-space-4);
}

.app-pager__label {
  color: var(--app-ink-muted);
  font-size: var(--app-text-caption);
  white-space: nowrap;
}

.app-pager__jump .form-control {
  width: 5rem;
  text-align: center;
}

.app-pager__size > :not(.app-pager__label) {
  min-width: 5.5rem;
}

@media (max-width: 767.98px) {
  .app-pager {
    flex-direction: column;
    justify-content: center;
  }
}

/* -----------------------------------------------------------------------------
   8. Facts — a record shown for reading, not for editing

   Every "details" modal in the app is the same shape: a record, in labelled
   groups, that the user came to read. They were all built the same wrong two
   ways. Either as a stack of Bootstrap cards inside the modal panel — a raised
   surface on a raised surface, each with its own gradient header — or, worse,
   as a column of `<input disabled>`: a field the user cannot type in reads as
   permission withheld, not as a value that was never editable.

   A fact is a term and its definition. It gets a caption-sized key, a body-sized
   value, and no box at all; the group heading and a hairline carry the grouping
   that a card was being used for. Nothing here is interactive, so nothing here
   is focusable, hoverable or shaped like a control.

   Inside a modal the FIRST group carries no __legend: the modal title already
   heads it, and "تفاصيل الطالب" above "معلومات الطالب" is one label twice. Only
   the groups the title does not name are labelled.
   -------------------------------------------------------------------------- */
.app-facts {
  display: flex;
  flex-direction: column;
  gap: var(--app-space-6);
}

.app-facts__legend {
  display: flex;
  align-items: center;
  gap: var(--app-space-2);
  margin: 0 0 var(--app-space-3);
  padding-bottom: var(--app-space-2);
  border-bottom: 1px solid var(--app-line);
  font-size: var(--app-text-subtitle);
  font-weight: var(--app-weight-semibold);
  color: var(--app-brand-ink);
}

/* auto-fit rather than a column count: the same grid holds a six-fact record
   and a two-fact one without either being told how wide it is. */
.app-facts__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--app-space-3) var(--app-space-6);
}

.app-fact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.app-fact--wide {
  grid-column: 1 / -1;
}

.app-fact__key {
  display: flex;
  align-items: center;
  gap: var(--app-space-1);
  font-size: var(--app-text-caption);
  color: var(--app-ink-muted);
}

.app-fact__val {
  font-size: var(--app-text-body);
  font-weight: var(--app-weight-medium);
  color: var(--app-ink);
  /* A long Arabic name or an address has to wrap somewhere; anywhere beats
     widening the grid column and pushing the next fact off the row. */
  overflow-wrap: anywhere;
}

/* "غير محدد" is the absence of a value, and printing it at the same weight as a
   real one makes an empty record look full. */
.app-fact__val--empty {
  font-weight: var(--app-weight-regular);
  color: var(--app-ink-faint);
}

/* A session is a day and a time read as one thing, so it is one chip rather than
   two facts that happen to sit next to each other. */
.app-slots {
  display: flex;
  flex-wrap: wrap;
  gap: var(--app-space-2);
}

.app-slot {
  display: inline-flex;
  align-items: center;
  gap: var(--app-space-2);
  padding: var(--app-space-2) var(--app-space-3);
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-md);
  background-color: var(--app-surface-sunken);
}

.app-slot__day {
  font-size: var(--app-text-caption);
  font-weight: var(--app-weight-semibold);
  color: var(--app-brand-ink);
}

.app-slot__time {
  font-size: var(--app-text-body);
  color: var(--app-ink);
  font-variant-numeric: tabular-nums;
}

/* -----------------------------------------------------------------------------
   9. Print preview

   The frame holds the server's own print document untouched, so nothing here
   styles its contents — only the window it is shown through. Wider than the
   wide panel because a preview the reader cannot read is not a preview.
   -------------------------------------------------------------------------- */
.app-print__panel {
  width: min(960px, 100%);
}

/* The caller's print preferences, between the caption and the document. The
   strip is the modal's, the fields are the caller's: it lays them out on one
   wrapping row and styles nothing inside beyond the small labels, so a caller
   uses the ordinary .btn-group / .form-check controls it already has. */
.app-print__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--app-space-2) var(--app-space-4);
  padding: var(--app-space-3) var(--app-space-4);
  border-bottom: 1px solid var(--app-line);
  background-color: var(--app-surface);
}

.app-print__control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.app-print__control > .form-label,
.app-print__control > .form-check {
  margin-bottom: 0;
  font-size: var(--app-text-caption);
  line-height: var(--app-text-caption-lh);
  color: var(--app-ink-muted);
}

/* The check-style controls sit on the buttons' baseline, not the labels'. */
.app-print__control--checks {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--app-space-3);
  padding-bottom: 6px;
}

.app-print__control--checks .form-check-input {
  margin-inline-end: 6px;
}

.app-print__control--note {
  flex: 1 1 200px;
}

/* «الشعار»: a list of the configured shapes' names (X-91), wide enough for one. */
.app-print__control--logo {
  flex: 0 1 220px;
}

.app-print__body {
  padding: var(--app-space-3);
  background-color: var(--app-surface-sunken);
}

.app-print__frame {
  display: block;
  width: 100%;
  height: min(68vh, 900px);
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-md);
  /* Paper is white in both themes: the document inside is printed, not viewed,
     and previewing it on a dark ground would misrepresent what comes out. */
  background-color: var(--app-paper, var(--tb-white));
}

/* Fetching. The frame stays in place at its full height so the modal does not
   resize under the reader the moment the document lands. */
.app-print.is-loading .app-print__body {
  position: relative;
}

.app-print.is-loading .app-print__body::after {
  content: "";
  position: absolute;
  inset: var(--app-space-3);
  border-radius: var(--app-radius-md);
  background-color: var(--app-surface-sunken);
  opacity: 0.85;
  animation: app-skeleton-pulse 1.4s ease-in-out infinite;
}

/* Should the preview itself ever be on screen when the page is printed — a
   ctrl+P against the app rather than the طباعة button — print nothing. The
   document to print lives in the frame and is printed through it. */
@media print {
  .app-print {
    display: none !important;
  }
}

/* =============================================================================
   10. Table -- the shape every list in the product shares

   Before this, each screen wrote its own: `table table-hover align-middle w-100`
   plus a `thead.table-light`, plus a handful of per-view rules for the numeric
   column, the reference column and the empty cell. Sixteen modules produced
   sixteen slightly different tables -- different header weight, different row
   rhythm, different idea of where a number sits -- and the differences were
   invisible to whoever wrote the seventeenth.

   `.app-table` is that shape, once. It is applied ALONGSIDE Bootstrap's
   `.table`, which still supplies the reset and what `.table-responsive`
   expects, and it overrides only what the design system has an opinion about:
   the header, the hairline, the row rhythm and the reading direction. It
   replaces `.table-light` on the head, whose literal grey did not follow the
   dark theme, and `.table-hover`, whose hover fill is a Bootstrap variable this
   file would otherwise have to re-point.

   Reading direction is the rule that is easiest to get wrong. A table reads
   START-aligned -- right in an Arabic document, left in a Latin one -- so there
   is no text-align here beyond the header, and centring is asked for per column
   with `.app-table__c`, never on the table element.
   docs/design-system.md section 7 item 5.
   ========================================================================== */
.app-table {
  --app-table-cell-y: 0.6rem;
  --app-table-cell-x: 0.75rem;
  --bs-table-bg: transparent;
  --bs-table-accent-bg: transparent;
  width: 100%;
  margin-bottom: 0;
  border-color: var(--app-line);
  color: var(--app-ink);
  vertical-align: middle;
}

/* The header is a label row, not a title row: caption scale on the sunken
   surface, rather than a fill of its own. */
.app-table > thead {
  background-color: var(--app-surface-sunken);
}

.app-table > thead > tr > th {
  padding: var(--app-table-cell-y) var(--app-table-cell-x);
  border-bottom: 1px solid var(--app-line-strong);
  background-color: transparent;
  color: var(--app-ink-muted);
  font-size: var(--app-text-caption);
  font-weight: var(--app-weight-semibold);
  line-height: var(--app-text-caption-lh);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.app-table > tbody > tr > td {
  padding: var(--app-table-cell-y) var(--app-table-cell-x);
  border-bottom: 1px solid var(--app-line);
}

/* The last hairline duplicates the card's own edge. */
.app-table > tbody > tr:last-child > td {
  border-bottom: 0;
}

.app-table > tbody > tr {
  transition: background-color 0.15s var(--app-ease);
}

.app-table > tbody > tr:hover {
  background-color: var(--app-sidebar-hover);
}

/* Only a row that really navigates gets the pointer: a pointer over a row
   promises a click, and most of these rows do not answer one. */
.app-table--clickable > tbody > tr {
  cursor: pointer;
}

/* Dense, scannable lists -- an audit log, an event feed. */
.app-table--compact {
  --app-table-cell-y: 0.4rem;
}

/* --- per-column intent ------------------------------------------------------
   Asked for on the <th> and its <td>s, never on the table. */

/* These are written out through `> thead > tr > th` and `> tbody > tr > td`
   rather than as bare classes, and the reason is DataTables, not tidiness.
   `dataTables.bootstrap5.css` ships

       table.dataTable td.dt-type-numeric { text-align: right }

   at (0,2,2), it stamps `dt-type-numeric` on ANY column whose values parse as a
   number -- a badge holding a count included -- and every view links that file
   from `pagecss`, which renders AFTER this one. A bare `.app-table__num` at
   (0,1,0) therefore lost the tie, and lost it in the worst possible way: the
   figures aligned to the physical RIGHT, which in the Arabic document is the
   START of the column, i.e. exactly what asking for a numeric column was meant
   to prevent. Load order cannot be won from here, so specificity is; these are
   (0,2,3) and beat it in both documents without !important. */

/* Centred: short status and action columns only. */
.app-table > thead > tr > th.app-table__c,
.app-table > tbody > tr > td.app-table__c {
  text-align: center;
}

/* A number: aligned to the END of its column and tabular, so the digits line up
   and a longer figure is still comparable at a glance. */
.app-table > thead > tr > th.app-table__num,
.app-table > tbody > tr > td.app-table__num {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* A reference -- a code, an id, an invoice key, a timestamp. Technical strings
   read LTR in both documents, and `unicode-bidi: isolate` stops an Arabic
   paragraph re-ordering them around their own punctuation. */
.app-table > thead > tr > th.app-table__code,
.app-table > tbody > tr > td.app-table__code {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The same isolation for a column that must still WRAP -- an email, a URL, a
   long free-text reference. `__code` is nowrap because a code that breaks is
   unreadable, but a column that cannot wrap widens the whole table, so the two
   cases need separate names rather than one compromise. */
.app-table > thead > tr > th.app-table__ref,
.app-table > tbody > tr > td.app-table__ref {
  direction: ltr;
  unicode-bidi: isolate;
  overflow-wrap: anywhere;
}

/* Two facts in one cell: the name, and its reference underneath. Collapses two
   columns that are always read together into one that is read once. */
.app-table__stack {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.1rem;
}

/* The stack's second line. This was `.app-table__stack > :last-child`, which
   is (0,2,0) and therefore out-specified any single-class modifier a view put
   ON that line -- a caption that needed its own tone ("expires in 2 days")
   could not take one, and the workaround was to keep the caption out of the
   stack entirely. Naming the part instead of reaching for it costs the markup
   one class and gives every consumer their specificity back. */
.app-table__stack > .app-table__sub {
  color: var(--app-ink-muted);
  font-size: var(--app-text-caption);
}

/* Kept, at lower specificity than the named part above, so the ~14 cells that
   already ship a two-child stack keep rendering while they are converted. A new
   stack should name its second line `.app-table__sub`. */
.app-table__stack > :last-child:not(.app-table__sub):not(:first-child) {
  color: var(--app-ink-muted);
  font-size: var(--app-text-caption);
}

/* DataTables writes its "no data" message into a cell of its own and centres
   nothing. DataTables 2 renamed that cell `dt-empty`; the 1.x name is kept
   beside it so the rule survives either build of the library. */
.app-table > tbody > tr > td.dt-empty,
.app-table > tbody > tr > td.dataTables_empty {
  text-align: center;
}

/* =============================================================================
   11. Empty state -- the answer to a list with nothing in it

   Every module wrote this from scratch (.centers-empty, .pay-empty, .subs-empty
   and five more), which is how a product ends up with eight empty states that
   agree on nothing. There are two of them and they are NOT interchangeable:
   NOTHING YET, whose way forward is to create the first record, and NOTHING
   MATCHED, whose way forward is to clear the filters. Showing the first when
   the second is true tells the user their data is gone.
   ========================================================================== */
.app-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--app-space-3);
  padding: var(--app-space-8) var(--app-space-4);
  text-align: center;
}

.app-empty__icon {
  display: inline-flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  border-radius: var(--app-radius-full);
  background-color: var(--app-surface-sunken);
  color: var(--app-ink-faint);
  font-size: 1.75rem;
}

.app-empty__title {
  margin: 0;
  color: var(--app-ink);
  font-size: var(--app-text-subtitle);
  font-weight: var(--app-weight-semibold);
  line-height: var(--app-text-subtitle-lh);
}

/* Held to a readable measure: an explanation set across a full-width table is
   one long line the eye cannot track back from. */
.app-empty__body {
  max-width: 46ch;
  margin: 0;
  color: var(--app-ink-muted);
}

.app-empty__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--app-space-2);
}

/* Inside a table cell the padding above is already generous. */
.app-table .app-empty {
  padding-block: var(--app-space-6);
}

/* A side panel is not a page. The full block padding is right when the empty
   state owns the screen and wrong when it is one card in a column of them. */
.app-empty--compact {
  gap: var(--app-space-2);
  padding: var(--app-space-4) var(--app-space-3);
}

.app-empty--compact .app-empty__icon {
  width: 40px;
  height: 40px;
  font-size: 1.125rem;
}

.app-empty--compact .app-empty__title {
  font-size: var(--app-text-body);
}

/* -----------------------------------------------------------------------------
   Motion preferences apply to every component above.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .app-modal__scrim,
  .app-modal__panel,
  .app-toast,
  .app-skeleton,
  .app-spinner,
  .app-table > tbody > tr,
  .app-print.is-loading .app-print__body::after {
    animation: none;
  }

  /* Transitions too, not only keyframes: the caret's half-turn and the roles
     twisty are motion as much as any animation is. */
  .app-modal__close,
  .app-select__control,
  .app-select__field,
  .app-select__caret,
  .app-select__chip-remove,
  .app-action,
  .app-roles__toggle i,
  .app-roles__all,
  .app-table > tbody > tr {
    transition: none;
  }

  .app-skeleton {
    opacity: 0.7;
  }
}

/* -----------------------------------------------------------------------------
   12. Screen guide -- the button beside a page's title and the text it opens

   The guide (X-77) is prose in a modal: a lead that says what the screen is,
   then short lists under the same few headings on every screen, so a reader
   who learned one guide can scan the next. Quiet on purpose -- the button sits
   beside the page's <h1> and must not compete with it.
   -------------------------------------------------------------------------- */
.app-guide-open {
  display: inline-flex;
  align-items: center;
  gap: var(--app-space-1);
  min-height: 32px;
  padding: 0 var(--app-space-3);
  border: 1px solid var(--app-brand-border);
  border-radius: var(--app-radius-full);
  background-color: var(--app-brand-soft);
  color: var(--app-brand-ink);
  font-size: var(--app-text-caption);
  line-height: var(--app-text-caption-lh);
  font-weight: var(--app-weight-semibold);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.16s var(--app-ease),
    color 0.16s var(--app-ease);
}

.app-guide-open:hover {
  background-color: var(--app-brand);
  border-color: var(--app-brand);
  /* The on-brand ink, not the surface: the surface is dark in the dark theme. */
  color: var(--app-on-brand);
}

.app-guide-open:focus-visible {
  outline: 2px solid var(--app-brand);
  outline-offset: 2px;
}

@media (pointer: coarse) {
  .app-guide-open {
    min-height: 44px;
  }
}

.app-guide .app-guide__lead {
  margin: 0 0 var(--app-space-4);
  color: var(--app-ink-strong);
  font-weight: var(--app-weight-medium);
}

.app-guide h3 {
  margin: var(--app-space-4) 0 var(--app-space-2);
  padding-bottom: var(--app-space-1);
  border-bottom: 1px solid var(--app-line);
  font-size: var(--app-text-body);
  line-height: var(--app-text-body-lh);
  font-weight: var(--app-weight-semibold);
  color: var(--app-brand-ink);
}

.app-guide ul {
  margin: 0;
  padding-inline-start: var(--app-space-4);
}

.app-guide li {
  margin-bottom: var(--app-space-1);
}

.app-guide li:last-child {
  margin-bottom: 0;
}

.app-guide p {
  margin: 0 0 var(--app-space-2);
}

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

/* A structure screen read with no year open (X-29, _StructureReadOnly.cshtml): the gate refuses every
   write, so the controls that would post one are not offered. */
#page-body:has([data-structure-read-only])
  :is(
    [data-structure-open],
    [data-structure-post],
    [data-structure-delete],
    [data-structure-form] [type="submit"]
  ) {
  display: none;
}
