/*
 * Kulliyati -- the administration overview (templates/ui/admin_overview.html).
 *
 * Design: docs/design/visual-design.md, "Admin 'Needs attention' row" and
 * "Quick access tiles"; boards A-admin-phone / A-admin-desktop in the Indigo
 * colours. Phone: the sections stack, the counts read in three columns and the
 * tiles in two. Desktop: "Needs attention" and "Today across the faculty" sit
 * side by side when there is room, the tiles in five columns.
 *
 * Only adds rules to `@layer components` with var(--...) tokens from
 * static/css/app.css: no colour literals, gradients, blur or filters, shadows
 * only as the light theme's elevation tokens (tests/test_css_rules.py). Shared
 * components (.btn, .row, .row-list, .section-label) are static/css/components.css;
 * the selectors here carry the screen's own class first, and outrank a shared
 * rule's specificity, so they win whatever the link order.
 */
@layer components {
  /* Sections: 24px apart (Quick access 32px from 768px). The section labels'
     top margin spaces them (a flex item's margin does not collapse into a
     row gap, so the row gap stays 0). */
  .overview-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0 var(--space-4);
  }

  /* Specific enough (0,3,0) to beat components.css's
     `.overview-section + .overview-section` in any link order. */
  .overview-top > .overview-section,
  .overview-top > .overview-section + .overview-section {
    margin-top: 0;
    min-width: 0;
  }

  .overview-top > .attention {
    flex: 2 1 560px;
  }

  .overview-top > .faculty-today {
    flex: 1 1 300px;
  }

  .overview-top + .quick-access {
    margin-top: var(--space-6);
  }

  .overview-top .section-label,
  .quick-access .section-label {
    margin-top: var(--space-6);
    margin-bottom: var(--space-3);
  }

  /* "Needs attention": a tinted 36px circle by kind, a big bold count before
     what is waiting, a muted description, and the "Review" pill (.btn is the
     secondary button). The pill stays beside the text on phones too. */
  .attention-list .attention-row {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: var(--space-3);
    padding-block: var(--space-4);
  }

  .attention-row .attention-row__icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    inline-size: 36px;
    block-size: 36px;
    margin-top: var(--space-05);
    border-radius: 50%;
  }

  .attention-row .attention-row__icon .icon {
    inline-size: 18px;
    block-size: 18px;
    stroke-width: 2.25;
  }

  .attention-row .attention-row__icon--positive {
    background: var(--attend-positive-bg);
    color: var(--attend-positive-text);
  }

  .attention-row .attention-row__icon--warning {
    background: var(--attend-warning-bg);
    color: var(--attend-warning-text);
  }

  .attention-row .attention-row__icon--info {
    background: var(--attend-info-bg);
    color: var(--attend-info-text);
  }

  .attention-row .attention-row__icon--inactive {
    background: var(--attend-inactive-bg);
    color: var(--attend-inactive-text);
  }

  .attention-row .attention-row__icon--danger {
    background: var(--attend-danger-bg);
    color: var(--attend-danger-text);
  }

  .attention-row .attention-row__body {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .attention-row .row__title {
    font-size: var(--text-body);
    line-height: var(--leading-body);
    font-weight: var(--weight-strong);
  }

  .attention-row .attention-row__count {
    margin-inline-end: var(--space-05);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: 28px; /* 28/800 at every width (§7) */
    line-height: 32px;
    font-weight: var(--weight-display);
    font-variant-numeric: tabular-nums;
  }

  .attention-row .row__meta {
    color: var(--attend-text-muted);
  }

  .attention-list .attention-row__review {
    flex-shrink: 0;
    gap: var(--space-1);
    padding-inline: var(--space-4);
  }

  /* Nothing waiting: an "All caught up" card the height of the faculty card
     beside it (owner, 2026-11-02). Only an empty queue stretches the row. */
  .overview-top:has(.attention-clear) {
    align-items: stretch;
  }

  .overview-top > .attention:has(.attention-clear) {
    display: flex;
    flex-direction: column;
  }

  .attention .attention-clear {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-6) var(--space-4);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-lg);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-card);
    text-align: center;
  }

  .attention-clear .attention-clear__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 56px;
    block-size: 56px;
    margin-bottom: var(--space-2);
    border-radius: 50%;
    background: var(--attend-brand-tint);
    color: var(--attend-brand-text);
  }

  .attention-clear .attention-clear__title {
    margin: 0;
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-size: var(--text-h2);
    font-weight: var(--weight-display);
  }

  .attention-clear .attention-clear__body {
    margin: 0;
    max-width: var(--measure);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
  }

  /* "Today across the faculty": one card of three counts. */
  .faculty-today .faculty-today__list {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--attend-border);
    border-radius: var(--r-lg);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-card);
  }

  .faculty-today .faculty-today__item {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-width: 0;
    padding: var(--space-4) var(--space-3);
    overflow-wrap: anywhere;
  }

  .faculty-today .faculty-today__item + .faculty-today__item {
    border-inline-start: 1px solid var(--attend-border);
  }

  /* Phones show the number and its words only; the icon tile joins from 768px. */
  .faculty-today .faculty-today__icon {
    display: none;
  }

  .faculty-today .faculty-today__count {
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: 28px; /* 28/800 at every width (§7) */
    line-height: 32px;
    font-weight: var(--weight-display);
    font-variant-numeric: tabular-nums;
  }

  .faculty-today .faculty-today__label {
    margin-top: var(--space-1);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    line-height: var(--leading-small);
  }

  /* "Quick access": tiles of a brand-tint icon circle and a label. */
  .quick-access .quick-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .quick-tiles .quick-tile {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    block-size: 100%;
    min-height: var(--touch);
    padding: var(--space-4);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-md);
    background: var(--attend-surface);
    color: var(--attend-text-strong);
    font-size: var(--text-button);
    line-height: var(--leading-button);
    font-weight: var(--weight-button);
    text-decoration: none;
    overflow-wrap: anywhere;
  }

  /* Hover only with a mouse (review L5); a tap shows the pressed fill instead. */
  @media (hover: hover) and (pointer: fine) {
    .quick-tiles .quick-tile:hover {
      border-color: var(--attend-border-strong);
      background: var(--attend-row-hover);
    }
  }

  .quick-tiles .quick-tile:active {
    background: var(--attend-row-hover);
  }

  .quick-tiles .quick-tile__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 40px;
    block-size: 40px;
    border-radius: 50%;
    background: var(--attend-brand-tint);
    color: var(--attend-brand-text);
  }

  .quick-tiles .quick-tile__icon .icon {
    inline-size: 20px;
    block-size: 20px;
  }

  @media (min-width: 768px) {
    .overview-top + .quick-access {
      margin-top: var(--space-8);
    }

    .attention-list .attention-row {
      gap: var(--space-4);
      padding-inline: var(--space-6);
    }

    .attention-row .attention-row__icon {
      align-self: center;
      margin-top: 0;
    }

    .attention-row .attention-row__count {
      margin-inline-end: var(--space-2);
    }

    .faculty-today .faculty-today__list {
      flex-direction: column;
      padding: var(--space-1) var(--space-6);
    }

    .faculty-today .faculty-today__item {
      flex-direction: row;
      align-items: center;
      gap: var(--space-3);
      padding: var(--space-4) 0;
    }

    .faculty-today .faculty-today__item + .faculty-today__item {
      border-inline-start: 0;
      border-top: 1px solid var(--attend-border);
    }

    .faculty-today .faculty-today__icon {
      display: inline-flex;
      flex: 0 0 auto;
      align-items: center;
      justify-content: center;
      inline-size: 40px;
      block-size: 40px;
      border-radius: var(--r-sm);
      background: var(--attend-ground);
      color: var(--attend-text);
    }

    .faculty-today .faculty-today__icon .icon {
      inline-size: 20px;
      block-size: 20px;
    }

    .faculty-today .faculty-today__count {
      min-width: 2ch;
    }

    .faculty-today .faculty-today__label {
      margin-top: 0;
      color: var(--attend-text);
      font-size: var(--text-body);
      line-height: var(--leading-body);
    }

    .quick-access .quick-tiles {
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: var(--space-4);
    }
  }

  @media (min-width: 1024px) {
    .quick-access .quick-tiles {
      grid-template-columns: repeat(5, minmax(0, 1fr));
    }
  }

  /* The sections under the top row (Live now, This week, Quick access) are
     spaced by their labels alone (later in the cascade than the shared
     `.overview-section + .overview-section`, at the same specificity). */
  .overview-top ~ .overview-section {
    margin-top: 0;
  }

  .overview-top ~ .overview-section .section-label {
    margin-top: var(--space-6);
    margin-bottom: var(--space-3);
  }

  /* Every icon well on the overview is a circle (design review AL20). */
  .faculty-today .faculty-today__icon {
    border-radius: 50%;
  }

  /* Phones: a "Needs attention" count sits on its own line above what is
     waiting, so a wrapped label never starts under the numeral (AD23). */
  @media (max-width: 767px) {
    .attention-row .attention-row__count {
      display: block;
    }
  }

  /* "Live now" (templates/ui/_live_wall.html): a card per open round, its
     count, and a wall of initials that fills as students check in. The wall
     is the count drawn, not decoration: filled = checked in. */
  .live-now .live-rounds {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .live-now .live-round-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  .live-round-card .live-round-card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
  }

  .live-round-card .live-round-card__what {
    min-width: 0;
  }

  .live-round-card .live-round-card__label {
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    font-weight: var(--weight-strong);
  }

  .live-round-card .live-round-card__title {
    color: var(--attend-text-strong);
    font-size: var(--text-body);
    font-weight: var(--weight-strong);
    overflow-wrap: anywhere;
  }

  .live-round-card .live-round-card__count {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    white-space: nowrap;
  }

  .live-round-card .live-count {
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: 28px;
    line-height: 32px;
    font-weight: var(--weight-display);
  }

  .live-round-card .live-round-card__unit {
    color: var(--attend-text-muted);
    font-size: var(--text-small);
  }

  .live-round-card .wall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* The tile is the shared one (static/css/components.css "Live wall"): batch 3's
     dashed circle that fills in (design integration 2026-11-10). */
  .wall .wall__tile {
    aspect-ratio: 1;
  }

  /* A roster past WALL_MAX (apps/ui/live_wall.py): the count as a bar, the
     round progress bar's colours (accent on the progress track). */
  .live-round-card .live-progress {
    display: block;
    inline-size: 100%;
    block-size: 8px;
    border: 0;
    border-radius: var(--r-pill);
    background: var(--attend-progress-track);
    overflow: hidden;
    appearance: none;
  }

  .live-round-card .live-progress::-webkit-progress-bar {
    border-radius: var(--r-pill);
    background: var(--attend-progress-track);
  }

  .live-round-card .live-progress::-webkit-progress-value {
    border-radius: var(--r-pill);
    background: var(--attend-accent);
  }

  .live-round-card .live-progress::-moz-progress-bar {
    border-radius: var(--r-pill);
    background: var(--attend-accent);
  }

  @media (prefers-reduced-motion: no-preference) {
    .wall .wall__tile {
      transition: background-color 400ms ease-out, border-color 400ms ease-out, color 400ms ease-out;
    }
  }

  .live-now .live-now__more {
    margin-top: var(--space-2);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
  }

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

  /* "This week" (templates/ui/admin_overview.html): attendance per teaching
     type with its trend line, the lowest courses, lectures with no
     attendance taken and the way into Reports. */
  .week .week__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0 var(--space-3);
  }

  .week .week__dates {
    color: var(--attend-text-muted);
    font-size: var(--text-small);
  }

  .week .week__card {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  .week .week__note {
    color: var(--attend-text);
  }

  .week .week-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .week-types .week-type {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label status"
      "value spark"
      "meta spark";
    align-items: center;
    gap: var(--space-1) var(--space-3);
  }

  .week-type .week-type__label {
    grid-area: label;
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    font-weight: var(--weight-strong);
  }

  .week-type .week-type__value {
    grid-area: value;
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: var(--text-display);
    line-height: var(--leading-display);
    font-weight: var(--weight-display);
  }

  .week-type .week-type__meta {
    grid-area: meta;
    color: var(--attend-text-muted);
    font-size: var(--text-small);
  }

  .week-type .week-type__status {
    grid-area: status;
    justify-self: end;
  }

  .week-type .sparkline {
    grid-area: spark;
    overflow: visible;
  }

  /* Owner, 2026-11-10: no lone dot; the trend line waits for a second day. */
  .week-type .week-type__trend-later {
    grid-area: spark;
    max-inline-size: 112px;
    margin: 0;
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    text-align: end;
  }

  .sparkline polyline {
    fill: none;
    stroke: var(--attend-brand);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .sparkline circle {
    fill: var(--attend-surface);
    stroke: var(--attend-brand);
    stroke-width: 1.5;
  }

  .week .week__sub {
    color: var(--attend-text-strong);
    font-size: var(--text-body);
    font-weight: var(--weight-strong);
  }

  .week .week-low {
    margin-top: calc(-1 * var(--space-2));
  }

  .week-low .week-low__row {
    flex-wrap: nowrap;
    min-height: var(--touch);
    padding-block: var(--space-2);
  }

  .week-low .week-low__body {
    min-width: 0;
  }

  .week-low .week-low__value {
    flex: none;
    color: var(--attend-text-strong);
    font-size: var(--text-num-m);
    font-weight: var(--weight-display);
  }

  .week .week-count {
    color: var(--attend-text);
  }

  .week .week-count__n {
    margin-inline-end: var(--space-1);
    color: var(--attend-text-strong);
    font-weight: var(--weight-display);
  }

  .week .week__open {
    align-self: flex-start;
  }
}

/*
 * Activation cards (templates/accounts/cards/): the choice screen's summary and
 * its "One student" box, the "How to activate" steps, and the print page.
 *
 * The print page (owner, 2026-11-11): A4 sheets with an 8 mm margin, so an
 * ordinary office printer clips nothing; the printable area (194 x 281 mm)
 * holds 8 cards (2 x 4, 97 x 70.25 mm), 4 (2 x 2, 97 x 140.5 mm) or one large
 * card, as the sheets' data-per-sheet says (static/js/accounts/card-sheets.js
 * regroups the cards). Dashed cut lines; one sheet per printed page; the
 * toolbar never prints. On screen each sheet is drawn as the paper, its margin
 * as padding. The page is always rendered in the light theme (paper). The
 * card is English (lang="en"): on an Arabic page it keeps the Latin faces.
 * Millimetres only for the paper; type and spaces are tokens, times
 * --card-scale (0.9 on 4 per sheet, 1.7 on the one large card).
 */
@layer components {
  .cards-summary__count {
    font-size: var(--text-h2);
    color: var(--attend-text-strong);
  }

  .help-steps {
    display: grid;
    gap: var(--space-3);
    margin-block: var(--space-4);
    padding-inline-start: var(--space-6);
  }

  /* "One student" (templates/accounts/cards/choose.html): the search on one line
     with its button, the results as list rows. */
  .cards-one__search {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
  }

  .cards-one__search .field {
    flex: 1 1 260px;
    max-inline-size: 420px;
  }

  .cards-one__results:not(:empty) {
    margin-block-start: var(--space-4);
  }

  body.cards-print {
    background: var(--attend-ground);
  }

  .cards-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    max-width: 210mm;
    margin: 0 auto;
    padding: var(--space-6) var(--space-4);
  }

  .cards-toolbar__text {
    flex: 1 1 320px;
    min-width: 0;
  }

  .cards-toolbar__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-4);
  }

  .cards-layout legend {
    margin-block-end: var(--space-2);
    font-size: var(--text-support);
    font-weight: var(--weight-medium);
  }

  .cards-layout .segmented__option {
    min-inline-size: var(--touch);
  }

  .cards-sheet {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
    box-sizing: border-box;
    width: 210mm;
    height: 297mm;
    margin: 0 auto var(--space-8);
    padding: 8mm;
    background: var(--attend-surface);
    color: var(--attend-text-strong);
    box-shadow: var(--attend-shadow-card);
    break-after: page;
    overflow: hidden;
  }

  .cards-sheet:last-child {
    break-after: auto;
  }

  .cards-sheets[data-per-sheet="4"] .cards-sheet {
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .cards-sheets[data-per-sheet="1"] .cards-sheet {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  /* The card: the owner's design file (2026-11-12, docs/DECISIONS.md).
     Each sheet cell is cut along its dashed edge; inside it a framed card: a
     tinted band (the wordmark, "Account activation"), then the body.
     8 per sheet (97 x 70.25 mm): the student, the QR beside how to scan, the
     manual code in one tinted row, the date. 4 per sheet and the one large
     card: one centred column, "Activate your account", the QR in a framed box,
     how to scan, two tiles (the manual code, the web address), the date.
     Type and spaces are tokens times --card-scale; the paper sizes are mm. */
  .activation-card {
    --card-scale: 1;
    --card-qr: 22mm;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    padding: 2.5mm;
    border: 0.5px dashed var(--attend-border-strong);
    color: var(--attend-text-strong);
    font-family: var(--font-body);
    font-size: calc(var(--text-label) * var(--card-scale));
    line-height: 1.3;
    overflow: hidden;
    break-inside: avoid;
    print-color-adjust: exact;
  }

  :lang(ar) .activation-card[lang="en"] {
    --font-display: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  }

  .activation-card p {
    margin: 0;
  }

  .activation-card__frame {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    inline-size: 100%;
    block-size: 100%;
    border: 1px solid var(--attend-border);
    border-radius: var(--r-xs);
    background: var(--attend-surface);
    overflow: hidden;
  }

  .activation-card__band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: calc(var(--space-2) * var(--card-scale));
    padding: calc(var(--space-2) * var(--card-scale)) calc(var(--space-3) * var(--card-scale));
    border-block-end: 1px solid var(--attend-border);
    background: var(--attend-brand-tint);
  }

  .activation-card__brand .wordmark {
    font-size: calc(var(--text-small) * var(--card-scale));
  }

  /* The design file's lockup: a thin rule between the two names. */
  .activation-card__brand .wordmark__sep {
    align-self: stretch;
    inline-size: 0;
    margin-inline: 0.15em;
    border-inline-start: 1px solid var(--attend-border-strong);
    color: transparent;
    overflow: hidden;
  }

  .activation-card__kind {
    color: var(--attend-brand-text);
    font-weight: var(--weight-bold);
  }

  .activation-card__body {
    flex: 1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "head head"
      "qr how"
      "tiles tiles"
      "valid valid";
    align-content: space-between;
    gap: calc(var(--space-2) * var(--card-scale)) calc(var(--space-3) * var(--card-scale));
    min-block-size: 0;
    padding: calc(var(--space-2) * var(--card-scale)) calc(var(--space-3) * var(--card-scale));
  }

  .activation-card__title {
    display: none;
  }

  .activation-card__head {
    grid-area: head;
    min-width: 0;
  }

  .activation-card__name {
    font-size: calc(var(--text-body) * var(--card-scale));
    font-weight: var(--weight-strong);
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  /* "University ID 5096 · placement": a dot between the two. */
  .activation-card__who {
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.4em;
  }

  .activation-card__who .activation-card__meta + .activation-card__meta::before {
    content: "\00b7"; /* the middle dot, escaped: the stylesheet has no @charset */
    margin-inline-end: 0.4em;
  }

  .activation-card__meta {
    color: var(--attend-text-muted);
  }

  .activation-card__qr {
    grid-area: qr;
    box-sizing: border-box;
    inline-size: var(--card-qr);
    padding: calc(var(--space-1) * var(--card-scale));
    border: 1px solid var(--attend-border);
    border-radius: var(--r-xs);
  }

  .activation-card__svg {
    display: block;
    width: 100%;
    height: auto;
  }

  .activation-card__how {
    grid-area: how;
    align-self: center;
    min-width: 0;
  }

  .activation-card__how-title {
    font-size: calc(var(--text-small) * var(--card-scale));
    font-weight: var(--weight-bold);
  }

  .activation-card__how-text,
  .activation-card__web,
  .activation-card__valid {
    color: var(--attend-text-muted);
  }

  .activation-card__web--small {
    margin-block-start: calc(var(--space-3) * var(--card-scale));
  }

  .activation-card__web--small .activation-card__address {
    display: block;
  }

  /* An address is never broken inside: the line wraps before it. */
  .activation-card__address {
    color: var(--attend-brand-text);
    font-weight: var(--weight-bold);
    white-space: nowrap;
  }

  .activation-card__tiles {
    grid-area: tiles;
  }

  .activation-card__tile {
    border-radius: var(--r-xs);
    background: var(--attend-ground);
  }

  .activation-card__tile--code {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0 var(--space-2);
    padding: calc(var(--space-1) * var(--card-scale)) calc(var(--space-2) * var(--card-scale));
  }

  .activation-card__tile--web,
  .activation-card__long {
    display: none;
  }

  .activation-card__tile-label {
    color: var(--attend-brand-text);
    font-weight: var(--weight-bold);
  }

  .activation-card__code {
    font-family: var(--font-mono);
    font-size: calc(var(--text-small) * var(--card-scale));
    font-weight: var(--weight-bold);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }

  .activation-card__valid {
    grid-area: valid;
  }

  /* 4 per sheet (97 x 140.5 mm) and the one large card: one centred column. */
  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(var(--space-3) * var(--card-scale));
    padding: calc(var(--space-4) * var(--card-scale));
    text-align: center;
  }

  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__title {
    display: block;
    font-family: var(--font-display);
    font-size: calc(var(--text-h1) * var(--card-scale));
    font-weight: var(--weight-display);
    letter-spacing: -0.02em;
    line-height: 1.1;
  }

  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__name {
    font-size: calc(var(--text-h2) * var(--card-scale));
  }

  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__who {
    justify-content: center;
  }

  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__qr {
    padding: calc(var(--space-3) * var(--card-scale));
    border-radius: var(--r-sm);
  }

  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__web--small {
    display: none;
  }

  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(var(--space-3) * var(--card-scale));
    align-self: stretch;
    padding-block-start: calc(var(--space-3) * var(--card-scale));
    border-block-start: 1px solid var(--attend-border);
    text-align: start;
  }

  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: calc(var(--space-1) * var(--card-scale));
    padding: calc(var(--space-2) * var(--card-scale)) calc(var(--space-3) * var(--card-scale));
  }

  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__tile-label {
    color: var(--attend-text-strong);
  }

  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__long {
    display: inline;
  }

  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__short {
    display: none;
  }

  /* The tiles' code and address keep their own sizes: each fits its tile on
     one line (the large card's tiles sit side by side, 4 per sheet's stack). */
  .cards-sheets:is([data-per-sheet="4"], [data-per-sheet="1"]) .activation-card__tile {
    align-items: stretch;
    text-align: start;
  }

  .cards-sheets[data-per-sheet="4"] .activation-card__tiles {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }

  .cards-sheets[data-per-sheet="4"] .activation-card__tile .activation-card__code {
    font-size: var(--text-small);
  }

  .cards-sheets[data-per-sheet="4"] .activation-card__tile .activation-card__address {
    font-size: var(--text-label);
  }

  .cards-sheets[data-per-sheet="4"] .activation-card__tile-label {
    font-size: var(--text-label);
  }

  .cards-sheets[data-per-sheet="1"] .activation-card__tile-label {
    font-size: var(--text-small);
  }

  .cards-sheets[data-per-sheet="1"] .activation-card__tile .activation-card__code {
    font-size: var(--text-body);
  }

  .cards-sheets[data-per-sheet="1"] .activation-card__tile .activation-card__address {
    font-size: var(--text-support);
  }

  .cards-sheets[data-per-sheet="4"] .activation-card {
    --card-scale: 0.9;
    --card-qr: 40mm;
  }

  .cards-sheets[data-per-sheet="1"] .activation-card {
    --card-scale: 1.7;
    --card-qr: 76mm;
    border-color: transparent;
  }

  .cards-sheets[data-per-sheet="1"] .activation-card__frame {
    inline-size: 172mm;
    block-size: auto;
    border-radius: var(--r-md);
  }

  /* The card step of "Add a student" (templates/accounts/people/cards.html, board
     P1-AddStudentCard): the sheet with what was just done above it, and beside it
     the sitting's cards with "Print all added today". Under the sheet's width the
     list goes below. None of it is printed. */
  .cards-page--sitting {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 0 var(--space-8);
    padding-inline: var(--space-4);
  }

  .cards-page--sitting .cards-page__main {
    flex: none;
    max-inline-size: 100%;
  }

  .cards-page__banner {
    max-width: 210mm;
    margin: var(--space-6) auto 0;
  }

  .cards-page__side {
    flex: 1 1 280px;
    max-inline-size: 420px;
    padding-block: var(--space-6);
  }

  .cards-page__side > * + * {
    margin-block-start: var(--space-4);
  }

  .cards-page__side .row {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .cards-page__who {
    flex: 1 1 auto;
    min-inline-size: 0;
  }

  @media print {
    @page {
      size: A4;
      margin: 8mm;
    }

    body.cards-print {
      background: var(--attend-surface);
    }

    .cards-toolbar {
      display: none;
    }

    .cards-page__banner,
    .cards-page__side {
      display: none;
    }

    .cards-page--sitting {
      display: block;
      padding: 0;
    }

    /* The sheet is the printable area: the page's margin is the paper's. */
    .cards-sheet {
      width: 194mm;
      height: 280mm;
      margin: 0;
      padding: 0;
      box-shadow: none;
    }
  }
}

