/* Mon Petit Héros - back office.
 *
 * The design tokens are the site's, verbatim (see the step's specification): same palette,
 * same radii, same gradient. Tabler ships the layout and the CRUD widgets; this file paints
 * them and adds the handful of components the review desk needs.
 *
 * Four rules run through this file and are easy to break later:
 *   - small text never goes below --text-muted: --text-subtle and the blue/violet accents
 *     are for large type, borders and glows only;
 *   - no blue or violet wording on the glass cards: those two colours are fills;
 *   - everything is *regular weight*. The brand face has two cuts (Regular and Bold) and
 *     hierarchy is carried by size, colour and letter-spacing instead - a 400 title over a
 *     400 label, not a 600 one;
 *   - Tabler's light-theme defaults (white inputs, white checkboxes, `btn-light` surfaces)
 *     are never allowed through: every control is repainted dark below;
 *   - nothing moves for its own sake. What animates is an entrance (a screen arriving) or a
 *     hover (a control answering), it is all decoration, and `prefers-reduced-motion` at the
 *     bottom of this file switches every last bit of it off.
 */

:root {
  --bg: #0a0a0f;
  --card: #161a33;
  --card-glass: rgba(22, 26, 51, 0.78);
  --card-border: rgba(139, 92, 246, 0.22);
  --primary: #4a6cf7;
  --secondary: #8b5cf6;
  --accent: #e93b9b;
  --text: #ffffff;
  --text-muted: #a9aabf;
  --text-subtle: #7a7a7a;
  --success: #3ddc84;
  --danger: #ff5c7a;
  --gradient: linear-gradient(90deg, #4a6cf7, #8b5cf6, #e93b9b);
  --radius-card: 20px;
  --radius-btn: 999px;
  --font: 'Nunito', system-ui, sans-serif;
  --shadow-glow: 0 0 24px rgba(139, 92, 246, 0.35);
  /*: The rail is wider than Tabler's 15rem: the menu is a list of full names, not icons. */
  --mph-sidebar-w: 18rem;
  /*: The opaque colour behind the glass inputs - what autofill is painted over with. */
  --mph-field: #0e101c;
  /*: Motion: one curve and three durations, so every hover and every entrance in this file
   *  moves at the same tempo. */
  --mph-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --mph-fast: 140ms;
  --mph-base: 240ms;
  --mph-slow: 420ms;

  /* Tabler reads its own variables; point them at ours so its widgets come out on brand. */
  --tblr-body-bg: var(--bg);
  --tblr-body-color: var(--text);
  --tblr-card-bg: var(--card-glass);
  --tblr-card-border-color: var(--card-border);
  --tblr-card-cap-bg: transparent;
  --tblr-border-color: var(--card-border);
  --tblr-primary: var(--primary);
  --tblr-primary-rgb: 74, 108, 247;
  --tblr-link-color: var(--text);
  --tblr-link-hover-color: var(--text);
  --tblr-font-sans-serif: var(--font);
  --tblr-border-radius: 14px;
  --tblr-border-radius-lg: var(--radius-card);
  /* Regular weight everywhere: the two cuts we ship are Regular (400) and Bold (600). */
  --tblr-font-weight-medium: 400;
  --tblr-font-weight-bold: 600;
  --tblr-btn-font-weight: 400;
  /* Every field Tabler paints for itself (checkboxes included) starts from this. */
  --tblr-bg-forms: var(--mph-field);
  --tblr-form-check-bg: var(--mph-field);
  --tblr-dropdown-bg: var(--card);
  --tblr-dropdown-link-hover-bg: rgba(139, 92, 246, 0.16);
  --tblr-dropdown-link-hover-color: var(--text);
  --tblr-dropdown-link-active-bg: var(--secondary);
  --tblr-dropdown-link-active-color: #fff;
  /* Tabler's "surface" tokens are the light theme's near-white greys and they reach places
   * this file does not name: the table header row (`.table thead th`), a card's header, the
   * disabled state, the browser's own autofill paint. Repainted here once, dark everywhere. */
  --tblr-bg-surface: var(--card);
  --tblr-bg-surface-secondary: #1b1f38;
  --tblr-bg-surface-tertiary: rgba(255, 255, 255, 0.03);
  --tblr-table-striped-bg: rgba(255, 255, 255, 0.015);
  --tblr-border-color-translucent: var(--card-border);
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
}

body {
  background-image:
    radial-gradient(circle at 12% -10%, rgba(74, 108, 247, 0.18), transparent 45%),
    radial-gradient(circle at 88% 0%, rgba(233, 59, 155, 0.14), transparent 40%);
  background-attachment: fixed;
}

h1,
h2,
h3,
h4,
h5,
h6,
.page-title,
.card-title {
  font-family: var(--font);
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.01em;
}

a {
  color: var(--text);
}

a:hover {
  color: var(--text);
  text-decoration-color: var(--secondary);
}

/* --- small type: never below --text-muted ---------------------------------- */
.text-muted,
.form-hint,
.page-pretitle,
small,
.small {
  color: var(--text-muted) !important;
}

.mph-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.mph-gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* --- sidebar ------------------------------------------------------------------
 * A fixed rail from 768px up (that is Tabler's own breakpoint for a vertical navbar), and
 * two rules the default does not carry: it is wider than 15rem, and the menu itself takes at
 * least two thirds of the window height, so an operator never squints at a short stack of
 * links. The logout sits at the very bottom of the column.
 */
.navbar-vertical {
  background: linear-gradient(180deg, rgba(22, 26, 51, 0.92), rgba(10, 10, 15, 0.96));
  border-right: 1px solid var(--card-border);
}

/* One surface, edge to edge. Tabler paints a *second* background on every navbar it renders -
 * `--tblr-navbar-bg`, which is its dark theme's `--tblr-bg-surface` (a flat #1f2937) - and the
 * menu it generates inside the rail is a navbar too: the slab landed on the menu, from under
 * the brand down to the logout, with the rail's gradient left showing above, below and beside
 * it. Tabler declares the token on `.navbar` itself, so it has to be unset there - on the rail
 * and on any navbar inside it; the rail's gradient above is then the only surface, running the
 * full height of the column. The one place that still needs a surface of its own is the phone
 * drawer, painted in the small-screen block at the end of this file. */
.mph-sidebar,
.mph-sidebar .navbar {
  --tblr-navbar-bg: transparent;
}

.mph-sidebar-inner {
  /* Tabler zeroes the padding of a vertical navbar's container; the rail needs it back. */
  padding: 0 1.05rem !important;
}

.mph-brand {
  margin: 0;
  padding: 1.35rem 0 1.1rem !important;
}

.mph-brand-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.6rem;
}

.mph-brand-logo {
  display: block;
  height: 38px;
  width: auto;
  max-width: 100%;
  filter: drop-shadow(var(--shadow-glow));
}

.navbar-brand-wordmark {
  display: block;
  font-size: 1.05rem;
  line-height: 1.1;
}

/* The generated menu hides its icons between 768px and 992px (`d-md-none d-lg-inline-block`);
 * in this rail the icons are always wanted. */
.mph-sidebar .nav-link-icon {
  display: inline-block !important;
  width: 1.5rem;
  text-align: center;
  font-size: 1rem;
}

.mph-sidebar .navbar-toggler {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  color: var(--text);
}

.mph-sidebar .navbar-toggler-icon {
  /* The three bars are painted with `currentColor`, which Tabler sets to a grey. */
  background: var(--text);
}

.mph-sidebar .navbar-nav {
  gap: 0.25rem;
}

.mph-sidebar .navbar-nav .nav-link {
  color: var(--text-muted);
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 400;
  padding: 0.6rem 0.9rem !important;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: color var(--mph-fast) var(--mph-ease),
    background-color var(--mph-fast) var(--mph-ease),
    box-shadow var(--mph-base) var(--mph-ease),
    transform var(--mph-base) var(--mph-ease);
}

.mph-sidebar .navbar-nav .nav-link:hover {
  color: var(--text);
  background: rgba(139, 92, 246, 0.12);
  transform: translateX(3px);
}

.mph-sidebar .navbar-nav .nav-link.active,
.mph-sidebar .navbar-nav .nav-item.active > .nav-link {
  color: var(--text);
  background: var(--gradient);
  box-shadow: var(--shadow-glow);
}

.mph-sidebar .navbar-nav .dropdown-menu .nav-link {
  font-size: 0.9rem;
  padding: 0.5rem 0.9rem !important;
}

.nav-link-icon {
  color: inherit;
}

.mph-sidebar-footer {
  /* `margin-top: auto` in the flex column of the rail: the logout is the last thing, always. */
  margin-top: auto;
  padding: 1.25rem 0 1.5rem;
}

.mph-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-weight: 400;
}

