/*
 * components.css: components shared by the admin and parent screens.
 *
 * Part of the new stylesheet stack (redesign Step 3). Loaded by
 * templates/base.html.twig in this order, one <link> each: tokens.css,
 * base.css, layout.css, components.css, forms.css, admin.css, parent.css.
 * Never use @import here: every file is linked on its own so that
 * FileModifiedVersionStrategy versions each one by its modification time.
 *
 * Ported from the portal's original stylesheet, in its source order. Class names are kept (they are the
 * components' API) and restyled onto the design system's tokens; classes the
 * system adds for Step 4+ markup are added where they belong.
 */

/* ----------------------------------------------------------------- utilities */

/* `hidden` has to win over any display rule an author sets. The UA's
   [hidden] { display: none } is only (0,1,0), so a rule like
   `.form-card .help-text { display: block }` beats it and a "hidden" element
   renders as an empty gap. Controllers toggle the hidden attribute (tabs, the
   child form's age hint, dialogs), so it must stay authoritative. This is the
   one !important outside the print rules, carried over unchanged from the original stylesheet. */
[hidden] { display: none !important; }

.muted { color: var(--muted); }

/* A button that reads as a link: a number that opens a popup, so it looks
   tappable beside the real links in the same table. */
.link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--plum);
    text-decoration: underline;
    cursor: pointer;
}

.code-chip {
    display: inline-block;
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--plum-tint);
    color: var(--plum-dark);
    font-size: var(--text-small);
    line-height: var(--leading-small);
    word-break: break-all;
}

/* Stacked list without bullets: a row of one fact per line. */
.plain-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    font-size: var(--text-table);
    line-height: var(--leading-table);
}

.plain-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack > .card + .card { margin-top: 0; }

/* The wide column and the side column of a record page. */
.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: var(--space-4);
    align-items: start;
}

.quick-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ----------------------------------------------------- page head and sections */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0 0 var(--space-2);
    padding: 0;
    list-style: none;
    font-size: var(--text-small);
    line-height: var(--leading-small);
    color: var(--muted);
}

.breadcrumb li + li::before { content: "/"; margin-right: var(--space-2); color: var(--line-control); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--ink); text-decoration: underline; }

.page-head { margin: 0 0 var(--space-6); }

.page-head h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-display-page);
    line-height: var(--leading-display-page);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-display-page);
}

.page-head h1 em {
    font-style: italic;
    color: var(--plum);
}

/* A status or tag beside the title keeps the body face. */
.page-head h1 .status,
.page-head h1 .tag {
    vertical-align: middle;
    font-family: var(--font-body);
    letter-spacing: 0;
    margin-left: var(--space-1);
}

.page-head__sub {
    margin: var(--space-1) 0 0;
    max-width: 64ch;
    font-size: var(--text-table);
    line-height: var(--leading-table);
    color: var(--muted);
}

/* Title on the left, actions on the right aligned to the title. */
.page-head--row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

/* The title column takes the room the actions leave and wraps its description
   inside it; the actions only drop under the title when less than 22rem is
   left for it (a phone). Without this a 64ch description pushed one button
   onto a row of its own at 1024px. */
.page-head--row > div:first-child { flex: 1 1 22rem; min-width: 0; }

.page-head__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.section { margin: var(--space-8) 0; }

.section__title {
    margin: 0 0 var(--space-3);
    font-family: var(--font-display);
    font-size: var(--text-display-section);
    line-height: var(--leading-display-section);
    font-weight: var(--weight-semibold);
}

/* With a one-line description under it the title sits tight to that line. */
.section__title:has(+ .section__sub) { margin-bottom: var(--space-1); }

.section__sub {
    margin: 0 0 var(--space-4);
    font-size: var(--text-table);
    line-height: var(--leading-table);
    color: var(--muted);
}

.page-note {
    margin: var(--space-4) 0 0;
    font-size: var(--text-label);
    line-height: var(--leading-label);
    color: var(--muted);
}