/* Device approvals: the review of first phones approved automatically
   (owner decision 2026-11-09). The photo beside each row, a small copy of the
   identity photo; the link to the review list with its count. */
@layer components {
  .identity__photo--thumb {
    width: 48px;
    height: 60px;
  }

  .review-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
  }
}

/* Activation cards (templates/accounts/cards/choose.html; design review BI19):
   from 768px the Stage select is as wide as its longest line (stage,
   department, students and cards), never wider than the page; the shared
   filter field stops at 200px and cut the line. Phones keep full-width fields. */
@layer components {
  @media (min-width: 768px) {
    .cards-picker.filters .field:not(.field--search) {
      flex: 0 1 auto;
    }

    .cards-picker select {
      inline-size: auto;
      max-inline-size: 100%;
    }
  }
}

/*
 * Onboarding progress (templates/reports/onboarding.html): one row per step --
 * the step and its rule, the count, an 8px pill bar (the live card's progress
 * track: brand tint, accent fill), and the step's "Not yet" link. Phone: the
 * count and the link share the line under the text; from 768px the count and
 * the link sit beside the text. The step whose list is shown carries a 3px
 * accent bar on its leading edge.
 */
@layer components {
  .onboarding__total {
    margin: 0;
    color: var(--attend-text-muted);
  }

  .onboarding__total strong {
    color: var(--attend-text-strong);
    font-size: var(--text-num-m);
    font-weight: var(--weight-num-m);
    line-height: var(--leading-num-m);
  }

  .onboarding .onboarding-steps {
    margin-top: var(--space-4);
  }

  .onboarding-steps .onboarding-step {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "body body"
      "count action"
      "bar bar";
    align-items: center;
    gap: var(--space-2) var(--space-4);
  }

  .onboarding-step .onboarding-step__body {
    grid-area: body;
    min-width: 0;
  }

  .onboarding-step__body p {
    margin: 0;
  }

  .onboarding-step .onboarding-step__count {
    grid-area: count;
    margin: 0;
    color: var(--attend-text-muted);
    white-space: nowrap;
  }

  .onboarding-step__count strong {
    color: var(--attend-text-strong);
  }

  .onboarding-step .onboarding-step__action {
    grid-area: action;
    justify-self: end;
  }

  .onboarding-step .onboarding-step__bar {
    grid-area: bar;
    display: block;
    inline-size: 100%;
    block-size: 8px;
    border: 0;
    border-radius: var(--r-pill);
    background: var(--attend-progress-track);
    overflow: hidden;
    appearance: none;
  }

  .onboarding-step__bar::-webkit-progress-bar {
    border-radius: var(--r-pill);
    background: var(--attend-progress-track);
  }

  .onboarding-step__bar::-webkit-progress-value {
    border-radius: var(--r-pill);
    background: var(--attend-accent);
  }

  .onboarding-step__bar::-moz-progress-bar {
    border-radius: var(--r-pill);
    background: var(--attend-accent);
  }

  .onboarding-steps .onboarding-step--current::after {
    content: "";
    position: absolute;
    inset-block: var(--space-3);
    inset-inline-start: 0;
    inline-size: 3px;
    border-radius: var(--r-pill);
    background: var(--attend-accent);
  }

  .onboarding-list .onboarding-list__range {
    margin: var(--space-3) 0 0;
  }

  @media (min-width: 768px) {
    .onboarding-steps .onboarding-step {
      grid-template-columns: minmax(0, 1fr) auto auto;
      grid-template-areas:
        "body count action"
        "bar bar bar";
    }
  }
}