.mph-logout:hover,
.mph-logout:focus-visible {
  background: rgba(233, 59, 155, 0.18);
  border-color: var(--accent);
  color: var(--text);
}

.mph-logout-icon {
  font-size: 0.95rem;
}

/* --- one content column, on every screen --------------------------------------
 * Tabler shifts the whole document by the scrollbar's width at desk sizes
 * (``:root { margin-left: calc(100vw - 100%) }``). With a rail fixed to the viewport that is
 * a *second* gutter: the content starts 15px further from the rail and ends 15px earlier, so
 * a long list is 30px narrower than a short screen and the panel changes size as the
 * operator moves between them. The document stays anchored at 0 here.
 */
:root {
  margin-left: 0;
  margin-right: 0;
}

/* And the scrollbar keeps its strip on every page, long or short: the content column is the
 * same width everywhere, and it no longer jumps when a list grows past the window. */
html {
  overflow-y: scroll;
}

@media (min-width: 768px) {
  .navbar-vertical.navbar-expand-md,
  .navbar-vertical.navbar-expand-lg {
    width: var(--mph-sidebar-w);
    overflow-y: auto;
  }

  .navbar-vertical.navbar-expand-md ~ .page-wrapper,
  .navbar-vertical.navbar-expand-lg ~ .page-wrapper {
    margin-left: var(--mph-sidebar-w);
  }

  .mph-sidebar .mph-nav {
    flex: 1 1 auto;
    min-height: 66vh;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
  }

  .mph-sidebar .mph-nav .navbar-collapse {
    width: 100%;
  }
}