/* ---------------------------------------------------------------------- tabs
   The system's Tabs: an oak underline and plum-dark bold on the current one,
   muted otherwise. One rule set serves both kinds. Links that change the URL
   mark the current one with aria-current="page"; buttons that swap panels in
   place (tabs_controller.js) mark it with aria-selected="true". A count is a
   .count pill after the label. The strip wraps rather than scrolls, so the
   focus ring (2px, offset 2px, from base.css) is never clipped by an overflow
   box and no tab hides off the edge. */

.tabs__nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin: 0 0 var(--space-5);
    border-bottom: 1px solid var(--line);
}

.tabs__tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: -1px;
    padding: var(--space-3);
    border: none;
    border-bottom: 3px solid transparent;
    background: none;
    color: var(--muted);
    font-family: var(--font-body);
    font-size: var(--text-button);
    line-height: var(--leading-button);
    font-weight: var(--weight-semibold);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

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

.tabs__tab[aria-current="page"],
.tabs__tab[aria-selected="true"] {
    color: var(--plum-dark);
    font-weight: var(--weight-bold);
    border-bottom-color: var(--oak);
}

.tabs__panel[hidden] { display: none; }

/* --------------------------------------------------------- flashes and callouts
   .callout is the one message set apart from the page: a tinted block with an
   icon, a body and, optionally, a title and one small action (templates/
   _callout.html.twig). The body stays ink; only the icon and the title take
   the tone colour, and the tint is the signal: no coloured left edge. Every
   flash and every in-page error is a callout; .flash and .flash--{tone} stay
   on those elements as hooks for the print rule (layout.css) and the tests,
   and carry no styles of their own. */

.callout {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--sunken);
    border-radius: var(--radius-lg);
    background: var(--sunken);
    color: var(--ink);
    font-size: var(--text-table);
    line-height: var(--leading-table);
    font-weight: var(--weight-regular);
}

.callout .icon { width: 20px; height: 20px; margin-top: 1px; }
.callout p { margin: 0; }
.callout ul { margin: 0; padding-left: var(--space-5); }
.callout__body { flex: 1; min-width: 0; }
.callout__actions { flex: none; }

/* Paragraphs, lists and a form inside one callout sit a step apart; the
   visually hidden tone word that opens the body takes no space. */
.callout .callout__body > * + * { margin-top: var(--space-2); }
.callout .callout__body > .sr-only + * { margin-top: 0; }
.callout .callout__body > .callout__title + * { margin-top: var(--space-1); }

.callout__title {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--text-table);
    line-height: var(--leading-table);
    font-weight: var(--weight-bold);
}

.callout--success { background: var(--sage-tint); border-color: var(--sage-tint); }
.callout--success .icon, .callout--success .callout__title { color: var(--sage-deep); }

.callout--warning { background: var(--attention-tint); border-color: var(--attention-tint); }
.callout--warning .icon, .callout--warning .callout__title { color: var(--attention); }

.callout--error { background: var(--danger-tint); border-color: var(--danger-tint); }
.callout--error .icon, .callout--error .callout__title { color: var(--danger); }

.callout--info { background: var(--info-tint); border-color: var(--info-tint); }
.callout--info .icon, .callout--info .callout__title { color: var(--info); }

/* On a narrow screen the action wraps under the text, in line with it. */
@media (max-width: 560px) {
    .callout { flex-wrap: wrap; }
    .callout__body { flex-basis: calc(100% - 20px - var(--space-3)); }
    .callout:not(:has(.icon)) .callout__body { flex-basis: 100%; }
    .callout__actions { flex-basis: 100%; padding-left: calc(20px + var(--space-3)); }
    .callout:not(:has(.icon)) .callout__actions { padding-left: 0; }
}

/* ---------------------------------------------------------------------- cards
   Flat: card fill, 1px line, no shadow. .form-card (forms.css) is the same
   surface for forms. The parent dashboard's .child-card and .camera-card are
   not here. */

.card,
.panel {
    padding: var(--space-5);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--card);
}

/* A card is always --space-4 from the block after it. Margin-bottom (not the
   owl pattern) so a card followed by a form, table or search box gets the gap
   too; margins collapse with the next block's own margin-top. Containers that
   space their children with `gap` reset it below, so the gap is never doubled.
   .form-card (forms.css) is in this family and gets the same margin there. */