/*
 * Administration lists on a phone (design review #13): the shared `.table--rows`
 * component, its "phone-only cells" form (static/css/components.css).
 */

/*
 * Administration filters (templates/ui/_admin_filters.html; design review #14).
 * From 768px, and on a phone without JavaScript, the filters' <dialog> and its
 * body are `display: contents`, so their fields sit in the filter row as
 * before. On a phone with JavaScript (data-sheet-ready) the dialog is closed
 * until "Filters · N" opens it as the shared bottom sheet (.dialog). Search
 * labels stay for screen readers; the phone shows the placeholder only.
 */
@layer components {
  .admin-filters .filters-sheet,
  .admin-filters .filters-sheet__fields {
    display: contents;
  }

  .admin-filters .filters-sheet__head,
  .admin-filters .filters-sheet__foot {
    display: none;
  }

  /* With JavaScript every change applies at once: Apply is for no-JS only. */
  .admin-filters[data-sheet-ready] [data-filter-apply] {
    display: none;
  }

  .filter-chips {
    display: none;
  }

  @media (min-width: 768px) {
    .admin-filters .filters-open {
      display: none;
    }

    /* Labels on one line at the top; a field's help sits under its input. */
    .admin-filters {
      align-items: flex-start;
    }

    .admin-filters .filters-actions {
      align-self: flex-end;
    }

    .admin-filters .field select {
      min-inline-size: 12rem;
    }
  }

  @media (max-width: 767px) {
    .admin-filters[data-sheet-ready] {
      flex-wrap: nowrap;
      align-items: center;
      gap: var(--space-2);
    }

    .admin-filters[data-sheet-ready] .field--search {
      flex: 1 1 auto;
    }

    .admin-filters[data-sheet-ready] .field--search .field__label {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }

    .admin-filters[data-sheet-ready] .filters-open {
      flex: none;
      gap: var(--space-2);
      white-space: nowrap;
    }

    .admin-filters[data-sheet-ready] .filters-actions {
      flex: none;
    }

    .admin-filters[data-sheet-ready] .filters-actions:not(:has(.htmx-request)) {
      display: none;
    }

    .admin-filters[data-sheet-ready] .filters-sheet {
      display: revert;
    }

    .admin-filters[data-sheet-ready] .filters-sheet:not([open]) {
      display: none;
    }

    .admin-filters[data-sheet-ready] .filters-sheet[open] {
      display: flex;
      flex-direction: column;
    }

    .admin-filters[data-sheet-ready] .filters-sheet__head {
      display: flex;
    }

    .admin-filters[data-sheet-ready] .filters-sheet__fields {
      display: flex;
      flex-direction: column;
      gap: var(--space-4);
      overflow-y: auto;
      overscroll-behavior: contain;
    }

    .admin-filters[data-sheet-ready] .filters-sheet__foot {
      display: flex;
      padding-top: var(--space-4);
    }

    .admin-filters[data-sheet-ready] .filters-sheet__fields .field {
      flex: none;
    }

    .filter-chips {
      display: flex;
      flex-wrap: nowrap;
      gap: var(--space-2);
      margin: calc(-1 * var(--space-3)) 0 var(--space-4);
      padding: 0 0 var(--space-1);
      overflow-x: auto;
      list-style: none;
      scrollbar-width: none;
    }

    .filter-chips:empty {
      display: none;
    }

    .filter-chips .filter-chip {
      display: inline-flex;
      align-items: center;
      min-height: var(--touch);
      padding: 0 var(--space-4);
      border: 1px solid var(--attend-border-strong);
      border-radius: var(--r-pill);
      background: var(--attend-surface);
      color: var(--attend-text-strong);
      font: inherit;
      font-size: var(--text-small);
      font-weight: var(--weight-strong);
      white-space: nowrap;
      cursor: pointer;
    }

    .filter-chips .filter-chip::after {
      content: "\00d7";
      margin-inline-start: var(--space-2);
      color: var(--attend-text-muted);
      font-size: var(--text-button);
      line-height: 1;
    }
  }
}