/* --- motion ---------------------------------------------------------------------
 * The panel moves, on four rules that keep it from ever getting in the way:
 *
 *   - entrances animate `opacity` and `transform` only (compositor work, no reflow), and the
 *     hover states transition colours, borders and shadows;
 *   - an entrance fills *backwards*, never forwards: during its delay the element is at its
 *     "from" state, and the moment it is over the element is back on its normal styles - so a
 *     card that has just risen still takes its hover lift;
 *   - nothing runs longer than ~900ms and the delays are short, so no screen is ever waiting
 *     on an animation to be readable;
 *   - `prefers-reduced-motion` switches all of it off, at the end of the file.
 */
@keyframes mph-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mph-pop {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes mph-fill {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}

/* A screen arrives as its cards rise, one after the other rather than all at once. */
.page-body .card {
  animation: mph-rise var(--mph-slow) var(--mph-ease) backwards;
}

.mph-stats > .mph-stat:nth-child(2) {
  animation-delay: 70ms;
}

.mph-stats > .mph-stat:nth-child(3) {
  animation-delay: 140ms;
}

.mph-stats > .mph-stat:nth-child(4) {
  animation-delay: 210ms;
}

/* SQLAdmin's filter card is a container that was moved into our panel, not a card of the
 * screen: it does not rise on its own, the panel does. */
.mph-filters-drop .card {
  animation: none;
}

/* --- glass cards and tables -------------------------------------------------- */
.card,
.modal-content,
.dropdown-menu,
.toast {
  background: var(--card-glass) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: var(--radius-card) !important;
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 40px rgba(6, 6, 12, 0.45);
  transition: border-color var(--mph-base) var(--mph-ease),
    box-shadow var(--mph-base) var(--mph-ease),
    transform var(--mph-base) var(--mph-ease);
}

.card-header,
.card-footer {
  background: transparent !important;
  border-color: var(--card-border) !important;
}

/* The card that opens a screen carries the brand tint on its header; the whole panel is
 * dark, and a title alone on a black band reads as an unfinished table. */
.card-header {
  background: linear-gradient(90deg,
      rgba(139, 92, 246, 0.14),
      rgba(233, 59, 155, 0.06) 55%,
      transparent) !important;
  border-bottom: 1px solid var(--card-border) !important;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
}

.card-title {
  margin-bottom: 0.25rem;
  font-size: 1.05rem;
}

.modal-header,
.modal-footer {
  border-color: var(--card-border) !important;
}

.table {
  color: var(--text);
  --tblr-table-color: var(--text);
  --tblr-table-border-color: var(--card-border);
  --tblr-table-hover-bg: rgba(139, 92, 246, 0.08);
}

.table thead th {
  /* Tabler paints this row with `--tblr-bg-surface-tertiary`, a near-white grey in its light
   * theme - the "white header" of a list screen. The token is dark now (see :root). */
  background: var(--tblr-bg-surface-tertiary);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--card-border);
}