.card,
.panel { margin-bottom: var(--space-4); }

.stack > .card,
.stack > .panel,
.stack > .form-card,
.detail-grid > .card,
.detail-grid > .panel,
.detail-grid > .form-card,
.card-grid > .card,
.card-grid > .panel,
.card-grid > .form-card,
.form-section > .card { margin-bottom: 0; }

/* The panel contains a floated .panel__action: without flow-root an action
   placed last (Sync now, on the payroll page) hangs out through the border. */
.panel { display: flow-root; }

/* A finished or all-clear panel: a sage edge, nothing else changes. */
.panel--done { border-color: var(--sage); }

.panel__action {
    float: right;
    font-family: var(--font-body);
    font-size: var(--text-label);
    line-height: var(--leading-label);
    font-weight: var(--weight-semibold);
}

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin: 0 0 var(--space-3);
}

.card__title,
.panel__title {
    margin: 0 0 var(--space-3);
    font-family: var(--font-display);
    font-size: var(--text-display-card);
    line-height: var(--leading-display-card);
    font-weight: var(--weight-semibold);
    color: var(--ink);
}

.card__head .card__title { margin: 0; }

/* A bare paragraph in a card. :where() keeps this at (0,1,0): `.card > p` was
   (0,1,1), which beat every single-class paragraph style that comes after it
   (.card__note, .order-margin, .card-assurance, .form-error, .code-warning:
   their margin and size were silently replaced by these). Now they win by
   coming later, like any two single-class rules. */
.card > :where(p) { margin: 0 0 var(--space-3); font-size: var(--text-table); line-height: var(--leading-table); }
.card > :where(p:last-child) { margin-bottom: 0; }

.card__note { margin: var(--space-3) 0 0; font-size: var(--text-small); line-height: var(--leading-small); color: var(--muted); }

.card__sub {
    margin: var(--space-5) 0 var(--space-2);
    font-size: var(--text-label);
    line-height: var(--leading-label);
    font-weight: var(--weight-bold);
}

.card .table-wrap { border-radius: var(--radius-md); }

/* Groups inside one card (Leave and cover: On leave, then Temporary staff),
   each with a small .card__sub heading. The first heading sits at the top. */
.card__group + .card__group { margin-top: var(--space-4); }
.card__head + .card__group > .card__sub { margin-top: 0; }

/* One line of state with its action on the right, e.g. the Director row. */
.card--row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-table);
    line-height: var(--leading-table);
}

/* The text side takes the room the action leaves, and the action drops under
   it when there is less than 20rem for the text (a phone). */
.card--row > div { display: flex; align-items: center; gap: var(--space-3); flex: 1 1 20rem; flex-wrap: wrap; }

.card-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

/* ------------------------------------------------------------------- tag, count
   .room-badge (a child's room, on the parent dashboard and in the admin child
   and staff screens) is the same neutral chip as .tag: oak is not a chip colour. */

.tag,
.room-badge {
    display: inline-block;
    padding: 0 var(--space-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--sunken);
    color: var(--muted);
    font-size: var(--text-overline);
    line-height: var(--leading-small);
    font-weight: var(--weight-bold);
    white-space: nowrap;
}

a.room-badge { text-decoration: none; }
a.room-badge:hover { text-decoration: underline; }

.count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--sunken);
    color: var(--muted);
    font-size: var(--text-overline);
    line-height: var(--leading-small);
    font-weight: var(--weight-bold);
    text-align: center;
}

/* ---------------------------------------------------------------- empty state */

.empty-state {
    padding: var(--space-10) var(--space-5);
    border: 1px dashed var(--line-control);
    border-radius: var(--radius-lg);
    background: var(--card);
    color: var(--muted);
    font-size: var(--text-table);
    line-height: var(--leading-table);
    text-align: center;
}

.empty-state p { margin: 0; }
.empty-state p + p { margin-top: var(--space-1); }

.empty-state__title {
    margin: 0 0 var(--space-1);
    font-family: var(--font-display);
    font-size: var(--text-display-card);
    line-height: var(--leading-display-card);
    font-weight: var(--weight-semibold);
    color: var(--ink);
}