/*
 * Reports (templates/reports/index.html; design review #15): the period in
 * words, the headline figures, "How this report counts" as a disclosure and
 * a wider course column (AL22).
 */
@layer components {
  .report-period {
    color: var(--attend-text-muted);
    font-size: var(--text-small);
  }

  .report-headline {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  .report-headline .report-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .report-kpis .report-kpi {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-4);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-lg);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-card);
  }

  .report-kpi .report-kpi__label {
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    font-weight: var(--weight-strong);
  }

  .report-kpi .report-kpi__value {
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: 28px;
    line-height: 32px;
    font-weight: var(--weight-display);
  }

  .report-kpi .report-kpi__value--na {
    font-family: var(--font-body);
    font-size: var(--text-body);
    line-height: 32px;
    font-weight: var(--weight-strong);
  }

  .report-kpi .report-kpi__meta {
    color: var(--attend-text-muted);
    font-size: var(--text-small);
  }

  .report-basis {
    border: 1px solid var(--attend-border);
    border-radius: var(--r-md);
    background: var(--attend-surface);
  }

  .report-basis > summary {
    display: flex;
    align-items: center;
    min-height: var(--touch);
    padding: 0 var(--space-4);
    color: var(--attend-text-strong);
    font-weight: var(--weight-strong);
    cursor: pointer;
  }

  .report-basis > .definition-list {
    padding: 0 var(--space-4) var(--space-4);
  }

  /* A bar of each course's attendance under its figure (SF14): the round
     progress bar's colours, hidden on a phone, where the row shows the figure. */
  .report-table .report-bar {
    display: none;
  }

  @media (min-width: 768px) {
    .report-table td:first-child {
      min-inline-size: 18rem;
    }

    /* The row's details and its counting note on one muted line, cut with an
       ellipsis (the whole text is its title), so the first column stays two
       lines (AL22). */
    .report-table .report-table__sub {
      display: block;
      max-inline-size: 18rem;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .report-table .report-bar {
      display: block;
      inline-size: 96px;
      block-size: 6px;
      margin-top: var(--space-1);
      margin-inline-start: auto;
      border: 0;
      border-radius: var(--r-pill);
      background: var(--attend-progress-track);
      overflow: hidden;
      appearance: none;
    }

    .report-table .report-bar::-webkit-progress-bar {
      border-radius: var(--r-pill);
      background: var(--attend-progress-track);
    }

    .report-table .report-bar::-webkit-progress-value {
      border-radius: var(--r-pill);
      background: var(--attend-accent);
    }

    .report-table .report-bar::-moz-progress-bar {
      border-radius: var(--r-pill);
      background: var(--attend-accent);
    }

    /* Many filters (Reports) sit on a fixed grid: equal columns, labels on
       one line, nothing alone on a row (AL9). */
    .admin-filters.admin-filters--grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
      align-items: start;
    }

    .admin-filters--grid .field select,
    .admin-filters--grid .field input {
      inline-size: 100%;
      min-inline-size: 0;
    }

    .admin-filters--grid .filters-actions {
      align-self: end;
    }

    /* With JavaScript (Apply hidden) only the loading line is left: it sits
       just under the grid's end, in the form's margin, not on a row of its
       own. */
    .admin-filters.admin-filters--grid[data-sheet-ready] {
      position: relative;
    }

    .admin-filters--grid[data-sheet-ready] .filters-actions {
      position: absolute;
      inset-block-start: 100%;
      inset-inline-end: 0;
    }
  }
}