.table tbody tr {
  transition: background-color var(--mph-fast) var(--mph-ease);
}

.table td,
.table th {
  border-color: rgba(139, 92, 246, 0.12);
  vertical-align: middle;
}

.table-striped > tbody > tr:nth-of-type(odd) > td {
  background: rgba(255, 255, 255, 0.015);
}

/* The eye / pen / trash of a row are icons, not links to read: they are painted muted and
 * light up on hover, instead of shining white in the middle of the table. */
.card-table a i,
.table a i {
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.card-table a:hover i,
.table a:hover i {
  color: var(--accent);
}

/* --- buttons: pills with a glow ---------------------------------------------- */
.btn {
  --tblr-btn-border-radius: var(--radius-btn);
  border-radius: var(--radius-btn);
  font-family: var(--font);
  font-weight: 400;
  padding-inline: 1.1rem;
  transition: color var(--mph-fast) var(--mph-ease),
    background-color var(--mph-fast) var(--mph-ease),
    border-color var(--mph-fast) var(--mph-ease),
    box-shadow var(--mph-base) var(--mph-ease),
    filter var(--mph-fast) var(--mph-ease),
    transform var(--mph-fast) var(--mph-ease);
}

/* A pill lifts a hair under the pointer and settles under the click - enough to feel alive,
 * small enough that nothing around it appears to move. A disabled one does neither. */
.btn:not(:disabled, .disabled):hover {
  transform: translateY(-1px);
}

.btn:not(:disabled, .disabled):active {
  transform: translateY(0) scale(0.985);
}

.btn-primary,
.btn-gradient {
  background: var(--gradient);
  border: 0;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover,
.btn-gradient:hover {
  background: var(--gradient);
  filter: brightness(1.08);
  color: #fff;
}

/* `btn-light` is what Tabler puts on the Actions dropdown and the page-size picker. In the
 * light theme it is a *white* pill, which is the ugliest surface that used to be on these
 * screens; here it is the same dark pill as everything else. */
.btn-light,
.btn-white,
.btn-outline-light,
.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text);
}

.btn-outline-light,
.btn-secondary {
  background: transparent;
}

.btn-light:hover,
.btn-light:focus,
.btn-light:active,
.btn-outline-light:hover,
.btn-secondary:hover {
  background: rgba(139, 92, 246, 0.16) !important;
  border-color: var(--secondary) !important;
  color: var(--text) !important;
}

.btn-light:disabled,
.btn-light.disabled {
  background: rgba(255, 255, 255, 0.02) !important;
  border-color: var(--card-border) !important;
  color: var(--text-muted) !important;
  opacity: 1;
}

/* The search submit button ships as a bare `.btn` - Tabler's default is a white surface. */
#search-button {
  background: var(--gradient);
  border: 0 !important;
  color: #fff !important;
  box-shadow: var(--shadow-glow);
}

#search-button:hover {
  filter: brightness(1.08);
}

#search-reset {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
}

#search-reset:hover {
  border-color: var(--secondary);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  border: 0;
  color: #1b0710;
}

.btn-sm {
  padding-inline: 0.85rem;
}

/* --- forms -------------------------------------------------------------------- */
.form-control,
.form-select,
.select2-container .select2-selection {
  background: rgba(10, 10, 15, 0.55) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: 14px !important;
  color: var(--text) !important;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--secondary) !important;
  box-shadow: var(--shadow-glow) !important;
}

.form-label,
.col-form-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.form-control::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

/* A prefilled field (a password manager, Chrome, Opera GX) is painted by the browser, not by
 * us: the white background it forces is covered with an inset shadow of the field colour, and
 * the text colour is set back to ours. The huge transition delay keeps the repaint from
 * flashing on the way in. */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus,