.empty-state .empty-state__action { margin-top: var(--space-4); } /* beats `.empty-state p + p` */

/* Extra breathing room below a work-queue notice sitting above a search box. */
.empty-state--spaced { margin-bottom: var(--space-6); }

/* ----------------------------------------------------------------- buttons
   Primary (plum fill), secondary (visible control border), ghost (no border,
   plum-tint hover), danger (danger border and label), small. A bare .btn is
   quiet like ghost without the hover. Disabled is 50% opacity and no pointer,
   for the attribute, aria-disabled and the .is-disabled class (the pager's
   ends keep their buttons in place so the row does not jump). */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 40px;
    padding: 0 var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: none;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--text-button);
    line-height: var(--leading-button);
    font-weight: var(--weight-bold);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.btn--primary { background: var(--plum); color: var(--on-plum); }
.btn--primary:hover { background: var(--plum-dark); }

.btn--secondary { background: var(--card); border-color: var(--line-control); color: var(--plum-dark); }
.btn--secondary:hover { background: var(--plum-tint); border-color: var(--plum); }

.btn--ghost { color: var(--plum-dark); }
.btn--ghost:hover { background: var(--plum-tint); }

.btn--danger { background: var(--card); border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-tint); }

/* Ghost and danger together: the quiet destructive button, the danger label
   without the danger outline. Both single-class rules above have the same
   specificity, so without this the later .btn--danger won and drew the outline. */
.btn--ghost.btn--danger { border-color: transparent; background: transparent; }
.btn--ghost.btn--danger:hover { background: var(--danger-tint); }

.btn--small {
    min-height: 32px;
    padding: 0 var(--space-3);
    font-size: var(--text-small);
    line-height: var(--leading-small);
}

.btn--block { width: 100%; }

/* Icon-only action buttons in listings (tooltip via title, sr-only label). */
.btn--icon { width: 40px; padding: 0; }
.btn--small.btn--icon { width: 32px; }
.btn--icon .icon { display: inline-block; vertical-align: middle; }

.btn:disabled,
.btn[aria-disabled="true"],
.btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 640px) {
    .btn,
    .btn--small { min-height: 44px; }
    .btn--icon,
    .btn--small.btn--icon { width: 44px; }
}

/* ---------------------------------------------------------------- stat cards */

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

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
}

a.stat-card:hover { border-color: var(--plum); }

.stat-card__number {
    font-family: var(--font-display);
    font-size: var(--text-display-stat);
    line-height: var(--leading-display-stat);
    font-weight: var(--weight-semibold);
    color: var(--plum-dark);
}

.stat-card__number small {
    font-size: var(--text-display-card);
    line-height: var(--leading-display-card);
    color: var(--muted);
    font-weight: var(--weight-regular);
}

.stat-card__label {
    font-size: var(--text-small);
    line-height: var(--leading-small);
    font-weight: var(--weight-bold);
    color: var(--muted);
}

.stat-card__note { font-size: var(--text-small); line-height: var(--leading-small); color: var(--muted); }

/* ------------------------------------------------------------ tiles, dl */

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

.tile {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
}

a.tile:hover { border-color: var(--plum); }

.tile__icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--plum-tint);
    color: var(--plum-dark);
}

.tile__title { display: block; font-size: var(--text-table); line-height: var(--leading-table); font-weight: var(--weight-bold); }
.tile__text { display: block; margin: 2px 0 var(--space-2); font-size: var(--text-small); line-height: var(--leading-small); color: var(--muted); }

.dl {
    display: grid;
    grid-template-columns: minmax(120px, 200px) minmax(0, 1fr);
    gap: var(--space-2) var(--space-4);
    margin: 0;
    font-size: var(--text-table);
    line-height: var(--leading-table);
}

.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.dl dd .muted { display: block; font-size: var(--text-small); line-height: var(--leading-small); }

.dl--stacked { grid-template-columns: minmax(0, 1fr); gap: 0; }
.dl--stacked dt { font-size: var(--text-small); line-height: var(--leading-small); }
.dl--stacked dd { margin-bottom: var(--space-3); }
.dl--stacked dd:last-child { margin-bottom: 0; }

