/*
 * Admin design system (the new admin shell and kit). Built to public_html/css/admin-v4.css by
 * scripts/build-css.js (target in scripts/css/targets.js). Loaded by the layout
 * modules/Admin/Resources/views/layouts/shell.blade.php. It does not replace css/admin.css, which the
 * old layout layouts/adminv3.blade.php still loads.
 * Source of truth: docs/admin/design-brief.md and the Admin part of docs/design/DESIGN.md.
 * The reference mockup is docs/admin/mockups/admin.css (same rules, same class names).
 * Everything is scoped under [data-app="admin"] with native CSS nesting.
 * Logical properties only. Physical left/right appear in three marked places
 * (select arrow position, sidebar/sheet slide direction through --ad-flip, none else).
 *
 * ---------------------------------------------------------------------------
 * CLASS INDEX (public names, keep stable)
 * ---------------------------------------------------------------------------
 * Shell
 *   .ad-topline                 3 px ministry-green line at the very top
 *   .ad-shell                   flex row: sidebar + main
 *   .ad-sidebar                 navy sidebar (264 px); .is-open = drawer open (< 1024 px)
 *   .ad-scrim                   dark overlay behind drawer or sheet; .is-open = shown
 *   .ad-sidebar__brand          logo area
 *   .ad-logo-mark               white tile with the ministry emblem
 *   .ad-sidebar__title          ministry name; .ad-sidebar__sub = department name
 *   .ad-sidebar__search         search field wrapper; .ad-sidebar__input = the input
 *   .ad-nav                     menu container
 *   .ad-nav-group               <details> group; .ad-nav-group__label = its <summary>
 *   .ad-nav-list                <ul> of items
 *   .ad-nav-item                link or <summary> row; .is-active = current page
 *   .ad-nav-item--sub           item inside a sub list (no icon, indented)
 *   .ad-nav-sub                 <details> sub group; .ad-nav-sublist = its <ul>
 *   .ad-nav-empty               "no result" line of the menu search
 *   .ad-badge                   count badge (sidebar, bell)
 *   .ad-icon                    20 px inline SVG icon; .ad-icon--sm 16 px
 *   .ad-main                    column to the side of the sidebar
 *   .ad-topbar                  56 px top bar
 *   .ad-topbar__menu            hamburger: toggles the drawer < 1024 px, collapses the sidebar >= 1024 px
 *   .ad-breadcrumb              breadcrumb <ol>; .ad-breadcrumb__sep = separator
 *   .ad-topbar__spacer          flexible gap
 *   .ad-topbar__search          global search; .ad-kbd = key hint (button or form with an input)
 *   .ad-iconbtn                 square 40 px icon button (bell, close); .ad-iconbtn .ad-badge
 *   .ad-user                    user menu button; .ad-user__avatar, .ad-user__name, .ad-user__role
 *   .ad-content                 content container (max 1440)
 *   .ad-page-header             title block + actions; .ad-page-header__title,
 *                               .ad-page-header__desc, .ad-page-header__actions
 * Kit
 *   .ad-btn                     + --primary --secondary --ghost --danger --sm --icon
 *   .ad-card                    + .ad-card__title .ad-card__note .ad-card__head
 *   .ad-grid                    layout grid; --2 --3 --4 modifiers (1 column on mobile)
 *   .ad-stack                   vertical gap 16 px
 *   .ad-row                     horizontal flex with gap; --between --wrap
 *   .ad-kpis                    KPI grid 4/2/1; .ad-kpi, .ad-kpi__label, .ad-kpi__value,
 *                               .ad-kpi__delta (+ --up --down --flat), .ad-kpi__spark
 *   .ad-chip                    + --success --neutral --info --danger --warning --filter;
 *                               .ad-chip__x = remove button of a filter chip
 *   .ad-filterbar               filter row card; .ad-filterbar__field, .ad-filterbar__grow,
 *                               .ad-filterbar__actions, .ad-filter-chips
 *   .ad-sheet                   side sheet; .is-open; .ad-sheet__head, .ad-sheet__body,
 *                               .ad-sheet__foot
 *   .ad-table-wrap              white card around a table; .ad-table__bar = toolbar above rows
 *   .ad-table                   + --compact; .ad-table__check, .ad-table__num,
 *                               .ad-table__actions, .ad-table__link, .ad-sort (sort button in th)
 *                               .ad-row-actions (one-line actions), .ad-row-actions__more (menu
 *                               trigger), .ad-row-actions__menu (popover panel, set by rowActions.js)
 *                               th[aria-sort] shows the arrow; tr.is-selected
 *   .ad-pagination              bottom bar; .ad-pagination__info, .ad-pagination__pages,
 *                               .ad-page (button), .ad-page.is-current
 *   .ad-form                    form root; .ad-form__section (card), .ad-form__title,
 *                               .ad-form__grid (2 columns >= 1024), .ad-form__full (span 2),
 *                               .ad-form__footer (sticky bar)
 *   .ad-field                   label + control + help + error; .ad-field.has-error
 *   .ad-label                   label; .ad-req = required star (+ .ad-sr-only text)
 *   .ad-input .ad-select .ad-textarea    40 px controls
 *   .ad-check                   checkbox or radio with label text
 *   .ad-help / .ad-error        help and error text
 *   .ad-tabs                    tab list; .ad-tab ([aria-selected="true"] = active); .ad-tabpanel
 *   .ad-alert                   + --success --warning --danger --info; .ad-alert__title
 *   .ad-toast-region            fixed region at top end; --static = in flow (mockup sample)
 *   .ad-toast                   + --success --warning --danger --info
 *   .ad-empty                   empty / error state; .ad-empty__icon, .ad-empty__text
 *   .ad-skeleton                loading block; --line --title --row
 *   .ad-dialog                  confirm dialog (<dialog> or div); --static = in flow (sample);
 *                               .ad-dialog__title, .ad-dialog__body, .ad-dialog__foot
 *   .ad-chart                   chart card; .ad-chart__head, .ad-chart__legend,
 *                               .ad-chart__legend-item, .ad-chart__swatch, .ad-chart__body,
 *                               .ad-chart__svg, .ad-chart__link, .ad-chart__hint (scroll hint
 *                               under a sideways scrolling body; JS sets [hidden] and the
 *                               classes .is-scrollable, .is-fade-l, .is-fade-r on the body)
 *   .ad-hbar                    horizontal bar list (<ol>, --max on the list, --v on each bar);
 *                               .ad-hbar__row, .ad-hbar__label, .ad-hbar__track,
 *                               .ad-hbar__bar ([data-series] = colour), .ad-hbar__value
 *   .ad-menu                    dropdown wrapper; .ad-menu__panel (.is-open), .ad-menu__item,
 *                               .ad-menu__sep, .ad-menu__head
 *                               .ad-menu__label (group label); [aria-checked="true"] = chosen
 *   html[data-theme="dark"]     dark tokens (user menu: light / dark / system; see shell.js)
 * Utilities
 *   .ad-sr-only, .ad-muted, .ad-num (tabular figures), .ad-hide-print
 *
 * CONTRAST: every text pair is 4.5 or more, large text, icons and borders are 3 or more.
 * The computed ratio of each pair is listed in the header of docs/admin/mockups/admin.css. The active bar on the navy sidebar uses --ad-primary-on-nav
 * (5.22 on nav), because --ad-primary is only 2.88 there. The active item also has a background
 * and bold text, never the bar alone.
 */

/*
 * Self-hosted UI font, same files as scss/_fonts.scss (output sits next to css/app.css, so the
 * path is the same). The family name here is the one the token --ad-font lists first.
 */
@font-face {
  font-family: "Helvetica Neue LT W20 Arabic";
  font-weight: 400;
  font-display: swap;
  ascent-override: 137%;
  descent-override: 85%;
  src: url("../fonts/HelveticaNeueLTW20-Light.woff") format("woff");
}

@font-face {
  font-family: "Helvetica Neue LT W20 Arabic";
  font-weight: 700;
  font-display: swap;
  ascent-override: 137%;
  descent-override: 85%;
  src: url("../fonts/HelveticaNeueLTW20-Bold.woff") format("woff");
}