.form-control:-webkit-autofill:active,
.form-control:autofill {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--mph-field) inset !important;
  box-shadow: 0 0 0 1000px var(--mph-field) inset !important;
  background-color: var(--mph-field) !important;
  caret-color: var(--text);
  transition: background-color 100000s ease-in-out 0s;
}

/* Same story for the checkboxes of a list: white by default, dark and brand-tinted here. */
.form-check-input,
.form-check-input[type='checkbox'] {
  /* Tabler squares a checkbox off `--tblr-border-radius` (14px here), which rounds a 20px
   * box into a circle; a checkbox says "checkbox" better with a small radius. */
  background-color: var(--mph-field);
  border: 1px solid var(--card-border);
  border-radius: 6px;
}

.form-check-input:checked {
  background-color: var(--secondary);
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.form-check-input:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

/* The search box and its two buttons are a group in SQLAdmin; pills read better than the
 * welded-together Bootstrap row they are by default. */
.input-group {
  gap: 0.5rem;
}

.input-group > .form-control,
.input-group > .form-select {
  border-radius: var(--radius-btn) !important;
}

.input-group > .btn {
  border-radius: var(--radius-btn) !important;
}

/* --- dropdowns ------------------------------------------------------------------ */
.dropdown-item.active,
.dropdown-item:active {
  background: var(--gradient);
  color: #fff;
}

.dropdown-toggle::after {
  border-top-color: currentColor;
}

/* --- badges and status chips ---------------------------------------------------- */
.badge,
.mph-chip {
  border-radius: var(--radius-btn);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  padding: 0.35rem 0.75rem;
}

.mph-chip {
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
}

.mph-chip-ok {
  background: rgba(61, 220, 132, 0.16);
  border-color: rgba(61, 220, 132, 0.4);
  color: var(--text);
}

.mph-chip-warn {
  background: rgba(233, 59, 155, 0.16);
  border-color: rgba(233, 59, 155, 0.4);
  color: var(--text);
}

.mph-chip-danger {
  background: rgba(255, 92, 122, 0.18);
  border-color: rgba(255, 92, 122, 0.45);
  color: var(--text);
}

.mph-chip-info {
  background: rgba(74, 108, 247, 0.18);
  border-color: rgba(74, 108, 247, 0.4);
  color: var(--text);
}

/* --- page header --------------------------------------------------------------- */
.page-header {
  margin-bottom: 0.5rem;
}

.page-title {
  font-weight: 400;
  letter-spacing: 0.005em;
}

.page-pretitle {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

/* --- dashboard -------------------------------------------------------------------
 * The four headline numbers are one row of equal cards, not a stack: `repeat(4, 1fr)` says so
 * outright, and the two narrower layouts say how it degrades.
 */
.mph-stats {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* `row-deck` turns every column into a flex row, which is what makes cards in a row equal
 * height - but a child that is not a card (this grid) is then a flex item sized by its
 * content, so the four numbers huddle on the left of a full-width column. Stretching the
 * grid restores the rule the row is there for. */
.row-deck > [class*='col-'] > .mph-stats {
  width: 100%;
}

@media (max-width: 1399.98px) {
  .mph-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .mph-stats {
    grid-template-columns: minmax(0, 1fr);
  }
}

.mph-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.mph-stat {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.15rem 1.25rem 1.25rem;
}

/* Only the small cards take the hover lift; a full-width table card moving under the pointer
 * would read as a glitch rather than as feedback. */
.mph-stat:hover,
.mph-page-card:hover {
  border-color: rgba(139, 92, 246, 0.42) !important;
  box-shadow: 0 22px 50px rgba(6, 6, 12, 0.55);
  transform: translateY(-2px);
}



.mph-stat-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}

.mph-stat-icon {
  align-items: center;
  background: var(--gradient);
  border-radius: 12px;
  box-shadow: var(--shadow-glow);
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.85rem;
  height: 2rem;
  justify-content: center;
  width: 2rem;
}

.mph-stat-value {
  font-size: 1.95rem;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.mph-stat-hint {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
  transition: color var(--mph-base) var(--mph-ease);
}

/* Under the pointer the caption comes up to full strength: the card that is about to open on
 * a click says so. (The number itself counts up on arrival - see ``admin.js``.) */
.mph-stat:hover .mph-stat-hint {
  color: var(--text);
}

.mph-bar {
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-btn);
  height: 8px;
  overflow: hidden;
}

/* The bar grows from its left edge instead of appearing full: `scaleX` off the inline width
 * the template already set, so the bar still means exactly the number it is given. */
.mph-bar span {
  animation: mph-fill 900ms var(--mph-ease) 120ms backwards;
  background: var(--gradient);
  display: block;
  height: 100%;
  transform-origin: left center;
}

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

.mph-list li {
  border-bottom: 1px solid rgba(139, 92, 246, 0.12);
  padding: 0.6rem 0;
}

.mph-list li:last-child {
  border-bottom: 0;
}

/* Orders by status: the count is as far right as the bar is wide, so the eye can compare. */
.mph-status-head {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.mph-status-name {
  font-size: 0.9rem;
  line-height: 1.4;
}

.mph-status-list li {
  padding: 0.7rem 0;
}

/* Tasks to watch out for: a chip row, one meta line, then the error - each with room around
 * it, instead of four sentences running into each other. */
.mph-job-list li.mph-job {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.9rem 0;
}

.mph-job-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.mph-job-type {
  font-size: 0.95rem;
  line-height: 1.4;
}

.mph-job-action {
  margin-left: auto;
}

.mph-job-meta {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.82rem;
  gap: 0.4rem;
  line-height: 1.6;
}

.mph-job-sep {
  opacity: 0.45;
}

.mph-job-code {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-btn);
  font-size: 0.76rem;
  padding: 0.05rem 0.5rem;
}

/* --- review desk ---------------------------------------------------------------- */
.mph-review-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.mph-page-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.mph-page-frame {
  background: rgba(10, 10, 15, 0.6);
  position: relative;
}

.mph-page-frame img {
  display: block;
  width: 100%;
}

.mph-page-frame .mph-page-empty {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 0.85rem;
  justify-content: center;
  min-height: 190px;
}

.mph-page-overlay {
  background: linear-gradient(180deg, transparent, rgba(10, 10, 15, 0.92) 55%);
  bottom: 0;
  left: 0;
  padding: 2.2rem 0.9rem 0.7rem;
  position: absolute;
  right: 0;
}

.mph-page-text {
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.35;
  margin: 0;
}

.mph-page-body {
  padding: 0.85rem 0.9rem 1rem;
}

.mph-page-head {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.mph-page-title {
  font-size: 0.98rem;
  font-weight: 400;
  margin: 0;
}

.mph-checks {
  color: var(--text-muted);
  font-size: 0.78rem;
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.mph-checks li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.mph-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.85rem;
}

.mph-actions form {
  margin: 0;
}

/* --- timeline ------------------------------------------------------------------ */
.mph-timeline {
  border-left: 1px solid var(--card-border);
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.1rem;
}

.mph-timeline li {
  margin-bottom: 1rem;
  position: relative;
}

.mph-timeline li::before {
  background: var(--gradient);
  border-radius: 50%;
  content: '';
  height: 10px;
  left: -1.42rem;
  position: absolute;
  top: 0.35rem;
  width: 10px;
}

.mph-timeline-time {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.mph-event-data {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
}

/* --- filters, as a button that drops the panel open -------------------------------
 * SQLAdmin renders the filters in a card down the right-hand column; `admin.js` moves that
 * card into the panel, and the panel itself under `<body>` (`position: fixed` cannot resolve
 * against the viewport while it is inside a card, whose `backdrop-filter` makes it the
 * containing block). The two offsets come from the button's own rectangle, so the panel sits
 * just under it whatever the header does; the CSS defaults below are what a panel looks like
 * if the script never ran - in which case the filters are still in their column, untouched.
 */

.mph-filters-toggle {
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text);
  display: inline-flex;
  gap: 0.55rem;
}

.mph-filters-toggle:hover,
.mph-filters-toggle[aria-expanded='true'] {
  background: rgba(139, 92, 246, 0.18);
  border-color: var(--secondary);
  color: var(--text);
}

.mph-filters-toggle-icon {
  font-size: 0.9rem;
}

.mph-filters-count {
  align-items: center;
  background: var(--gradient);
  border-radius: var(--radius-btn);
  color: #fff;
  display: inline-flex;
  font-size: 0.72rem;
  height: 1.35rem;
  justify-content: center;
  min-width: 1.35rem;
  padding: 0 0.35rem;
}

.mph-filters-panel {
  animation: mph-pop var(--mph-base) var(--mph-ease) backwards;
  backdrop-filter: blur(14px);
  background: var(--card-glass);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: 0 24px 60px rgba(4, 4, 10, 0.6);
  max-height: min(70vh, 34rem);
  overflow: auto;
  padding: 1rem 1.1rem 1.25rem;
  position: fixed;
  right: var(--mph-panel-right, 2rem);
  text-align: left;
  top: var(--mph-panel-top, 6rem);
  transform-origin: top right;
  width: min(24rem, calc(100vw - 3rem));
  z-index: 1080;
}

.mph-filters-head {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.mph-filters-title {
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.mph-filters-clear {
  font-size: 0.8rem;
  margin-left: auto;
  text-decoration-color: var(--secondary);
}

.mph-filters-close {
  align-items: center;
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 50%;
  color: var(--text-muted);
  display: inline-flex;
  height: 1.85rem;
  justify-content: center;
  margin-left: auto;
  width: 1.85rem;
}

.mph-filters-clear + .mph-filters-close {
  margin-left: 0.35rem;
}

.mph-filters-close:hover {
  border-color: var(--accent);
  color: var(--text);
}

.mph-filters-active {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

/* The widgets themselves keep SQLAdmin's markup; this drops their card chrome (the panel
 * already carries the "Filtres" title, so the moved card must not repeat it) and repaints the
 * two classes SQLAdmin uses for a *selected* value, which are light-theme colours: a grey
 * chip with dark text, in the middle of a dark panel. */
.mph-filters-drop .card {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none;
}

.mph-filters-drop .card-header {
  display: none;
}

.mph-filters-drop .card-body {
  padding: 0;
}

.mph-filters-drop .fw-bold {
  font-weight: 400 !important;
}

.mph-filters-drop .fs-3 {
  color: var(--text-muted);
  font-size: 0.8rem !important;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.mph-filters-drop .bg-secondary-lt {
  background: rgba(139, 92, 246, 0.18) !important;
  border: 1px solid var(--card-border);
  border-radius: 12px !important;
}

.mph-filters-drop .text-dark {
  color: var(--text) !important;
}

.mph-filters-drop a.d-block {
  border-radius: 12px;
  color: var(--text-muted);
}

.mph-filters-drop a.d-block:hover {
  background: rgba(139, 92, 246, 0.14);
  color: var(--text);
}

.mph-filters-drop .btn-outline-primary {
  background: var(--gradient);
  border: 0;
  color: #fff;
}

/* --- widgets SQLAdmin loads from its own stylesheets -------------------------------------
 * Select2 (the foreign-key pickers) and flatpickr (the date fields) ship light themes of
 * their own; they are the last white surfaces on a form. Only the surfaces are repainted -
 * the behaviour is theirs.
 */
.select2-dropdown,
.select2-container--default .select2-results,
.flatpickr-calendar,
.flatpickr-months .flatpickr-month,
.flatpickr-time {
  background: var(--card) !important;
  border-color: var(--card-border) !important;
  color: var(--text) !important;
}

.select2-container--default .select2-results__option--highlighted,
.flatpickr-day.selected {
  background: rgba(139, 92, 246, 0.3) !important;
  color: var(--text) !important;
}

.select2-container--default .select2-results__option,
.flatpickr-day,
.flatpickr-weekday,
.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
  color: var(--text-muted);
  fill: var(--text-muted);
}

.flatpickr-day.today,
.flatpickr-day:hover {
  border-color: var(--secondary);
  background: rgba(139, 92, 246, 0.16);
}

.select2-container--default .select2-search--dropdown .select2-search__field,
.flatpickr-time input,
.flatpickr-time .flatpickr-am-pm {
  background: var(--mph-field) !important;
  border-color: var(--card-border) !important;
  color: var(--text) !important;
}

/* --- pagination ------------------------------------------------------------------
 * SQLAdmin puts "showing x to y", the pager and the page-size picker on one line. The pager
 * links sat flush against each other with a default padding that made "suivant" look glued to
 * the number before it; each link is its own pill with a fixed minimum width now.
 */
.card-footer {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 1rem 1.25rem;
}

.card-footer > p {
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
  margin: 0;
}

.pagination {
  --tblr-pagination-padding-x: 0.65rem;
  --tblr-pagination-padding-y: 0.3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
}

.pagination .page-link {
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-btn) !important;
  color: var(--text-muted);
  display: inline-flex;
  gap: 0.35rem;
  justify-content: center;
  line-height: 1.25rem;
  min-width: 2.25rem;
  padding: 0.4rem 0.8rem;
}

.pagination .page-item:first-child .page-link,
.pagination .page-item:last-child .page-link {
  border-radius: var(--radius-btn) !important;
}

.pagination .page-link:hover {
  background: rgba(139, 92, 246, 0.16);
  border-color: var(--secondary);
  color: var(--text);
}

.pagination .page-item.active .page-link {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
}

.pagination .page-item.disabled .page-link {
  background: transparent;
  opacity: 0.45;
}

.alert-danger {
  animation: mph-pop var(--mph-base) var(--mph-ease) backwards;
  background: rgba(255, 92, 122, 0.16);
  border: 1px solid rgba(255, 92, 122, 0.45);
  color: var(--text);
}

.alert-success {
  animation: mph-pop var(--mph-base) var(--mph-ease) backwards;
  background: rgba(61, 220, 132, 0.14);
  border: 1px solid rgba(61, 220, 132, 0.4);
  color: var(--text);
}

hr {
  border-color: var(--card-border);
}

/* --- themes -------------------------------------------------------------------- */
.mph-swatches {
  display: flex;
  gap: 0.4rem;
}

.mph-swatch {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  height: 26px;
  width: 26px;
}

.mph-prompt {
  color: var(--text-muted);
  font-size: 0.8rem;
  max-height: 12rem;
  overflow: auto;
  white-space: pre-wrap;
}

/* --- login ---------------------------------------------------------------------- */
.mph-login {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1.25rem;
}

.mph-login-card {
  animation: mph-rise 520ms var(--mph-ease) backwards;
  max-width: 27rem;
  padding: 2.25rem 2rem;
  width: 100%;
}

.mph-login-brand {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: center;
}

.mph-login-logo {
  filter: drop-shadow(0 0 22px rgba(139, 92, 246, 0.45));
  height: auto;
  width: 84px;
}

.mph-login-title {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0.6rem 0 0;
}

.mph-login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.mph-login form {
  margin-top: 1.75rem;
}

.mph-login-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 1.5rem 0 0;
  text-align: center;
}

/* --- mobile ----------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  /* Below the rail's breakpoint there is no column to paint the gradient across: the menu is
   * a drawer that opens over the page, and it is the one surface Tabler used to give it (see
   * ``--tblr-navbar-bg`` above). The drawer gets the panel's own card instead, edge to edge
   * with the rail. */
  .mph-sidebar .mph-nav {
    width: 100%;
  }

  .mph-sidebar .navbar-collapse.show,
  .mph-sidebar .navbar-collapse.collapsing {
    background: var(--card-glass);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-card);
    box-shadow: 0 18px 40px rgba(6, 6, 12, 0.45);
    margin: 0.5rem 0 0.25rem;
    padding: 0.6rem;
  }

  /* The sheet rises from the bottom of the window there, so that is the corner it grows from. */
  .mph-filters-panel {
    transform-origin: bottom center;
  }

  .mph-review-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .page-title {
    font-size: 1.35rem;
  }

  .navbar-vertical .navbar-brand-wordmark {
    font-size: 1rem;
  }

  .mph-stat-value {
    font-size: 1.6rem;
  }

  .mph-brand {
    padding: 0.9rem 0 !important;
  }

  /* On a phone the header wraps and the button can end up anywhere on the line, so a panel
   * hanging off it would stick out of the screen on the left. It becomes a sheet pinned to
   * the bottom of the window instead - still the same widgets, still the same panel. */
  .mph-filters-panel {
    bottom: 0.75rem;
    left: 0.75rem;
    max-height: 70vh;
    position: fixed;
    right: 0.75rem;
    top: auto;
    width: auto;
    z-index: 1080;
  }
}

/* --- reduced motion ----------------------------------------------------------------
 * Whoever asked their system for less movement gets a panel that simply is there: every
 * entrance and every hover is over as soon as it starts, and nothing is left mid-flight.
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-delay: 0ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