/* A row of figures, each a small card: label above a display number. Each
   pair sits in a div, which is valid inside a dl. */
.dl--figures {
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.dl--figures > div {
    min-width: 0;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--card);
}

.dl--figures dt { font-size: var(--text-small); line-height: var(--leading-small); }

.dl--figures dd {
    font-family: var(--font-display);
    font-size: var(--text-display-section);
    line-height: var(--leading-display-section);
    font-weight: var(--weight-semibold);
}

@media (max-width: 640px) {
    .dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .dl dd { margin-bottom: var(--space-3); }
    .dl--figures { gap: var(--space-3); }
    .dl--figures dd { margin-bottom: 0; }
    .tile-grid { grid-template-columns: minmax(0, 1fr); }
    .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------------------- status
   A pill with a word and a mark whose shape changes with its meaning (ring =
   neutral, disc = positive or informational, half disc = needs attention,
   diamond = a problem), so it never rests on colour alone. The class names are
   the portal's: status--on is positive, status--off is the danger tone,
   status--attention is attention (status--draft is its older name, kept for
   the parent pages), status--info is info, and no modifier is neutral.
   Markup comes from the status macro (templates/_status.html.twig) and the
   App\Ui\Tone enum, never written by hand in an admin template. */

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    background: var(--sunken);
    color: var(--muted);
    font-size: var(--text-small);
    line-height: var(--leading-small);
    font-weight: var(--weight-semibold);
    /* A pill that wraps reads as two broken words rather than one status. It is
       short by definition, so it never needs to break. */
    white-space: nowrap;
}

.status::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.status--on { background: var(--sage-tint); color: var(--sage-deep); }
.status--on::before { background: currentColor; }

.status--info { background: var(--info-tint); color: var(--info); }
.status--info::before { background: currentColor; }

.status--attention,
.status--draft { background: var(--attention-tint); color: var(--attention); }
.status--attention::before,
.status--draft::before { background: linear-gradient(to right, currentColor 50%, transparent 50%); }

.status--off { background: var(--danger-tint); color: var(--danger); }
.status--off::before { background: currentColor; border-radius: 1px; transform: rotate(45deg) scale(0.85); }

/* A status whose label is a whole sentence, in a narrow column (the side cards
   on a record page). Put .status-block on the element around the badge and the
   pill may wrap inside it: the text breaks at spaces, the pill keeps to the
   width it is given, and the mark stays level with the first line. Everywhere
   else a status stays one short line (the nowrap above), so none of this
   applies to a badge in a table or a list. The rounded rectangle is because a
   full pill radius looks like a stadium once there are two lines. */
.status-block .status {
    max-width: 100%;
    align-items: flex-start;
    border-radius: var(--radius-md);
    white-space: normal;
}

.status-block .status::before { margin-top: calc((var(--leading-small) - 8px) / 2); }

/* ------------------------------------------------------------------- toolbar */

.toolbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin: 0 0 var(--space-3); }

.toolbar__search { position: relative; flex: 1 1 220px; max-width: 320px; }
.toolbar__search .icon { position: absolute; top: 12px; left: 12px; color: var(--muted); }
.toolbar__search .input { padding-left: 36px; }
.toolbar select.input { width: auto; max-width: 100%; }
.toolbar__clear { font-size: var(--text-label); line-height: var(--leading-label); color: var(--muted); }