/*
 * Device approvals (templates/devices/approvals.html, detail.html; design
 * review BI11, BI12): the Pending / Decided / All tabs, the larger photo
 * with its full-size link, the next waiting request after a decision, and
 * the history folded after the last three.
 */
@layer components {
  .approval-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
  }

  .approval-tabs .btn {
    gap: var(--space-2);
  }

  .device-identity .device-identity__open {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: var(--space-1);
    color: var(--attend-brand-text);
    font-size: var(--text-small);
    font-weight: var(--weight-strong);
    text-decoration: none;
  }

  /* The photos an approver compares, larger (BI12): the official or relied-on
     photo and the photo the student sent (review L10); the empty "no
     official photo" box keeps the shared size. */
  .device-identity img.identity__photo,
  .sent-photo .identity__photo {
    width: 160px;
    height: 200px;
  }

  .next-request {
    margin-top: var(--space-3);
  }

  .device-replaced {
    margin-bottom: var(--space-3);
  }

  .device-history-more {
    margin-top: var(--space-3);
  }

  .device-history-more > summary {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch);
    color: var(--attend-brand-text);
    font-weight: var(--weight-strong);
    cursor: pointer;
  }
}

/* The audit log (templates/audit/log.html): on a phone the operation in words,
   then who and when, then Details (the code and the changes). */