[data-app="admin"] {
  /* ---- tokens: brand (shared with student and teacher apps) ---- */
  --ad-primary: #0072c8;
  --ad-primary-hover: #0061aa;
  --ad-primary-soft: #eff6fc;
  --ad-primary-text: #005a9e;
  --ad-primary-on-nav: #4aa3e8;
  --ad-ink: #2d2c47;
  --ad-ink-2: #5b6672;
  --ad-ink-3: #5f6779;
  /* page and cards are a step off pure white to cut the glare (user feedback 2026-11) */
  --ad-page: #eceff4;
  --ad-surface: #fbfcfd;
  --ad-surface-2: #f3f5f8;
  --ad-line: #d6dbe5;
  --ad-line-strong: #858d9c;
  --ad-nav: #1f2a44;
  --ad-on-nav: #e8ecf4;
  --ad-nav-muted: #a9b3c7;
  --ad-nav-active: #2d3b5c;
  --ad-success-text: #157539;
  --ad-success-soft: #e8f6ee;
  --ad-warning-text: #944f00;
  --ad-warning-soft: #fff4e5;
  --ad-danger-text: #b3301a;
  --ad-danger-fill: #c23a24;
  --ad-danger-hover: #b3301a;
  --ad-danger-soft: #fdeeeb;
  --ad-info-text: #005a9e;
  --ad-info-soft: #eff6fc;
  --ad-neutral-soft: #eef0f4;
  --ad-ministry: #0b6b4f;
  /* links: a touch darker than primary so they keep 4.5 on the page background */
  --ad-link: #006bbd;
  /* edge shadow of the pinned actions column */
  --ad-shadow-edge: rgba(31, 42, 68, 0.18);
  color-scheme: light;

  /* chart series, categorical order */
  --ad-series-1: #2a78d6;
  --ad-series-2: #138a5e;
  --ad-series-3: #6c43e1;
  --ad-series-4: #c32b6c;
  --ad-series-5: #eb6834;
  --ad-series-6: #58637a;

  /* ---- tokens: shape and layout ---- */
  --ad-radius: 6px;
  --ad-radius-card: 10px;
  --ad-shadow-card: 0 1px 2px rgba(31, 42, 68, 0.06);
  --ad-shadow-pop: 0 8px 24px rgba(31, 42, 68, 0.16);
  --ad-sidebar-w: 264px;
  --ad-topbar-h: 56px;
  --ad-topline-h: 3px;
  --ad-content-max: 1440px;
  --ad-gap: 16px;
  --ad-card-pad: 16px;
  --ad-control-h: 40px;
  --ad-font: "Helvetica Neue LT W20 Arabic", "Tajawal", "Segoe UI", Tahoma, sans-serif;
  /* 1 for RTL: an element parked outside at the inline start moves by +100% on the x axis */
  --ad-flip: 1;

  /* ---- base ---- */
  margin: 0;
  background: var(--ad-page);
  color: var(--ad-ink);
  font-family: var(--ad-font);
  font-size: 14px;
  line-height: 22px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;

  /* physical direction is unavoidable here: transform has no logical axis */
  html[dir="ltr"] & {
    --ad-flip: -1;
  }

  /* ---- dark theme: html[data-theme="dark"], set in the head of the shell before first paint
     (choice in the user menu: light / dark / follow the system). Only colour tokens change. ---- */
  /* screen only: print always uses the light tokens */
  @media screen {
    html[data-theme="dark"] & {
      color-scheme: dark;
      --ad-primary: #1f73c2;
      --ad-primary-hover: #1a66ae;
      --ad-primary-soft: #1a2c44;
      --ad-primary-text: #6cb4f0;
      --ad-primary-on-nav: #6cb4f0;
      --ad-link: #6cb4f0;
      --ad-ink: #e4e8f0;
      --ad-ink-2: #a6b0c2;
      --ad-ink-3: #9aa4b8;
      --ad-page: #0f1522;
      --ad-surface: #171e2d;
      --ad-surface-2: #1c2435;
      --ad-line: #2c3548;
      --ad-line-strong: #66718a;
      --ad-nav: #121a2b;
      --ad-on-nav: #e4e8f0;
      --ad-nav-muted: #9aa4b8;
      --ad-nav-active: #24304a;
      --ad-success-text: #5fd08b;
      --ad-success-soft: #15301f;
      --ad-warning-text: #f0b35c;
      --ad-warning-soft: #33250f;
      --ad-danger-text: #ff8f7a;
      --ad-danger-fill: #c23a24;
      --ad-danger-hover: #a52a16;
      --ad-danger-soft: #3a1c17;
      --ad-info-text: #6cb4f0;
      --ad-info-soft: #1a2c44;
      --ad-neutral-soft: #222b3d;
      --ad-series-1: #4d94e8;
      --ad-series-2: #2fb37f;
      --ad-series-3: #9273f0;
      --ad-series-4: #e0568f;
      --ad-series-5: #f08250;
      --ad-series-6: #8792a8;
      --ad-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
      --ad-shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);
      --ad-shadow-edge: rgba(0, 0, 0, 0.5);
    }
  }

  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  h1, h2, h3, h4, p, ul, ol, dl, dd, figure {
    margin: 0;
  }

  ul, ol {
    padding: 0;
    list-style: none;
  }

  b, strong, th, h1, h2, h3, h4 {
    font-weight: 700;
  }

  a {
    color: var(--ad-link);
    text-decoration: none;
  }

  a:hover {
    text-decoration: underline;
  }

  button, input, select, textarea {
    font: inherit;
    color: inherit;
  }

  button {
    cursor: pointer;
  }

  input[type="checkbox"],
  input[type="radio"] {
    accent-color: var(--ad-primary);
  }

  summary {
    cursor: pointer;
    list-style: none;
  }

  summary::-webkit-details-marker {
    display: none;
  }

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

  [hidden] {
    display: none !important;
  }

  /* ---- type scale ---- */
  .ad-page-header__title { font-size: 22px; line-height: 32px; font-weight: 700; }
  .ad-card__title,
  .ad-form__title { font-size: 16px; line-height: 24px; font-weight: 700; }
  .ad-table { font-size: 13px; line-height: 20px; }
  .ad-label { font-size: 13px; line-height: 20px; font-weight: 700; }
  .ad-help, .ad-error, .ad-chip, .ad-badge, .ad-kbd, .ad-pagination__info { font-size: 12px; line-height: 16px; }

  /* ---- utilities ---- */
  .ad-num { font-variant-numeric: tabular-nums; }
  .ad-muted { color: var(--ad-ink-2); }
  .ad-sr-only {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .ad-icon {
    inline-size: 20px;
    block-size: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .ad-icon--sm {
    inline-size: 16px;
    block-size: 16px;
  }

  .ad-stack { display: flex; flex-direction: column; gap: var(--ad-gap); }
  .ad-row { display: flex; align-items: center; gap: 8px; }
  .ad-row--between { justify-content: space-between; }
  .ad-row--wrap { flex-wrap: wrap; }
  .ad-grid { display: grid; gap: var(--ad-gap); grid-template-columns: 1fr; }

  /* ======================================================================
     SHELL
     ====================================================================== */
  .ad-topline {
    block-size: var(--ad-topline-h);
    background: var(--ad-ministry);
    position: sticky;
    inset-block-start: 0;
    z-index: 60;
  }

  .ad-shell {
    display: flex;
    align-items: flex-start;
    min-block-size: calc(100vh - var(--ad-topline-h));
    min-inline-size: 0;
    /* last guard only: the causes of sideways overflow are fixed at their source (topbar,
       main, content all have min-inline-size 0). clip does not create a scroll container,
       so the sticky topbar and sidebar keep working. */
    overflow-x: clip;
  }

  .ad-main {
    flex: 1 1 0;
    min-inline-size: 0;
    max-inline-size: 100%;
    display: flex;
    flex-direction: column;
    min-block-size: calc(100vh - var(--ad-topline-h));
  }

  .ad-content {
    inline-size: 100%;
    min-inline-size: 0;
    max-inline-size: var(--ad-content-max);
    margin-inline: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: var(--ad-gap);
  }

  /* ---- sidebar ---- */
  .ad-sidebar {
    flex: none;
    inline-size: var(--ad-sidebar-w);
    position: sticky;
    inset-block-start: var(--ad-topline-h);
    block-size: calc(100vh - var(--ad-topline-h));
    display: flex;
    flex-direction: column;
    background: var(--ad-nav);
    color: var(--ad-on-nav);
    overflow: hidden;
    z-index: 40;
  }

  .ad-sidebar :focus-visible {
    outline-color: var(--ad-primary-on-nav);
  }

  .ad-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-block-end: 1px solid rgba(232, 236, 244, 0.12);
  }

  .ad-logo-mark {
    inline-size: 44px;
    block-size: 44px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.28);
  }

  .ad-logo-mark img {
    inline-size: 32px;
    block-size: 32px;
    object-fit: contain;
    display: block;
  }

  .ad-sidebar__title {
    display: block;
    font-size: 13px;
    line-height: 20px;
    font-weight: 700;
    color: #ffffff;
  }

  .ad-sidebar__sub {
    display: block;
    margin-block-start: 2px;
    font-size: 12px;
    line-height: 16px;
    color: var(--ad-nav-muted);
  }

  .ad-sidebar__search {
    position: relative;
    padding: 12px 12px 8px;
  }

  .ad-sidebar__search .ad-icon {
    position: absolute;
    inset-inline-start: 24px;
    inset-block-start: 22px;
    color: var(--ad-nav-muted);
    pointer-events: none;
  }

  .ad-sidebar__input {
    inline-size: 100%;
    block-size: 40px;
    padding-inline: 40px 12px;
    border: 1px solid transparent;
    border-radius: var(--ad-radius);
    background: var(--ad-nav-active);
    color: var(--ad-on-nav);
  }

  .ad-sidebar__input::placeholder {
    color: var(--ad-nav-muted);
    opacity: 1;
  }

  .ad-sidebar__input:focus-visible {
    outline: 2px solid var(--ad-primary-on-nav);
    outline-offset: 2px;
  }

  .ad-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 4px 12px 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--ad-nav-active) transparent;
  }

  .ad-nav-group {
    margin-block-start: 8px;
  }

  .ad-nav-group__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 8px 4px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 700;
    color: var(--ad-nav-muted);
    border-radius: var(--ad-radius);
  }

  .ad-nav-group__label .ad-icon,
  .ad-nav-sub__chev {
    inline-size: 16px;
    block-size: 16px;
    transition: transform 0.15s ease;
  }

  .ad-nav-group[open] > .ad-nav-group__label .ad-icon,
  .ad-nav-sub[open] > summary .ad-nav-sub__chev {
    transform: rotate(180deg);
  }

  .ad-nav-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-block-start: 2px;
  }

  .ad-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-block-size: 40px;
    padding: 8px 12px;
    border-radius: var(--ad-radius);
    color: var(--ad-on-nav);
    font-size: 14px;
    line-height: 20px;
    text-decoration: none;
  }

  .ad-nav-item > span:first-of-type {
    flex: 1 1 auto;
    min-inline-size: 0;
  }

  .ad-nav-item:hover {
    background: color-mix(in srgb, var(--ad-nav-active) 55%, var(--ad-nav));
    color: #ffffff;
    text-decoration: none;
  }

  .ad-nav-item.is-active {
    background: var(--ad-nav-active);
    color: #ffffff;
    font-weight: 700;
  }

  .ad-nav-item.is-active::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    inset-block: 8px;
    inline-size: 3px;
    border-radius: 3px;
    background: var(--ad-primary-on-nav);
  }

  .ad-nav-item--sub {
    padding-inline-start: 44px;
    min-block-size: 36px;
    font-size: 13px;
  }

  .ad-nav-sublist {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-block: 2px 4px;
  }

  .ad-nav-sub > summary.ad-nav-item {
    cursor: pointer;
  }

  .ad-nav-empty {
    padding: 16px 8px;
    font-size: 13px;
    color: var(--ad-nav-muted);
  }

  .ad-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 20px;
    block-size: 20px;
    padding-inline: 6px;
    border-radius: 999px;
    background: var(--ad-danger-fill);
    color: #ffffff;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /* ---- top bar ---- */
  .ad-topbar {
    position: sticky;
    inset-block-start: var(--ad-topline-h);
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    block-size: var(--ad-topbar-h);
    padding-inline: 24px;
    /* the bar can never be wider than its column: only the breadcrumb shrinks */
    inline-size: 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
    background: var(--ad-surface);
    border-block-end: 1px solid var(--ad-line);
  }

  /* controls keep their size; the breadcrumb nav is the one child that may shrink */
  .ad-topbar > * {
    flex: none;
  }

  .ad-topbar > nav {
    flex: 0 1 auto;
    min-inline-size: 0;
    overflow: hidden;
  }

  .ad-topbar__spacer {
    flex: 1 1 0;
    min-inline-size: 0;
  }

  .ad-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    min-inline-size: 0;
    overflow: hidden;
    font-size: 13px;
    line-height: 20px;
    color: var(--ad-ink-2);
    white-space: nowrap;
  }

  .ad-breadcrumb > li {
    flex: none;
    min-inline-size: 0;
  }

  .ad-breadcrumb a {
    color: var(--ad-ink-2);
  }

  /* the current page is the item that gives way first, with an ellipsis */
  .ad-breadcrumb > li:last-child,
  .ad-breadcrumb [aria-current] {
    flex: 0 1 auto;
    min-inline-size: 0;
    color: var(--ad-ink);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ad-breadcrumb__sep {
    color: var(--ad-ink-2);
  }

  .ad-breadcrumb__sep .ad-icon {
    inline-size: 14px;
    block-size: 14px;
    /* chevron drawn pointing to the end; flips with the writing direction */
    transform: scaleX(calc(var(--ad-flip) * -1));
  }

  .ad-topbar__search {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    block-size: 36px;
    padding-inline: 12px 8px;
    border: 1px solid var(--ad-line-strong);
    border-radius: var(--ad-radius);
    background: var(--ad-surface);
    color: var(--ad-ink-2);
    font-size: 13px;
  }

  .ad-topbar__search:hover {
    background: var(--ad-page);
  }

  /* the search as a real form: the input has no border of its own, the form draws it */
  .ad-topbar__search input[type="search"] {
    inline-size: 160px;
    min-inline-size: 0;
    block-size: 100%;
    border: 0;
    background: transparent;
    color: var(--ad-ink);
    outline: 0;
  }

  .ad-topbar__search input[type="search"]::placeholder {
    color: var(--ad-ink-2);
    opacity: 1;
  }

  .ad-topbar__search:focus-within {
    outline: 2px solid var(--ad-primary);
    outline-offset: 2px;
  }

  .ad-kbd {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid var(--ad-line);
    border-radius: 4px;
    background: var(--ad-page);
    color: var(--ad-ink-2);
    font-family: inherit;
    font-weight: 700;
    direction: ltr;
  }

  .ad-iconbtn {
    position: relative;
    display: inline-grid;
    place-items: center;
    inline-size: 40px;
    block-size: 40px;
    border: 0;
    border-radius: var(--ad-radius);
    background: transparent;
    color: var(--ad-ink-2);
  }

  /* invisible 2 px ring around the 40 px button: the tap target is 44 px */
  .ad-iconbtn::before {
    content: "";
    position: absolute;
    inset: -2px;
  }

  .ad-iconbtn:hover {
    background: var(--ad-page);
    color: var(--ad-ink);
  }

  /* corner badge on the bell: 18 px high, border-box, pinned outside the top end corner of the
     40 px button and anchored at its inline end, so more digits grow away from the bell. The
     glyph box is the centred 20 px (10 px to 30 px from each side). With the end offset of
     -9 px a badge of 24 px (2 digits) spans -9 px to 15 px from the end edge, so it overlaps the
     glyph box by 5 px at most (25 %); a 1 digit badge (18 px) does not touch it. The 2 px ring
     is the topbar colour (surface), drawn with box-shadow so it adds no size. White on
     danger-fill is 5.35 (unchanged). Sidebar badges (.ad-nav-item .ad-badge) are not matched. */
  .ad-iconbtn .ad-badge {
    position: absolute;
    inset-block-start: 2px;
    inset-inline-end: -9px;
    box-sizing: border-box;
    min-inline-size: 18px;
    block-size: 18px;
    padding-inline: 5px;
    border: 0;
    border-radius: 999px;
    box-shadow: 0 0 0 2px var(--ad-surface);
    font-size: 11px;
    line-height: 18px;
    font-weight: 700;
  }

  .ad-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border: 0;
    border-radius: var(--ad-radius);
    background: transparent;
    text-align: start;
  }

  .ad-user:hover {
    background: var(--ad-page);
  }

  .ad-user__avatar {
    inline-size: 32px;
    block-size: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--ad-primary-soft);
    color: var(--ad-primary-text);
    font-weight: 700;
    font-size: 13px;
  }

  .ad-user__name {
    display: block;
    font-size: 13px;
    line-height: 18px;
    font-weight: 700;
    color: var(--ad-ink);
  }

  .ad-user__role {
    display: block;
    font-size: 12px;
    line-height: 16px;
    color: var(--ad-ink-2);
  }

  /* ---- page header ---- */
  .ad-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
  }

  .ad-page-header__desc {
    margin-block-start: 2px;
    color: var(--ad-ink-2);
  }

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

  /* ---- scrim ---- */
  .ad-scrim {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(31, 42, 68, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
  }

  .ad-scrim.is-open {
    opacity: 1;
    visibility: visible;
  }

  /* the drawer exists only under 1024 px, so the scrim never shows on desktop */
  @media (min-width: 1024px) {
    .ad-scrim {
      display: none;
    }
  }

  /* ======================================================================
     KIT
     ====================================================================== */

  /* ---- buttons ---- */
  .ad-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    block-size: var(--ad-control-h);
    padding-inline: 16px;
    border: 1px solid transparent;
    border-radius: var(--ad-radius);
    background: transparent;
    color: var(--ad-ink);
    font-size: 14px;
    line-height: 20px;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color 0.12s ease, border-color 0.12s ease;
  }

  .ad-btn:hover {
    text-decoration: none;
  }

  .ad-btn--primary {
    background: var(--ad-primary);
    color: #ffffff;
  }

  .ad-btn--primary:hover {
    background: var(--ad-primary-hover);
    color: #ffffff;
  }

  .ad-btn--secondary {
    background: var(--ad-surface);
    border-color: var(--ad-line-strong);
    color: var(--ad-ink);
  }

  .ad-btn--secondary:hover {
    background: var(--ad-page);
  }

  .ad-btn--ghost {
    color: var(--ad-primary-text);
  }

  .ad-btn--ghost:hover {
    background: var(--ad-primary-soft);
  }

  .ad-btn--danger {
    background: var(--ad-danger-fill);
    color: #ffffff;
  }

  .ad-btn--danger:hover {
    background: var(--ad-danger-hover);
    color: #ffffff;
  }

  .ad-btn--sm {
    block-size: 32px;
    padding-inline: 12px;
    font-size: 13px;
  }

  .ad-btn--icon {
    inline-size: var(--ad-control-h);
    padding-inline: 0;
  }

  .ad-btn--sm.ad-btn--icon {
    inline-size: 32px;
  }

  .ad-btn[disabled],
  .ad-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
  }

  /* ---- card ---- */
  .ad-card {
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius-card);
    box-shadow: var(--ad-shadow-card);
    padding: var(--ad-card-pad);
  }

  .ad-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-block-end: 12px;
  }

  .ad-card__note {
    margin-block-start: 2px;
    font-size: 12px;
    line-height: 16px;
    color: var(--ad-ink-2);
  }

  /* ---- KPI ---- */
  .ad-kpis {
    display: grid;
    gap: var(--ad-gap);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ad-kpi {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-inline-size: 0;
    padding: var(--ad-card-pad);
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius-card);
    box-shadow: var(--ad-shadow-card);
  }

  .ad-kpi__label {
    font-size: 13px;
    line-height: 20px;
    color: var(--ad-ink-2);
  }

  .ad-kpi__value {
    font-size: 28px;
    line-height: 36px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .ad-kpi__delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 700;
    color: var(--ad-ink-2);
  }

  .ad-kpi__delta .ad-icon {
    inline-size: 16px;
    block-size: 16px;
  }

  .ad-kpi__delta--up { color: var(--ad-success-text); }
  .ad-kpi__delta--down { color: var(--ad-danger-text); }
  .ad-kpi__delta--flat { color: var(--ad-ink-2); }

  .ad-kpi__spark {
    inline-size: 100%;
    block-size: 32px;
    margin-block-start: 4px;
    fill: none;
    stroke: var(--ad-primary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* two labelled KPI groups of the admin home, side by side from 1024 px */
  .ad-home-kpis {
    display: grid;
    gap: var(--ad-gap);
    grid-template-columns: minmax(0, 1fr);
  }

  .ad-kpi-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-inline-size: 0;
  }

  .ad-kpi-group__title {
    margin: 0;
    font-size: 13px;
    line-height: 20px;
    font-weight: 600;
    color: var(--ad-ink-2);
  }

  /* three tiles: 2 columns below 480 px (the odd last tile spans both), then 3 equal columns */
  .ad-kpis.ad-kpis--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ad-kpis.ad-kpis--3 > .ad-kpi:last-child:nth-child(odd) {
    grid-column: span 2;
  }

  .ad-kpis--3 .ad-kpi__value {
    font-size: 22px;
    line-height: 30px;
    overflow-wrap: anywhere;
  }

  @media (min-width: 480px) {
    .ad-kpis.ad-kpis--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ad-kpis.ad-kpis--3 > .ad-kpi:last-child:nth-child(odd) { grid-column: auto; }
  }

  @media (min-width: 1024px) {
    .ad-home-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }

  @media (min-width: 1440px) {
    .ad-kpis--3 .ad-kpi__value {
      font-size: 28px;
      line-height: 36px;
    }
  }

  /* ---- action tiles (admin home, items that need a follow-up) ---- */
  .ad-actions {
    display: grid;
    gap: var(--ad-gap);
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .ad-action {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "count go"
      "title go";
    align-items: center;
    column-gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius-card);
    background: var(--ad-surface);
    color: var(--ad-ink);
    text-decoration: none;
    transition: border-color 120ms, background-color 120ms;
  }

  .ad-action:hover {
    border-color: var(--ad-primary);
    background: var(--ad-page);
    text-decoration: none;
  }

  .ad-action__count {
    grid-area: count;
    font-size: 22px;
    line-height: 1.2;
    font-weight: 700;
  }

  .ad-action__title {
    grid-area: title;
    font-size: 13px;
    line-height: 20px;
    color: var(--ad-ink-2);
  }

  .ad-action__go {
    grid-area: go;
    inline-size: 16px;
    block-size: 16px;
    color: var(--ad-ink-2);
    /* chevron drawn pointing to the end; flips with the writing direction */
    transform: scaleX(calc(var(--ad-flip) * -1));
  }

  .ad-action:hover .ad-action__go {
    color: var(--ad-primary-text);
  }

  @media (prefers-reduced-motion: reduce) {
    .ad-action { transition: none; }
  }

  /* ---- collapsible block (a table behind a summary line) ---- */
  .ad-details > summary {
    padding-block: 8px;
    font-weight: 600;
    color: var(--ad-primary-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .ad-details > summary::before {
    content: '';
    inline-size: 0.45em;
    block-size: 0.45em;
    border-inline-end: 2px solid currentColor;
    border-block-end: 2px solid currentColor;
    transform: rotate(calc(var(--ad-flip) * 45deg));
    transition: transform 0.15s ease;
  }

  .ad-details[open] > summary::before {
    transform: rotate(calc(var(--ad-flip) * -45deg));
  }

  @media (prefers-reduced-motion: reduce) {
    .ad-details > summary::before {
      transition: none;
    }
  }

  .ad-details[open] > summary {
    margin-block-end: 8px;
  }

  /* ---- chips ---- */
  .ad-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    block-size: 24px;
    padding-inline: 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
    background: var(--ad-page);
    color: var(--ad-ink-2);
  }

  .ad-chip .ad-icon {
    inline-size: 14px;
    block-size: 14px;
  }

  /* neutral: hairline border kept; ink text because ink-2 on neutral-soft is only 4.44 */
  .ad-chip--neutral {
    background: var(--ad-neutral-soft);
    border-color: var(--ad-line);
    color: var(--ad-ink);
  }

  .ad-chip--success {
    background: var(--ad-success-soft);
    color: var(--ad-success-text);
  }

  .ad-chip--info {
    background: var(--ad-info-soft);
    color: var(--ad-info-text);
  }

  .ad-chip--danger {
    background: var(--ad-danger-soft);
    color: var(--ad-danger-text);
  }

  /* warning: soft background + warning text only, never a filled orange */
  .ad-chip--warning {
    background: var(--ad-warning-soft);
    color: var(--ad-warning-text);
  }

  .ad-chip--filter {
    background: var(--ad-primary-soft);
    color: var(--ad-primary-text);
    padding-inline-end: 2px;
  }

  .ad-chip__x {
    display: inline-grid;
    place-items: center;
    inline-size: 20px;
    block-size: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
  }

  .ad-chip__x:hover {
    background: rgba(0, 90, 158, 0.14);
  }

  /* ---- filter bar ---- */
  .ad-filterbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px var(--ad-card-pad);
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius-card);
    box-shadow: var(--ad-shadow-card);
  }

  .ad-filterbar > .ad-row {
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
  }

  .ad-filterbar__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-inline-size: 180px;
  }

  .ad-filterbar__grow {
    flex: 1 1 240px;
  }

  .ad-filterbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-inline-start: auto;
  }

  .ad-filter-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  /* ---- side sheet ---- */
  .ad-sheet {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    inline-size: min(420px, 100vw);
    background: var(--ad-surface);
    box-shadow: var(--ad-shadow-pop);
    /* parked outside at the inline end; physical axis unavoidable for transform */
    transform: translateX(calc(var(--ad-flip) * -100%));
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
  }

  .ad-sheet.is-open {
    transform: none;
    visibility: visible;
  }

  .ad-sheet__head,
  .ad-sheet__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
  }

  .ad-sheet__head {
    border-block-end: 1px solid var(--ad-line);
  }

  .ad-sheet__foot {
    border-block-start: 1px solid var(--ad-line);
    justify-content: flex-start;
  }

  .ad-sheet__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  /* ---- table ---- */
  .ad-table-wrap {
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius-card);
    box-shadow: var(--ad-shadow-card);
    /* the wrap is the scroll container in both axes: wide tables scroll sideways and the
       header cells stick to the top of the wrap (see thead th below) */
    overflow: auto;
    max-block-size: min(70vh, 720px);
  }

  .ad-table__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
    border-block-end: 1px solid var(--ad-line);
    font-size: 13px;
  }

  .ad-table {
    inline-size: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }

  .ad-table th,
  .ad-table td {
    padding: 0 12px;
    block-size: 44px;
    text-align: start;
    vertical-align: middle;
    border-block-end: 1px solid var(--ad-line);
  }

  .ad-table--compact th,
  .ad-table--compact td {
    block-size: 36px;
  }

  .ad-table thead th {
    position: sticky;
    inset-block-start: 0;
    z-index: 1;
    background: var(--ad-surface-2);
    color: var(--ad-ink-2);
    font-size: 12px;
    white-space: nowrap;
  }

  .ad-table tbody tr:hover {
    background: var(--ad-page);
  }

  .ad-table tbody tr.is-selected {
    background: var(--ad-primary-soft);
  }

  .ad-table tbody tr:last-child td {
    border-block-end: 0;
  }

  .ad-table__check {
    inline-size: 44px;
    text-align: center;
  }

  .ad-table th.ad-table__num,
  .ad-table td.ad-table__num {
    font-variant-numeric: tabular-nums;
  }

  .ad-table__actions {
    inline-size: 1%;
    white-space: nowrap;
    text-align: end;
  }

  /* A wide table scrolls sideways inside its card (the shell clips sideways overflow, so without
     this the inline end, where the actions are, was cut off). The card head stays in place. */
  .ad-card:has(> .ad-table) {
    overflow-x: auto;
    min-inline-size: 0;
  }

  .ad-card:has(> .ad-table) > .ad-card__head {
    position: sticky;
    inset-inline-start: 0;
  }

  /* the actions column stays pinned at the inline end while the row scrolls under it */
  .ad-table th.ad-table__actions,
  .ad-table td.ad-table__actions {
    position: sticky;
    inset-inline-end: 0;
    z-index: 1;
    background: var(--ad-surface);
    box-shadow: calc(var(--ad-flip) * 6px) 0 6px -6px var(--ad-shadow-edge);
  }

  .ad-table thead th.ad-table__actions {
    z-index: 2;
    background: var(--ad-surface-2);
  }

  .ad-table tbody tr:hover > td.ad-table__actions {
    background: var(--ad-page);
  }

  .ad-table tbody tr.is-selected > td.ad-table__actions {
    background: var(--ad-primary-soft);
  }

  /* row actions: one line at the inline end; rowActions.js adds .ad-row-actions to the wrapper
     (or to the td) and moves extra actions into the popover menu .ad-row-actions__menu */
  .ad-row-actions {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
  }

  td.ad-row-actions {
    display: table-cell;
  }

  td.ad-row-actions > * + * {
    margin-inline-start: 4px;
  }

  .ad-table__actions .ad-confirm {
    display: inline-flex;
  }

  /* a delete trigger that stays inline is an outlined button, never a filled one */
  .ad-table__actions .ad-btn--danger {
    background: transparent;
    color: var(--ad-danger-text);
    border: 1px solid var(--ad-line);
  }

  .ad-table__actions .ad-btn--danger:hover {
    background: var(--ad-danger-soft);
  }

  .ad-menu__panel.ad-row-actions__menu {
    position: fixed;
    inset: auto;
    margin: 0;
    display: none;
  }

  .ad-menu__panel.ad-row-actions__menu:popover-open {
    display: block;
  }

  .ad-table__actions .ad-row-actions__menu form {
    display: block;
    margin: 0;
  }

  .ad-row-actions__menu .ad-menu__item {
    display: flex;
    inline-size: 100%;
    min-block-size: 36px;
    cursor: pointer;
  }

  .ad-row-actions__menu .ad-menu__item .ad-icon {
    inline-size: 16px;
    block-size: 16px;
  }

  .ad-row-actions__menu .ad-menu__item:focus-visible {
    outline: 2px solid var(--ad-primary);
    outline-offset: 2px;
  }

  .ad-table__link {
    color: var(--ad-link);
    font-weight: 700;
  }

  .ad-sort {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-weight: 700;
    font-size: inherit;
  }

  .ad-sort .ad-icon {
    inline-size: 14px;
    block-size: 14px;
    opacity: 0.55;
  }

  .ad-table th[aria-sort] .ad-sort {
    color: var(--ad-ink);
  }

  .ad-table th[aria-sort] .ad-icon {
    opacity: 1;
  }

  .ad-table th[aria-sort="descending"] .ad-icon {
    transform: scaleY(-1);
  }

  .ad-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 8px 16px;
    border-block-start: 1px solid var(--ad-line);
    background: var(--ad-surface);
  }

  .ad-pagination__info {
    color: var(--ad-ink-2);
  }

  .ad-pagination__pages {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .ad-page {
    display: inline-grid;
    place-items: center;
    min-inline-size: 32px;
    block-size: 32px;
    padding-inline: 6px;
    border: 1px solid transparent;
    border-radius: var(--ad-radius);
    background: transparent;
    color: var(--ad-ink);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
  }

  .ad-page:hover {
    background: var(--ad-page);
    text-decoration: none;
  }

  .ad-page.is-current {
    background: var(--ad-primary-soft);
    border-color: var(--ad-primary);
    color: var(--ad-primary-text);
    font-weight: 700;
  }

  /* ---- forms ---- */
  .ad-form {
    display: flex;
    flex-direction: column;
    gap: var(--ad-gap);
  }

  .ad-form__section {
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius-card);
    box-shadow: var(--ad-shadow-card);
    padding: var(--ad-card-pad);
  }

  .ad-form__title {
    margin-block-end: 16px;
    padding-block-end: 8px;
    border-block-end: 1px solid var(--ad-line);
  }

  .ad-form__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .ad-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-inline-size: 0;
  }

  .ad-req {
    color: var(--ad-danger-text);
    margin-inline-start: 2px;
  }

  .ad-input,
  .ad-select,
  .ad-textarea {
    inline-size: 100%;
    block-size: var(--ad-control-h);
    padding-inline: 12px;
    border: 1px solid var(--ad-line-strong);
    border-radius: var(--ad-radius);
    background: var(--ad-surface);
    color: var(--ad-ink);
    font-size: 14px;
  }

  .ad-input::placeholder,
  .ad-textarea::placeholder {
    color: var(--ad-ink-3);
    opacity: 1;
  }

  .ad-textarea {
    block-size: auto;
    min-block-size: 96px;
    padding-block: 8px;
    resize: vertical;
  }

  .ad-select {
    appearance: none;
    padding-inline-end: 36px;
    /* chevron as inline data URI; position is physical because background-position has no logical form */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364707b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 10px center;
  }

  html[dir="ltr"] & .ad-select {
    background-position: right 10px center;
  }

  .ad-input:focus-visible,
  .ad-select:focus-visible,
  .ad-textarea:focus-visible {
    border-color: var(--ad-primary);
  }

  .ad-input[disabled],
  .ad-select[disabled],
  .ad-textarea[disabled] {
    background: var(--ad-page);
    cursor: not-allowed;
  }

  .ad-field.has-error .ad-input,
  .ad-field.has-error .ad-select,
  .ad-field.has-error .ad-textarea {
    border-color: var(--ad-danger-text);
  }

  .ad-help {
    color: var(--ad-ink-2);
  }

  .ad-error {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--ad-danger-text);
    font-weight: 700;
  }

  .ad-error .ad-icon {
    inline-size: 16px;
    block-size: 16px;
  }

  .ad-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
  }

  .ad-check input {
    inline-size: 18px;
    block-size: 18px;
    margin: 0;
    accent-color: var(--ad-primary);
  }

  .ad-form__footer {
    position: sticky;
    inset-block-end: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px var(--ad-card-pad);
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius-card);
    box-shadow: 0 -2px 8px rgba(31, 42, 68, 0.08);
  }

  /* ---- tabs ---- */
  .ad-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-block-end: 1px solid var(--ad-line);
    scrollbar-width: none;
  }

  .ad-tab {
    flex: none;
    padding: 10px 16px;
    margin-block-end: -1px;
    border: 0;
    border-block-end: 2px solid transparent;
    background: transparent;
    color: var(--ad-ink-2);
    font-weight: 700;
    white-space: nowrap;
  }

  .ad-tab:hover {
    color: var(--ad-ink);
  }

  .ad-tab[aria-selected="true"] {
    color: var(--ad-primary-text);
    border-block-end-color: var(--ad-primary);
  }

  /* ---- alerts ---- */
  .ad-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--ad-radius);
    border-inline-start: 4px solid var(--ad-info-text);
    background: var(--ad-info-soft);
    color: var(--ad-ink);
  }

  .ad-alert > .ad-icon {
    margin-block-start: 1px;
    color: var(--ad-info-text);
  }

  .ad-alert__title {
    display: block;
    font-weight: 700;
    color: var(--ad-info-text);
  }

  .ad-alert--success { background: var(--ad-success-soft); border-inline-start-color: var(--ad-success-text); }
  .ad-alert--success > .ad-icon, .ad-alert--success .ad-alert__title { color: var(--ad-success-text); }
  .ad-alert--warning { background: var(--ad-warning-soft); border-inline-start-color: var(--ad-warning-text); }
  .ad-alert--warning > .ad-icon, .ad-alert--warning .ad-alert__title { color: var(--ad-warning-text); }
  .ad-alert--danger { background: var(--ad-danger-soft); border-inline-start-color: var(--ad-danger-text); }
  .ad-alert--danger > .ad-icon, .ad-alert--danger .ad-alert__title { color: var(--ad-danger-text); }

  /* ---- toast ---- */
  .ad-toast-region {
    position: fixed;
    inset-block-start: calc(var(--ad-topline-h) + var(--ad-topbar-h) + 12px);
    inset-inline-end: 16px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 8px;
    inline-size: min(380px, calc(100vw - 32px));
  }

  .ad-toast-region--static {
    position: static;
    inline-size: min(380px, 100%);
  }

  .ad-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--ad-surface);
    color: var(--ad-ink);
    border: 1px solid var(--ad-line);
    border-inline-start: 4px solid var(--ad-info-text);
    border-radius: var(--ad-radius);
    box-shadow: var(--ad-shadow-pop);
  }

  .ad-toast > .ad-icon { color: var(--ad-info-text); }
  .ad-toast--success { border-inline-start-color: var(--ad-success-text); }
  .ad-toast--success > .ad-icon { color: var(--ad-success-text); }
  .ad-toast--warning { border-inline-start-color: var(--ad-warning-text); }
  .ad-toast--warning > .ad-icon { color: var(--ad-warning-text); }
  .ad-toast--danger { border-inline-start-color: var(--ad-danger-text); }
  .ad-toast--danger > .ad-icon { color: var(--ad-danger-text); }

  /* ---- empty state ---- */
  .ad-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 16px;
    text-align: center;
  }

  .ad-empty__icon {
    inline-size: 48px;
    block-size: 48px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--ad-page);
    color: var(--ad-ink-2);
  }

  .ad-empty__icon .ad-icon {
    inline-size: 24px;
    block-size: 24px;
  }

  .ad-empty__text {
    color: var(--ad-ink-2);
  }

  /* ---- skeleton ---- */
  .ad-skeleton {
    display: block;
    block-size: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--ad-line) 25%, var(--ad-page) 50%, var(--ad-line) 75%);
    background-size: 200% 100%;
    animation: ad-shimmer 1.4s linear infinite;
  }

  .ad-skeleton--line { block-size: 12px; }
  .ad-skeleton--title { block-size: 20px; inline-size: 40%; }
  .ad-skeleton--row { block-size: 44px; border-radius: 0; }

  @keyframes ad-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
  }

  /* ---- dialog ---- */
  .ad-dialog {
    inline-size: min(440px, calc(100vw - 32px));
    padding: 20px;
    border: 0;
    border-radius: var(--ad-radius-card);
    background: var(--ad-surface);
    color: var(--ad-ink);
    box-shadow: var(--ad-shadow-pop);
  }

  .ad-dialog::backdrop {
    background: rgba(31, 42, 68, 0.55);
  }

  .ad-dialog--static {
    border: 1px solid var(--ad-line);
  }

  .ad-dialog__title {
    font-size: 16px;
    line-height: 24px;
    font-weight: 700;
  }

  .ad-dialog__body {
    margin-block: 8px 20px;
    color: var(--ad-ink-2);
  }

  .ad-dialog__body b {
    color: var(--ad-ink);
  }

  .ad-dialog__foot {
    display: flex;
    gap: 8px;
  }

  /* ---- chart card ---- */
  /* Cards of the shared chart kit (React islands) look like every other admin card. */
  [data-slot="chart-card"] { box-shadow: var(--ad-shadow-card); border-color: var(--ad-line); }
  [data-slot="chart-card"] h3 { font-size: 16px; line-height: 24px; font-weight: 700; color: var(--ad-ink); }
  [data-slot="chart-toggle"] { block-size: 32px; padding-inline: 10px; gap: 6px; font-size: 12px; line-height: 16px; }
  [data-slot="chart-toggle"] svg { inline-size: 16px; block-size: 16px; }
  .ad-grid > .ad-chart-wide { grid-column: 1 / -1; }
  /* The column chooser and the export menu at the end of the table bar. */
  .ad-table__bar-tools { display: flex; align-items: center; gap: 8px; }
  /* A group of filters in the more-filters sheet. */
  .ad-fieldset { border: 0; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
  .ad-fieldset__legend { padding: 0 0 8px; margin-block-end: 4px; inline-size: 100%; border-block-end: 1px solid var(--ad-line); font-size: 13px; line-height: 20px; font-weight: 700; color: var(--ad-ink-2); }

  .ad-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius-card);
    box-shadow: var(--ad-shadow-card);
    padding: var(--ad-card-pad);
    min-inline-size: 0;
  }

  .ad-chart__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .ad-chart__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    font-size: 12px;
    line-height: 16px;
    color: var(--ad-ink-2);
  }

  .ad-chart__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .ad-chart__swatch {
    inline-size: 12px;
    block-size: 12px;
    border-radius: 3px;
    background: var(--ad-series-1);
  }

  .ad-chart__swatch[data-series="2"] { background: var(--ad-series-2); border-radius: 50%; }
  .ad-chart__swatch[data-series="3"] { background: var(--ad-series-3); border-radius: 1px; transform: rotate(45deg) scale(0.8); }
  .ad-chart__swatch[data-series="4"] { background: var(--ad-series-4); border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
  .ad-chart__swatch[data-series="5"] { background: var(--ad-series-5); }
  .ad-chart__swatch[data-series="6"] { background: var(--ad-series-6); }

  /* A chart is scaled with its viewBox, so the rendered text size is
       rendered px = font-size (user units) x svg rendered width / viewBox width.
     Text is set to 15 units; to keep it at 12 px or more the svg may not render narrower than
       12 / 15 = 0.8 of its viewBox width.
     Each svg states its viewBox width in --ad-chart-vbw (unitless, default 600) and the minimum
     width is 0.8 x that. Below this width the body scrolls sideways (focusable, tabindex="0"). */
  .ad-chart__body {
    min-block-size: 200px;
    overflow-x: auto;
  }

  .ad-chart__body:focus-visible {
    outline: 2px solid var(--ad-primary);
    outline-offset: 2px;
    border-radius: var(--ad-radius);
  }

  .ad-chart__svg {
    display: block;
    inline-size: 100%;
    min-inline-size: calc(var(--ad-chart-vbw, 600) * 0.8px);
    block-size: auto;
    direction: ltr;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
  }

  .ad-chart__svg text {
    fill: var(--ad-ink-2);
    font-size: 15px;
  }

  .ad-chart__link {
    align-self: flex-start;
    font-size: 13px;
    font-weight: 700;
  }

  /* Sideways scroll cue. JS adds .is-scrollable when the content is wider than the body, and
     .is-fade-l / .is-fade-r on the side where more content is hidden. The fade is a mask, so it
     only exists while there is something to scroll to. The gradient axis is physical because
     the scroll offset is physical. While the body has keyboard focus the mask is off, so the
     focus ring is never cut. */
  .ad-chart__body.is-scrollable {
    --ad-fade-l: 0px;
    --ad-fade-r: 0px;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--ad-fade-l), #000 calc(100% - var(--ad-fade-r)), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 var(--ad-fade-l), #000 calc(100% - var(--ad-fade-r)), transparent 100%);
  }

  .ad-chart__body.is-scrollable.is-fade-l { --ad-fade-l: 28px; }
  .ad-chart__body.is-scrollable.is-fade-r { --ad-fade-r: 28px; }

  .ad-chart__body.is-scrollable:focus-visible {
    -webkit-mask-image: none;
    mask-image: none;
  }

  .ad-chart__hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--ad-ink-2);
  }

  /* ---- horizontal bar list (replaces horizontal SVG bar charts) ----
     <ol class="ad-hbar" style="--max:16000"> with <li class="ad-hbar__row"> holding the label,
     the track with one bar (style="--v:15390") and the value. The bar width is v / max of the
     track and starts at the inline start (right in RTL). From 640 px one line per row
     (label 30 % | track | value); below 640 px the label has its own line above bar and value. */
  .ad-hbar {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-inline-size: 0;
  }

  .ad-hbar__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 56px;
    align-items: center;
    column-gap: 12px;
    row-gap: 0;
    min-block-size: 32px;
    padding-block: 2px;
  }

  .ad-hbar__label {
    grid-column: 1 / -1;
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    line-height: 20px;
    color: var(--ad-ink-2);
  }

  .ad-hbar__track {
    display: block;
    min-inline-size: 0;
    block-size: 12px;
  }

  .ad-hbar__bar {
    display: block;
    block-size: 12px;
    inline-size: calc(var(--v) / var(--max) * 100%);
    min-inline-size: 2px;
    max-inline-size: 100%;
    background: var(--ad-primary);
    border-start-end-radius: 4px;
    border-end-end-radius: 4px;
  }

  .ad-hbar__bar[data-series="1"] { background: var(--ad-series-1); }
  .ad-hbar__bar[data-series="2"] { background: var(--ad-series-2); }
  .ad-hbar__bar[data-series="3"] { background: var(--ad-series-3); }
  .ad-hbar__bar[data-series="4"] { background: var(--ad-series-4); }
  .ad-hbar__bar[data-series="6"] { background: var(--ad-series-6); }

  .ad-hbar__value {
    font-size: 13px;
    line-height: 20px;
    font-variant-numeric: tabular-nums;
    color: var(--ad-ink);
    text-align: end;
    white-space: nowrap;
  }

  @media (min-width: 640px) {
    .ad-hbar__row {
      grid-template-columns: 30% minmax(0, 1fr) 56px;
    }

    .ad-hbar__label {
      grid-column: auto;
    }
  }

  /* ---- dropdown menu (export, user, kebab) ---- */
  .ad-menu {
    position: relative;
    display: inline-block;
  }

  .ad-menu__panel {
    position: absolute;
    inset-block-start: calc(100% + 4px);
    inset-inline-end: 0;
    z-index: 50;
    display: none;
    min-inline-size: 200px;
    padding: 4px;
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius);
    box-shadow: var(--ad-shadow-pop);
  }

  .ad-menu__panel.is-open {
    display: block;
  }

  .ad-menu__head {
    padding: 8px 12px;
    border-block-end: 1px solid var(--ad-line);
    margin-block-end: 4px;
  }

  .ad-menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    inline-size: 100%;
    min-block-size: 36px;
    padding: 6px 12px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--ad-ink);
    font-size: 14px;
    text-align: start;
    text-decoration: none;
  }

  .ad-menu__item:hover {
    background: var(--ad-page);
    text-decoration: none;
  }

  .ad-menu__item--danger {
    color: var(--ad-danger-text);
  }

  /* group label inside a menu (theme choice) */
  .ad-menu__label {
    display: block;
    padding: 4px 12px 0;
    color: var(--ad-ink-2);
    font-size: 12px;
    font-weight: 700;
  }

  .ad-menu__item[aria-checked="true"] {
    color: var(--ad-primary-text);
    font-weight: 700;
  }

  .ad-menu__item[aria-checked="true"]::after {
    content: "✓";
    margin-inline-start: auto;
  }

  .ad-menu__sep {
    block-size: 1px;
    margin-block: 4px;
    background: var(--ad-line);
  }

  /* ======================================================================
     RESPONSIVE
     ====================================================================== */
  @media (min-width: 640px) {
    .ad-grid--2, .ad-grid--3, .ad-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ad-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }

  @media (min-width: 1024px) {
    .ad-form__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ad-form__full { grid-column: 1 / -1; }
    .ad-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ad-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ad-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }

  @media (min-width: 1440px) {
    --ad-card-pad: 20px;
  }

  /* drawer: under 1024 px the sidebar leaves the flow and slides in from the inline start */
  @media (max-width: 1023.98px) {
    .ad-sidebar {
      position: fixed;
      inset-block: var(--ad-topline-h) 0;
      inset-inline-start: 0;
      block-size: auto;
      /* never wider than the viewport, so the open drawer sits fully inside it */
      max-inline-size: 100vw;
      z-index: 80;
      transform: translateX(calc(var(--ad-flip) * 100%));
      visibility: hidden;
      transition: transform 0.2s ease, visibility 0.2s;
    }

    .ad-sidebar.is-open {
      transform: none;
      visibility: visible;
    }

    .ad-topbar {
      padding-inline: 16px;
    }
  }

  /* 1024 px and wider: the hamburger collapses the sidebar. shell.js sets the class on <html>,
     which is outside [data-app="admin"], so the selector puts & after it. */
  @media (min-width: 1024px) {
    .ad-nav-collapsed & .ad-sidebar {
      display: none;
    }
  }

  @media (max-width: 639.98px) {
    .ad-content {
      padding: 16px;
    }

    /* KPI: two tiles per row at 390 px (about 171 px each); long labels wrap */
    .ad-kpi {
      padding: 12px;
    }

    .ad-kpi__label {
      overflow-wrap: anywhere;
    }

    .ad-kpi__value {
      font-size: 22px;
      line-height: 28px;
    }

    .ad-topbar {
      gap: 8px;
      padding-inline: 12px;
    }

    /* breadcrumb: only the last item stays, earlier items and separators are hidden */
    .ad-breadcrumb > li:not(:last-child) {
      display: none;
    }

    /* search: icon button only, 44 x 44 tap target; text and key hint hidden */
    .ad-topbar__search {
      inline-size: 44px;
      block-size: 44px;
      padding: 0;
      justify-content: center;
    }

    .ad-topbar__search > span,
    .ad-topbar__search .ad-kbd {
      display: none;
    }

    /* the search as a form (--form) keeps a short input next to the icon */
    .ad-topbar__search--form {
      inline-size: auto;
      block-size: 36px;
      padding-inline: 8px;
      justify-content: flex-start;
    }

    .ad-topbar__search--form input[type="search"] {
      inline-size: 88px;
    }

    /* user menu: avatar (and chevron) only; the wrapper of name and role is hidden with them */
    .ad-user > span:not(.ad-user__avatar),
    .ad-user__name,
    .ad-user__role {
      display: none;
    }

    .ad-menu__head .ad-user__name,
    .ad-menu__head .ad-user__role {
      display: block;
    }

    .ad-page-header,
    .ad-page-header > * {
      min-inline-size: 0;
    }

    .ad-page-header__actions {
      inline-size: 100%;
      flex-wrap: wrap;
    }

    .ad-filterbar__field,
    .ad-filterbar__grow {
      flex: 1 1 100%;
      inline-size: 100%;
      min-inline-size: 0;
    }

    .ad-filterbar__actions {
      inline-size: 100%;
      margin-inline-start: 0;
      flex-wrap: wrap;
    }

    .ad-filterbar__actions > .ad-btn {
      flex: 1 1 100%;
      min-inline-size: 0;
    }

    .ad-pagination {
      justify-content: center;
    }

    /* card layout: the wrap grows with its rows */
    .ad-table-wrap {
      max-block-size: none;
    }

    /* table rows become cards; each td carries data-label */
    .ad-table,
    .ad-table tbody,
    .ad-table tr,
    .ad-table td {
      display: block;
    }

    .ad-table thead {
      position: absolute;
      inline-size: 1px;
      block-size: 1px;
      overflow: hidden;
      clip-path: inset(50%);
    }

    .ad-table tbody tr {
      position: relative;
      padding: 8px 16px;
      border-block-end: 1px solid var(--ad-line);
    }

    .ad-table th,
    .ad-table td {
      block-size: auto;
      border: 0;
    }

    .ad-table td {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      min-block-size: 32px;
      padding: 4px 0;
      text-align: end;
    }

    .ad-table td[data-label]::before {
      content: attr(data-label);
      flex: none;
      color: var(--ad-ink-2);
      font-size: 12px;
      font-weight: 700;
      text-align: start;
    }

    .ad-table td.ad-table__check,
    .ad-table td.ad-table__actions {
      inline-size: auto;
    }

    .ad-table td > * {
      min-inline-size: 0;
      overflow-wrap: anywhere;
    }

    /* mixed cell content (tableLabels.js): one column at the inline end, next to the label */
    .ad-table td > .ad-table__value {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 4px;
      text-align: end;
    }

    .ad-table td > .ad-table__value > .ad-row {
      justify-content: flex-end;
    }

    /* cards do not scroll sideways */
    .ad-card:has(> .ad-table) {
      overflow-x: visible;
    }

    /* actions: their own row at the foot of the card, never on top of the content */
    .ad-table td.ad-table__actions {
      position: static;
      flex-wrap: wrap;
      justify-content: flex-start;
      gap: 8px;
      margin-block-start: 4px;
      padding-block: 8px 0;
      border-block-start: 1px solid var(--ad-line);
      background: transparent;
      box-shadow: none;
      white-space: normal;
      text-align: start;
    }

    .ad-table td.ad-table__actions > .ad-row,
    .ad-table td.ad-table__actions > .ad-row-actions {
      flex-wrap: wrap;
      justify-content: flex-start;
      gap: 8px;
    }

    .ad-table td.ad-table__actions .ad-btn {
      min-block-size: 44px;
    }

    .ad-table tbody tr:last-child {
      border-block-end: 0;
    }
  }

  /* ======================================================================
     PRINT
     ====================================================================== */
  @media print {
    background: #ffffff;

    .ad-topline,
    .ad-sidebar,
    .ad-topbar,
    .ad-scrim,
    .ad-sheet,
    .ad-filterbar,
    .ad-form__footer,
    .ad-toast-region,
    .ad-menu,
    .ad-btn,
    .ad-table__bar,
    .ad-pagination,
    .ad-hide-print {
      display: none !important;
    }

    .ad-shell,
    .ad-main {
      display: block;
    }

    .ad-content {
      max-inline-size: none;
      padding: 0;
    }

    .ad-card,
    .ad-kpi,
    .ad-chart,
    .ad-table-wrap {
      box-shadow: none;
      break-inside: avoid;
    }

    .ad-table-wrap {
      overflow: visible;
      max-block-size: none;
    }

    .ad-table {
      inline-size: 100%;
    }

    .ad-table thead th {
      position: static;
    }

    .ad-card:has(> .ad-table) {
      overflow: visible;
    }

    .ad-table th.ad-table__actions,
    .ad-table td.ad-table__actions {
      position: static;
      box-shadow: none;
    }

    .ad-table thead {
      display: table-header-group;
    }

    .ad-table tr {
      break-inside: avoid;
    }

    a {
      color: inherit;
    }
  }

  /* ---- select2 (a few old forms): follow the theme tokens ---- */
  .select2-container--default .select2-selection--single,
  .select2-container--default .select2-selection--multiple,
  .select2-dropdown,
  .select2-search__field {
    background: var(--ad-surface);
    color: var(--ad-ink);
    border-color: var(--ad-line-strong);
  }
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--ad-ink);
  }
  .select2-container--default .select2-results__option[aria-selected="true"] {
    background: var(--ad-neutral-soft);
  }
  .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--ad-primary);
    color: #ffffff;
  }

  /* ---- combobox island (enhances select[data-combobox]) ---- */
  .ad-combo { position: relative; }
  .ad-combo__box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-block-size: var(--ad-control-h);
    padding: 3px 12px;
    border: 1px solid var(--ad-line-strong);
    border-radius: var(--ad-radius);
    background: var(--ad-surface);
    cursor: text;
  }
  .ad-combo__box:focus-within,
  .ad-combo__box.is-open { border-color: var(--ad-primary); }
  .ad-combo__box:focus-within { outline: 2px solid var(--ad-primary); outline-offset: 2px; }
  .ad-combo__chips { display: contents; }
  .ad-combo__input {
    flex: 1 1 120px;
    min-inline-size: 80px;
    block-size: 32px;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ad-ink);
    font: inherit;
    font-size: 14px;
  }
  .ad-combo__input::placeholder { color: var(--ad-ink-3); opacity: 1; }
  .ad-combo__chev { color: var(--ad-ink-2); margin-inline-start: auto; pointer-events: none; flex: none; }
  .ad-combo__box.is-open .ad-combo__chev { transform: rotate(180deg); }
  .ad-combo__list {
    position: absolute;
    inset-inline: 0;
    inset-block-start: calc(100% + 4px);
    z-index: 25;
    max-block-size: 240px;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius);
    background: var(--ad-surface);
    box-shadow: var(--ad-shadow-pop);
  }
  .ad-combo__list[hidden] { display: none; }
  .ad-combo__opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-block-size: 36px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
  }
  .ad-combo__opt:hover,
  .ad-combo__opt.is-active { background: var(--ad-page); }
  .ad-combo__opt[aria-selected="true"] {
    background: var(--ad-primary-soft);
    color: var(--ad-primary-text);
    font-weight: 700;
  }
  .ad-combo__tick { visibility: hidden; flex: none; }
  .ad-combo__opt[aria-selected="true"] .ad-combo__tick { visibility: visible; }
  .ad-combo__none { padding: 8px; color: var(--ad-ink-2); font-size: 13px; }

  /* ---- date picker popup (@lib/ui/DatePicker, markup of the islands/DatePicker) ---- */
  .datepicker__input-container { display: block; position: relative; }
  .datepicker__input-container .datepicker__input { inline-size: 100%; }
  /* the component sets left:0 inline; the popup must start at the inline start in RTL too */
  .datepicker__tether-element {
    inset-inline-start: 0 !important;
    left: auto !important;
    z-index: 40 !important;
  }
  .datepicker {
    inline-size: 280px;
    max-inline-size: calc(100vw - 32px);
    padding: 12px;
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius-card);
    background: var(--ad-surface);
    color: var(--ad-ink);
    box-shadow: var(--ad-shadow-pop);
    font-size: 14px;
    text-align: center;
  }
  .datepicker__triangle { display: none; }
  .datepicker__header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-block-end: 8px;
  }
  .datepicker__current-month {
    flex: 1;
    font-weight: 700;
    font-size: 14px;
    color: var(--ad-ink);
  }
  .datepicker__navigation {
    position: relative;
    flex: none;
    inline-size: 32px;
    block-size: 32px;
    border-radius: var(--ad-radius);
    cursor: pointer;
  }
  .datepicker__navigation:hover { background: var(--ad-page); }
  .datepicker__navigation::before {
    content: "";
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 50%;
    inline-size: 8px;
    block-size: 8px;
    border-block-start: 2px solid var(--ad-ink-2);
    border-inline-end: 2px solid var(--ad-ink-2);
  }
  /* the chevron is a corner box (top + inline-end borders); the angle depends on the direction */
  .datepicker__navigation::before { transform: translate(-50%, -50%) rotate(135deg); }
  .datepicker__navigation--previous::before { transform: translate(-50%, -50%) rotate(135deg); }
  .datepicker__navigation--next::before { transform: translate(-50%, -50%) rotate(-45deg); }
  html[dir="ltr"] & .datepicker__navigation--previous::before { transform: translate(-50%, -50%) rotate(-135deg); }
  html[dir="ltr"] & .datepicker__navigation--next::before { transform: translate(-50%, -50%) rotate(45deg); }
  /* the weekday names are the last child of the header: a full row under the month bar */
  .datepicker__header { flex-wrap: wrap; }
  .datepicker__header > div:last-child {
    display: flex;
    order: 5;
    inline-size: 100%;
    color: var(--ad-ink-2);
    font-size: 12px;
  }
  .datepicker__header > div:last-child .datepicker__day { block-size: 28px; line-height: 28px; cursor: default; }
  .datepicker__month { display: block; }
  .datepicker__week { display: flex; }
  .datepicker__day {
    flex: 1 1 0;
    min-inline-size: 0;
    block-size: 34px;
    line-height: 34px;
    border-radius: var(--ad-radius);
    color: var(--ad-ink);
    cursor: pointer;
    font-variant-numeric: tabular-nums;
  }
  .datepicker__header + .datepicker__month .datepicker__day:hover,
  .datepicker__week .datepicker__day:hover { background: var(--ad-page); }
  .datepicker__week .datepicker__day--outside-month { color: var(--ad-ink-3); }
  .datepicker__day--today { font-weight: 700; box-shadow: inset 0 0 0 1px var(--ad-primary); }
  .datepicker__week .datepicker__day--selected,
  .datepicker__week .datepicker__day--selected:hover {
    background: var(--ad-primary);
    color: #fff;
    font-weight: 700;
  }
  .datepicker__week .datepicker__day--disabled,
  .datepicker__week .datepicker__day--disabled:hover {
    background: transparent;
    color: var(--ad-ink-3);
    opacity: 0.5;
    cursor: not-allowed;
  }
  .datepicker__today-button {
    margin-block-start: 8px;
    padding: 6px;
    border-radius: var(--ad-radius);
    background: var(--ad-page);
    color: var(--ad-primary-text);
    font-weight: 700;
    cursor: pointer;
  }
  .datepicker__year-read-view {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 6px;
    border-radius: var(--ad-radius);
    cursor: pointer;
  }
  .datepicker__year-read-view:hover { background: var(--ad-page); }
  .datepicker__year-read-view--down-arrow {
    inline-size: 0;
    block-size: 0;
    border-inline: 4px solid transparent;
    border-block-start: 5px solid var(--ad-ink-2);
  }
  .datepicker__year-dropdown {
    position: absolute;
    inset-block-start: 100%;
    inset-inline: 25%;
    z-index: 2;
    padding: 4px;
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius);
    background: var(--ad-surface);
    box-shadow: var(--ad-shadow-pop);
  }
  .datepicker__year-option {
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
  }
  .datepicker__year-option:hover { background: var(--ad-page); }
  .datepicker__year-option--selected { position: absolute; inset-inline-start: 6px; color: var(--ad-primary-text); }
  .datepicker__navigation--years { display: block; inline-size: 100%; block-size: 20px; }
  .datepicker__navigation--years-upcoming::before { transform: translate(-50%, -25%) rotate(45deg); }
  .datepicker__navigation--years-previous::before { transform: translate(-50%, -75%) rotate(-135deg); }
  .datepicker .close-icon { display: none; }

  /* ---- reports (islands/report) ---- */
  .ad-rp-range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ad-rp-size { display: inline-flex; align-items: center; gap: 8px; }
  .ad-rp-size .ad-select { inline-size: 88px; }
  .ad-rp-cols { min-inline-size: 200px; max-block-size: 320px; overflow-y: auto; padding: 8px; }
  .ad-rp-cols__item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; }
  .ad-rp-note {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-inline-size: 280px;
    padding: 8px;
    border-block-start: 1px solid var(--ad-line);
    color: var(--ad-ink);
    font-size: 13px;
  }
  .ad-grid--1 { grid-template-columns: minmax(0, 1fr); }
  /* KPIs: 2 columns, a last tile alone in its row spans both; from 1024 px one column per tile, at most 4 */
  .ad-rp .ad-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ad-rp .ad-kpis > .ad-kpi:last-child:nth-child(odd) { grid-column: span 2; }
  @media (min-width: 1024px) {
    .ad-rp .ad-kpis { grid-template-columns: repeat(var(--ad-kpi-cols, 4), minmax(0, 1fr)); }
    .ad-rp .ad-kpis > .ad-kpi:last-child:nth-child(odd) { grid-column: auto; }
  }
  /* sort control for the card layout: the table header is hidden below 640 px */
  .ad-rp-sort-mobile { display: none; }
  .ad-rp-sort-mobile__field { display: flex; flex: 1; align-items: center; gap: 8px; min-inline-size: 0; }
  .ad-rp-sort-mobile__field .ad-select { flex: 1; min-inline-size: 0; }
  @media (max-width: 639.98px) {
    .ad-rp-sort-mobile {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 16px;
      border-block-end: 1px solid var(--ad-line);
    }
  }
  /* long text cells: 3 lines until the button shows all of it */
  .ad-rp-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-inline-size: 0; }
  .ad-rp-cell__text { overflow-wrap: anywhere; }
  .ad-rp-cell__text.is-clamped {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
  }
  @media (max-width: 639.98px) {
    .ad-rp-cell { flex: 1; align-items: flex-end; }
  }
  /* desktop column widths: long and plain text columns keep a readable floor, figures and dates stay on one line */
  @media (min-width: 640px) {
    .ad-rp-col--wide { min-inline-size: 22rem; }
    .ad-rp-col--text { min-inline-size: 9rem; }
    .ad-rp-col--nowrap { white-space: nowrap; }
  }
  .ad-table-wrap.is-loading { opacity: 0.6; transition: opacity 0.15s; }
  .ad-page[disabled] { opacity: 0.55; cursor: not-allowed; }
}