.toolbar__count {
    margin-left: auto;
    font-size: var(--text-label);
    line-height: var(--leading-label);
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* The bulk-action bar above a queue table. */
.table-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.table-actions__hint { color: var(--muted); font-size: var(--text-label); line-height: var(--leading-label); }

/* --------------------------------------------------------------------- tables */

/* Positioned so its scrolling also holds the absolutely positioned .sr-only
   labels in action cells. Without it they are laid out against the page
   instead, past the table's scroll, and widen the whole page on a phone. */
.table-wrap {
    position: relative;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-table);
    line-height: var(--leading-table);
    font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
    padding: calc(var(--space-3) - 2px) var(--space-4);
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.data-table thead th {
    background: var(--sunken);
    color: var(--muted);
    font-size: var(--text-overline);
    line-height: var(--leading-overline);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-overline);
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table tbody tr:hover { background: var(--paper); }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table a:not(.btn) { font-weight: var(--weight-semibold); text-decoration: none; }
.data-table a:not(.btn):hover { text-decoration: underline; }

/* Amounts and counts line up on the right. */
.data-table .is-numeric { text-align: right; }

.data-table__actions {
    text-align: right;
    white-space: nowrap;
}

/* ...except when it holds a form: a select plus a button needs to be able to
   wrap, or it pushes the table into a horizontal scroll on the narrower admin
   screens. */
.data-table__actions:has(.inline-form) { white-space: normal; }

/* A row with three or more icon actions (Guardians) lets them wrap into a
   block of two or three per line (the min-width stops them stacking one
   per line) while the content column is narrow
   (sidebar shown, viewport under 1280px), instead of pushing the last
   actions out of sight inside the table's scroll. */
@media (max-width: 1279px) {
    .data-table__actions:has(> :nth-child(3)) {
        white-space: normal;
        min-width: calc(3 * 32px + 2 * var(--space-1) + 2 * var(--space-3));
    }
    .data-table__actions:has(> :nth-child(3)) > * { margin-top: 2px; margin-bottom: 2px; }
}

/* Values that mean less broken in half than scrolled to: a person's name, a
   date range, an amount. Pair with .table-wrap, which scrolls. */
.data-table__nowrap { white-space: nowrap; }

/* DataTable conventions, for every admin list (the design system's DataTable):
 *  - <th scope="col"> on every header cell; the last, empty-looking one holds
 *    <span class="sr-only">Actions</span>.
 *  - The first column is the record's name and links to its page. A second
 *    fact about it goes under the name in .data-table__sub, not in a column.
 *  - Counts and amounts: class is-numeric on the th and the td (right-aligned;
 *    .data-table already sets tabular figures).
 *  - An empty cell shows <span class="muted">&mdash;</span>, always.
 *  - Row actions in the last .data-table__actions cell: icon buttons
 *    (btn btn--small btn--icon, a title and sr-only text that names the row).
 *
 * Columns that drop on a phone. At 640px and under (the breakpoint the other
 * components in this file use) a list keeps its name and its status and drops
 * the rest:
 *    .is-wide-only    on the th AND every td of a column that only shows
 *                     above 640px;
 *    .is-narrow-only  on a sub-line (.data-table__sub) or a note that only
 *                     shows at 640px and under, to stand in for the dropped
 *                     columns ("Educator · RECE" under the name).
 * Whatever is hidden has to stay reachable on the record the name links to,
 * so never use .is-wide-only on the only way to do something. display: none
 * takes the cell out of the accessibility tree too, which is why the
 * sub-line repeats the facts rather than hiding a duplicate. The two rules
 * themselves follow .data-table__sub below. */

/* A quieter second line under the main value in a cell: an age under a name, a
   date under a title. Keeps a column to one idea instead of spending a whole
   column on each half of it. */
.data-table__sub {
    display: block;
    margin-top: 2px;
    font-size: var(--text-small);
    line-height: var(--leading-small);
    color: var(--muted);
}

/* For a long unbroken value such as an email in a crowded table: it may break anywhere rather than widen the table. */
.data-table__sub--break { overflow-wrap: anywhere; }

/* Must come after .data-table__sub (display: block) so it wins at equal specificity. */
@media (min-width: 641px) {
    .is-narrow-only { display: none; }
}

@media (max-width: 640px) {
    .is-wide-only { display: none; }
}

/* An action cell holding a control plus its button: right-aligned as a group,
   and allowed to wrap onto two lines on a narrow screen rather than forcing the
   whole table into a sideways scroll. */
.data-table__actions .inline-form {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.data-table__actions form { display: inline-block; margin-left: var(--space-1); }

/* An actions cell of text buttons (Approve, Decline; Add to roster): they wrap
   under each other on a narrow screen instead of pushing the table into a
   sideways scroll, and sit on the row's right edge when they fit. */
.data-table__actions--wrap { white-space: normal; }
.data-table__actions--wrap > * { margin-top: 2px; margin-bottom: 2px; }

/* A form's own internal controls (e.g. a payer <select> beside its submit
   button) laid out inline, without .form-actions' card-row chrome. */
.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
}

/*
 * A single-line list of row actions inside a table cell, distinct from
 * .form-actions (a block-level row below a card, with its own top border and
 * margin, which looks broken when reused inside <td>). Each action (a <form>,
 * <a>, or <span>) is a direct child; a subdued vertical rule separates them
 * instead of a pipe glyph.
 *
 * Deliberately NON-wrapping: a wrapped divider orphaned onto its own line looks
 * broken. If a row's actions don't fit, .table-wrap's horizontal scroll is the
 * intended overflow behaviour, not an internal second line: keep the action
 * count per row small (2-3) so this stays moot in practice.
 */
.row-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
}