@layer components {
  .table--rows .audit-meta {
    display: none;
  }

  .table--rows .audit-what {
    display: block;
  }

  @media (max-width: 767px) {
    .table--rows .audit-meta {
      display: block;
      margin-top: var(--space-05);
      color: var(--attend-text-muted);
      font-size: var(--text-small);
      font-weight: var(--weight-medium);
    }
  }
}

/* Activation cards: the stage list as wide as its longest choice (BI19). */
@layer components {
  .cards-picker select {
    field-sizing: content;
    min-inline-size: 12rem;
    max-inline-size: 100%;
  }
}

/* Desktop administration tables keep short values on one line (AL22): times,
   people, rooms and IDs, marked cell--short in the templates (never found by
   their English data-label, which the Arabic work translates); the frame
   scrolls a table too wide for the page. */
@layer components {
  @media (min-width: 768px) {
    .table--rows td.cell--short {
      white-space: nowrap;
    }
  }
}

/* ------------------------------------------ Desk code box
   Phone approvals (devices/approvals.html; onboarding item 5): the six digits
   from the student's waiting screen open that request. */
@layer components {
  .desk-box {
    display: grid;
    gap: var(--space-2);
    margin-block-end: var(--space-4);
    max-inline-size: 32rem;
  }

  .desk-box__row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .desk-box__row input {
    flex: 1 1 12rem;
    min-inline-size: 0;
  }
}