.row-actions > * { display: inline-flex; align-items: center; margin: 0; }

/* The divider goes on every visible text-link child after the first. A hidden
   input (the CSRF token a form carries when the form is the .row-actions)
   draws nothing, so it must not make the first visible child look like the
   second: `:not(hidden) ~ :not(hidden)` is "has a visible child before it". A
   control (.btn, .input) is not a text link: a divider's padding and left
   border would overwrite its own box, so it is left out of the rule and takes
   a small gap instead (after .row-actions__link, below). :where() keeps the
   whole rule at (0,1,0), where `* + *` was, so every override of it still
   wins. The `--buttons` variant (admin.css) is a set of small buttons on a
   gap, not text links, so it takes no divider at all. */
.row-actions:where(:not(.row-actions--buttons)) > :where(:not([type="hidden"]) ~ :not([type="hidden"], .btn, .input)) {
    margin-left: var(--space-3);
    padding-left: var(--space-3);
    border-left: 1px solid var(--line);
}

/* Left-aligned instead of the default right-aligned (data-table__actions), for
   a badge-plus-link pairing inside an ordinary data cell. */
.row-actions--start { justify-content: flex-start; }

/* A muted detail line directly under a data-table row, for secondary facts
   that don't need their own always-visible column (invoice period, due date,
   paid-via, refund status): keeps the primary row down to the few columns that
   matter, which is what keeps a table usable at mobile widths. */
.data-table__row--with-subrow td { border-bottom: none; padding-bottom: var(--space-1); }

.data-table__subrow td {
    padding-top: 0;
    padding-bottom: var(--space-3);
    font-size: var(--text-small);
    line-height: var(--leading-small);
    color: var(--muted);
}

.data-table__meta { display: flex; flex-wrap: wrap; row-gap: var(--space-1); }

.data-table__meta > * + * {
    margin-left: var(--space-3);
    padding-left: var(--space-3);
    border-left: 1px solid var(--line);
}

/* A row action rendered as plain text rather than a button: for compact
   single-line lists like "Mark configured | End billing". */
.row-actions__link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    font-size: var(--text-small);
    line-height: var(--leading-small);
    font-weight: var(--weight-semibold);
    color: var(--plum-dark);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.row-actions__link:hover { text-decoration: underline; }
.row-actions__link--danger { color: var(--danger); }
.row-actions__link--muted { color: var(--muted); font-weight: var(--weight-regular); }

/* The gap for controls in a plain row (a date box, a room list, Save, then a
   "Stays" link): a control after something visible, and a link after a
   control, sit --space-2 apart and keep their own padding and border. After
   .row-actions__link on purpose: it resets its own margin at the same (0,1,0),
   so the later rule wins. A row of text links only is not touched. */
.row-actions:where(:not(.row-actions--buttons)) > :where(:not([type="hidden"]) ~ .btn, :not([type="hidden"]) ~ .input, .btn ~ .row-actions__link, .input ~ .row-actions__link) {
    margin-left: var(--space-2);
}

/* ---------------------------------------------------------------- pagination
   Prev/next with a position readout. No numbered page links: with a search box
   above it, "which page is the Nguyens on" is never the question; the readout
   is there to say how much list is left, not to be navigated by. */

.pager,
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-top: var(--space-3);
}

.pager__info {
    font-size: var(--text-label);
    line-height: var(--leading-label);
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.pager__pages { white-space: nowrap; }

/* The ends of the list keep their buttons in place rather than removing them:
   a control that disappears makes the row jump under the cursor. */
.pager .is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 560px) {
    .pager__pages { display: none; }
}

/* ------------------------------------------------------------------- mobile */

@media (max-width: 700px) {
    /* Denser tables buy more room before .table-wrap needs to scroll
       horizontally: the intended overflow behaviour on narrow screens, rather
       than squeezing action rows into an awkward multi-line wrap. */
    .data-table th,
    .data-table td { padding: var(--space-2) var(--space-3); font-size: var(--text-label); line-height: var(--leading-label); }
    .data-table__subrow td { font-size: var(--text-small); line-height: var(--leading-small); }
}

@media (max-width: 560px) {
    .page-head--row { align-items: stretch; }
    .page-head--row .btn { align-self: flex-start; }
}

/* ---------------------------------------------------------- guided walkthroughs */

.guide-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: var(--space-5);
    background: color-mix(in srgb, var(--ink) 45%, transparent);
}

.guide-modal__card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-overlay);
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: var(--space-6);
}

.guide-modal__eyebrow {
    margin: 0;
    font-size: var(--text-overline);
    line-height: var(--leading-overline);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-overline);
    text-transform: uppercase;
    color: var(--oak-deep);
}

.guide-modal__head h2 {
    font-family: var(--font-display);
    font-size: var(--text-display-section);
    line-height: var(--leading-display-section);
    font-weight: var(--weight-semibold);
    margin: var(--space-1) 0 var(--space-1);
}

.guide-modal__progress {
    margin: 0 0 var(--space-3);
    color: var(--muted);
    font-size: var(--text-small);
    line-height: var(--leading-small);
}

.guide-modal__foot {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-5);
}

/* ------------------------------------------------------------ dialog popups
   A native <dialog> opened with showModal(): the browser supplies the backdrop,
   Esc to close, and keeps focus inside. The card and its footer are not divs,
   because `.form-card div` spaces every div in a card and a dialog can sit in
   one. */

.dialog {
    width: min(460px, calc(100vw - var(--space-8)));
    max-height: 85vh;
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--card);
    color: var(--ink);
    box-shadow: var(--shadow-overlay);
}

/* ::backdrop does not reliably inherit custom properties, and the tokens have
   no scrim, so this is --ink (58, 50, 68) at 45%. */
.dialog::backdrop { background: rgba(58, 50, 68, 0.45); }

.dialog__card { display: block; padding: var(--space-6); }

.dialog__title {
    margin: 0 0 var(--space-2);
    font-family: var(--font-display);
    font-size: var(--text-display-section);
    line-height: var(--leading-display-section);
    font-weight: var(--weight-semibold);
}

.dialog__card p { margin: 0 0 var(--space-4); font-size: var(--text-table); line-height: var(--leading-table); }

.dialog__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-5);
}

/* The confirmation (assets/controllers/confirm_controller.js): the one dialog a
   question is asked in. 480px at most, and on a phone the width of the screen
   less a 16px gutter. Its card is a section and its footer a footer, not divs,
   like every popup. The Cancel button is quiet and sits left of the confirm
   button, which is a danger button for anything that removes or cancels, a
   primary one otherwise. */
.confirm-dialog {
    width: min(480px, calc(100vw - var(--space-8)));
    /* The browser gives a modal dialog max-width: 100% - 6px - 2em, which is
       wider than the gutter this one keeps on a phone. */
    max-width: none;
}

.confirm-dialog__body { color: var(--ink); }
.confirm-dialog__body[hidden],
.confirm-dialog__note[hidden] { display: none; }

.confirm-dialog__note { margin: 0 0 var(--space-4); }
.confirm-dialog__note-label { display: block; margin-bottom: var(--space-1); }

/* A numbered list in a popup: the children a count is made of. */
.dialog__list {
    margin: var(--space-3) 0 0;
    padding-left: var(--space-6);
    font-size: var(--text-table);
    line-height: var(--leading-table);
}