/* ------------------------------------------ Getting ready to approve phones
   The Super Admin's checklist on a staff account (accounts/_approver_ready.html;
   onboarding item 4): an icon and the step on one line, the detail under it. */
@layer components {
  .approver-ready__step .row__title {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
  }

  .approver-ready__step[data-state="done"] .row__title {
    color: var(--attend-text-muted);
  }

  /* The parts a role covers: one per line, no separator to translate. */
  .approver-ready__scopes {
    margin: 0;
    padding: 0;
    list-style: none;
  }
}

/* ------------------------------------------------------------ Add a lecture
   The one-page form (timetable/lectures/add.html; boards L1-AddLecture,
   L1-AddLectureClash, L1-AddLectureFriday). Its fields sit in wrappers that
   htmx replaces part by part; a wrapper has no box of its own, so the fields
   keep the form's own gap. */
@layer components {
  .lecture-add__part {
    display: contents;
  }

  /* A warning among the fields keeps the form's own gap (as `.form > .banner`;
     here it sits inside a wrapper). */
  .lecture-add .banner {
    margin-block-end: 0;
  }

  /* The day (wide), then From and To; on a phone the day takes its own line. */
  .lecture-add__when {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
  }

  .lecture-add__date,
  .lecture-add__weekday {
    grid-column: 1 / -1;
  }

  @media (min-width: 640px) {
    .lecture-add__when {
      grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
    }

    .lecture-add__date,
    .lecture-add__weekday {
      grid-column: auto;
    }
  }

  /* "One time" asks for a date, "Every week" for a day: the other is put away
     (both are in the page, so the choice needs no round trip; the server reads
     the one that belongs to the choice). */
  .lecture-add:has(input[name="repeat"][value="weekly"]:checked) .lecture-add__date,
  .lecture-add:has(input[name="repeat"][value="once"]:checked) .lecture-add__weekday {
    display: none;
  }

  /* "Busy at this time" under the room or the lecturer that is in the way. */
  .lecture-add__busy {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--attend-warning-text);
  }
}

/* "Add a student" (templates/accounts/people/add_student.html, board
   P1-AddStudent): the stage, the section and the practical group on one line.
   The group fields sit in a wrapper htmx replaces when the stage changes;
   `display: contents` keeps them cells of the same grid. */
@layer components {
  .person-add__place {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
  }

  .person-add__part {
    display: contents;
  }

  @media (min-width: 640px) {
    .person-add__place {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .person-add__hint {
      grid-column: span 2;
      align-self: end;
    }
  }
}

/* "Edit details" (templates/accounts/people/edit.html, board P1-EditPerson):
   the reason and the note of a stage change keep the form's own gap. */
@layer components {
  .person-add__move {
    display: grid;
    gap: var(--space-5);
  }

  .person-add__move:empty {
    display: none;
  }

  .person-add__move > .banner {
    margin-block-end: 0;
  }
}

/* "Add a staff member" (templates/accounts/people/add_staff.html, board
   P1-AddStaff): the subjects taught, one closed group per stage with its tick
   boxes in two columns (one on a phone). static/js/accounts/pick-list.js
   filters them and keeps each group's count. */
@layer components {
  .field--choices > div.pick-list {
    display: block;
    padding-inline: var(--space-4);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-md);
  }

  .pick-group + .pick-group {
    border-block-start: 1px solid var(--attend-border);
  }

  .pick-group > summary {
    padding-inline-end: var(--space-05);
  }

  .pick-group > summary::after {
    margin-inline-start: auto;
  }

  .pick-group__name {
    color: var(--attend-text-strong);
    font-weight: var(--weight-strong);
  }

  .pick-group__items {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0 var(--space-5);
    padding-block-end: var(--space-3);
  }

  @media (min-width: 640px) {
    .pick-group__items {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }
}

/*
 * The student record for staff (templates/academics/people/_record.html and
 * _record_section.html; boards P1-StudentRecord and P1-StudentRecordPhone;
 * docs/dev/student-record.md). The sections reuse the Account page's cards
 * (.account-group, static/css/student.css). Phone: one column, in the plan's
 * order. From 1024px: two columns the browser balances, filled in the same
 * order, so a viewer who sees fewer sections still gets even columns.
 */
@layer components {
  .record-head__who {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-inline-size: 0;
  }

  .record-head__text {
    min-inline-size: 0;
  }

  .record-head__text > p:last-child:not(.page-header__sub) {
    margin-block-start: var(--space-2);
  }

  .record-head .record-head__initials {
    inline-size: 56px;
    block-size: 56px;
    font-size: var(--text-h2);
  }

  .record-head__photo {
    display: block;
    flex: none;
    border-radius: var(--r-md);
  }

  .record-head__photo > img {
    display: block;
    inline-size: 96px;
    block-size: 120px;
    border: 1px solid var(--attend-edge);
    border-radius: var(--r-md);
    background: var(--attend-surface-subtle);
    object-fit: cover;
  }

  .record-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
    margin-block-end: var(--space-5);
  }

  .account-group.record-card {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: var(--space-4);
    min-inline-size: 0;
  }

  .record-card > p,
  .record-card__label {
    margin: 0;
  }

  .record-card__label {
    margin-block-start: var(--space-4);
  }

  .record-rows > li {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-3);
    min-block-size: 44px;
    padding-block: var(--space-2);
    border-block-start: 1px solid var(--attend-border);
  }

  .record-rows > li:first-child {
    border-block-start: 0;
  }

  .record-rows__text {
    flex: 1 1 12rem;
    min-inline-size: 0;
  }

  /* A row with a chip: the chip sits under the text (the board's half-width card). */
  .record-rows > li:has(> .status) > .record-rows__text {
    flex-basis: 100%;
  }

  .record-rows__text > p {
    margin: 0;
  }

  /* The whole row opens the request; the link stays the row's one focus stop. */
  .record-rows .row__title > a::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  .record-rows__go {
    display: inline-flex;
    margin-inline-start: auto;
    color: var(--attend-text-muted);
  }

  @media (min-width: 768px) {
    .record-head .record-head__initials {
      inline-size: 64px;
      block-size: 64px;
    }
  }

  @media (min-width: 1024px) {
    .record-grid {
      display: block;
      column-count: 2;
      column-gap: var(--space-5);
    }

    .record-grid > .record-card {
      break-inside: avoid;
      margin-block-end: var(--space-5);
    }
  }
  /* Group migrations, the live page (templates/academics/group_migrations/live.html;
     design 2026-11-16, screen 2): the figures in a row of cards, each with a bar. */
  .gm-live__when {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-block: 0 var(--space-4);
    color: var(--attend-text-muted);
  }

  .gm-live__when strong {
    color: var(--attend-text-strong);
  }

  .report-kpis.gm-figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-3);
    margin: 0 0 var(--space-5);
    padding: 0;
    list-style: none;
  }

  /* A clinic window: its clinics' figures in one list per section, under its heading. */
  .gm-figures__section {
    margin: 0 0 var(--space-2);
    color: var(--attend-text-strong);
    font-size: var(--text-support);
    font-weight: var(--weight-strong);
  }

  .gm-figures .gm-figures__line {
    color: var(--attend-text-strong);
    font-weight: var(--weight-strong);
  }

  .gm-figures .gm-figures__bar {
    inline-size: 100%;
    block-size: 8px;
    margin-block-start: var(--space-2);
    border: 0;
    border-radius: var(--radius-control);
    background: var(--attend-progress-track);
    appearance: none;
  }

  .gm-figures .gm-figures__bar::-webkit-progress-bar {
    border-radius: var(--radius-control);
    background: var(--attend-progress-track);
  }

  .gm-figures .gm-figures__bar::-webkit-progress-value {
    border-radius: var(--radius-control);
    background: var(--attend-accent);
  }

  .gm-figures .gm-figures__bar::-moz-progress-bar {
    border-radius: var(--radius-control);
    background: var(--attend-accent);
  }

  /* Group migrations, the preview (templates/academics/group_migrations/preview.html;
     design 2026-11-16, screen 3): the rows beside "Check before publishing" from
     1024px, one column below; a row's override opens under its "Change". */
  .gm-preview {
    display: grid;
    gap: var(--space-4);
    align-items: start;
  }

  @media (min-width: 1024px) {
    .gm-preview {
      grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    }
  }

  .gm-checks {
    padding: var(--space-5);
  }

  .gm-checks__title {
    margin: 0 0 var(--space-3);
    font-size: var(--text-body);
  }

  .gm-check {
    margin-block-end: var(--space-4);
    padding-inline-start: var(--space-3);
    border-inline-start: 3px solid var(--attend-warning-text);
  }

  .gm-check--info {
    border-inline-start-color: var(--attend-info-text);
  }

  .gm-check__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-1);
    font-size: var(--text-body);
    color: var(--attend-text-strong);
  }

  .gm-check ul {
    margin: var(--space-1) 0 0;
    padding-inline-start: var(--space-4);
    font-size: var(--text-small);
  }

  .gm-override__form {
    display: grid;
    gap: var(--space-2);
    min-inline-size: 200px;
    margin-block-start: var(--space-2);
  }

  @media (min-width: 1024px) {
    .gm-preview.gm-preview--one {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  /* The Publish card (under the preview, and the confirm page): the whole move in
     one line, the button at the end from 720px. */
  .gm-publish {
    display: grid;
    gap: var(--space-3);
    margin-block-start: var(--space-4);
    padding: var(--space-5);
  }

  .gm-publish__line {
    margin: 0;
    color: var(--attend-text-strong);
    font-weight: var(--weight-strong);
  }

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

  @media (min-width: 720px) {
    .gm-publish--bar {
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
    }
  }

  /* ---------------------------------------------- Group exchange (office)
     Boards Exchange-Office-Window and Exchange-Office-List (plans/group-exchange,
     approved 2026-11-25): the window row's actions, the open form, the group
     sizes (in = out) and the two-line cells of the agreed list. */
  .gx-window-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
  }

  .gx-window-actions form {
    display: contents;
  }

  .gx-window-actions .btn {
    min-height: var(--touch);
    padding-inline: var(--space-4);
    white-space: nowrap;
  }

  .gx-open {
    max-width: 720px;
  }

  .gx-open h2 {
    margin-block-end: var(--space-4);
  }

  .gx-window-form__dates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
  }

  .gx-sizes .section__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .gx-sizes__tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-2);
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
  }

  .gx-sizes__tiles .gx-pair__tile {
    border-color: transparent;
    background: var(--attend-field);
  }

  .gx-cell-lines {
    display: flex;
    flex-direction: column;
  }

  .gx-cell-line {
    margin: 0;
  }

  .gx-undone {
    margin: var(--space-1) 0 0;
  }
}

/*
 * A list's download under its filters (the Groups list's "Download Excel",
 * templates/academics/groups/_export.html): at the row's end, closer to the
 * filters than to the list.
 */
@layer components {
  .list-download {
    justify-content: flex-end;
    margin-block: calc(-1 * var(--space-3)) var(--space-4);
  }
}
