/*
 * Conflr — shared components.
 *
 * Everything a Conflr admin screen is built from: type, page header, buttons,
 * pills, cards, tables, row actions, filters, KPI tiles, gauges, callouts,
 * fields, the save bar, empty states and menus. Copied into each module by
 * `php tools/sync-theme.php`, like `tokens.css`.
 *
 * Load order, visible in every layout: tokens → components → the module's own
 * admin.css → nav. A module's stylesheet only holds what is particular to it
 * (the RAS board, the crew grid…); it never restyles a button.
 *
 * Colours come from `tokens.css` and nowhere else. The rule of thumb for a hue:
 * `--module` for a dot or a rail, `--module-strong` under white text,
 * `--module-ink` for text and links, `--module-soft` for a light ground.
 */

/* ==========================================================================
   Base
   ========================================================================== */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: var(--fs-body)/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    /* Inter's straight-sided 1 and open 4 read better in dense tables. */
    font-feature-settings: "cv05", "cv08";
}

a { color: var(--module-ink); text-decoration: none; }
a:hover { color: var(--module-ink); text-decoration: underline; }

/* One focus ring for everything, in the module's hue. `:focus-visible` so a
   mouse click does not leave a ring behind. */
:focus-visible {
    outline: 2px solid var(--module);
    outline-offset: 2px;
}

code, kbd, samp, .mono {
    font-family: var(--mono);
    font-size: 0.9em;
}

/* Numbers, dates and amounts line up in a column. */
.numeric, .num, time, .tabular { font-variant-numeric: tabular-nums; }

/* ---- Icons -------------------------------------------------------------
   Inline SVGs drawn with `currentColor`, so an icon takes the colour of the text
   it sits in. 16px by default, aligned to the text's middle.
   ---------------------------------------------------------------------- */
.icon {
    width: 16px;
    height: 16px;
    flex: none;
    vertical-align: -3px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---- Hue scopes ----------------------------------------------------------
   `.hue-content` and friends set a local family (`--h`, `--h-strong`,
   `--h-ink`, `--h-soft`, `--h-on-dark`, `--h-eyebrow`) so a dot, a ring or a
   rail can take another module's or space's colour without a literal.
   ---------------------------------------------------------------------- */
.hue-space { --h: var(--hue-space); --h-strong: var(--hue-space-strong); --h-ink: var(--hue-space-ink); --h-soft: var(--hue-space-soft); --h-on-dark: var(--hue-space-on-dark); --h-eyebrow: var(--hue-space-eyebrow); }
.hue-esignage { --h: var(--hue-esignage); --h-strong: var(--hue-esignage-strong); --h-ink: var(--hue-esignage-ink); --h-soft: var(--hue-esignage-soft); --h-on-dark: var(--hue-esignage-on-dark); --h-eyebrow: var(--hue-esignage-eyebrow); }
.hue-floorplan { --h: var(--hue-floorplan); --h-strong: var(--hue-floorplan-strong); --h-ink: var(--hue-floorplan-ink); --h-soft: var(--hue-floorplan-soft); --h-on-dark: var(--hue-floorplan-on-dark); --h-eyebrow: var(--hue-floorplan-eyebrow); }
.hue-expo { --h: var(--hue-expo); --h-strong: var(--hue-expo-strong); --h-ink: var(--hue-expo-ink); --h-soft: var(--hue-expo-soft); --h-on-dark: var(--hue-expo-on-dark); --h-eyebrow: var(--hue-expo-eyebrow); }
.hue-content { --h: var(--hue-content); --h-strong: var(--hue-content-strong); --h-ink: var(--hue-content-ink); --h-soft: var(--hue-content-soft); --h-on-dark: var(--hue-content-on-dark); --h-eyebrow: var(--hue-content-eyebrow); }
.hue-auth { --h: var(--hue-auth); --h-strong: var(--hue-auth-strong); --h-ink: var(--hue-auth-ink); --h-soft: var(--hue-auth-soft); --h-on-dark: var(--hue-auth-on-dark); --h-eyebrow: var(--hue-auth-eyebrow); }

/* Only for screen readers: a label for an icon-only control. Pinned to the top
   left of its containing block, so it can never reach past a scroll edge. */
.sr-only {
    top: 0;
    left: 0;
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Page frame
   ========================================================================== */

.main {
    padding: 28px 40px 48px;
    max-width: 1280px;
    min-width: 0;
}

/* Opt-in for pages whose content is one wide data table. */
.main.main-wide { max-width: 1760px; }

/* ---- Page header -------------------------------------------------------
   Breadcrumb → title (+ status pill) → a line of metadata → actions on the
   right. `header.page` and a bare `.main > h1` are the older forms of the same
   thing and are styled to match until every template uses `.page-head`.
   ---------------------------------------------------------------------- */
.page-head,
header.page {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 24px;
    flex-wrap: wrap;
    margin: 0 0 24px;
}
.page-head-main { min-width: 0; }

.crumbs,
header.page .crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin: 0 0 6px;
    font-size: 13px;
    color: var(--text-2);
}
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--text); }
/* The separator is drawn, not typed, so a screen reader reads a list of places. */
.crumbs > * + *::before {
    content: "/";
    margin-right: 8px;
    color: var(--line-strong);
}
.crumbs [aria-current] { color: var(--text-3); }

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

.page-head h1,
header.page h1,
.main > h1 {
    margin: 0;
    font-size: var(--fs-title);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.4px;
    color: var(--text);
}
.main > h1 { margin-bottom: 8px; }

/* A sentence under the title: what this screen is for. */
.page-sub,
.lede {
    margin: 6px 0 0;
    max-width: 72ch;
    color: var(--text-2);
    font-size: 15px;
    line-height: 1.5;
}
.lede { margin: 0 0 20px; font-size: 14px; }
.lede strong { color: var(--text); font-weight: 600; }

/* "9 – 12 Nov 2026 · 4 days   America/New_York   Hynes, Boston" */
.page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 22px;
    margin: 10px 0 0;
    color: var(--text-2);
    font-size: 15px;
}
.page-meta > span { display: inline-flex; align-items: center; gap: 7px; }
.page-meta .icon { color: var(--text-3); }

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

/* The row of actions that follows a heading, in pages that do not have a
   `.page-head` yet. */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 20px;
}
.toolbar .spacer { flex: 1; }
.toolbar-export { margin-top: -4px; margin-bottom: 12px; }

/* Section headings inside a page. Card titles at heart: 16/600, sentence case. */
.main h2 {
    margin: 32px 0 12px;
    font-size: var(--fs-card-title);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}
.main h2 + .lede { margin-top: -4px; }
.main h3 {
    margin: 20px 0 8px;
    font-size: 14px;
    font-weight: 600;
}
.main h3 small { color: var(--text-3); font-weight: 400; }

/* A small uppercase label above a group. The only place capitals are kept. */
.eyebrow {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-3);
}

/* A note after a table, explaining a convention the table itself cannot. */
.note {
    margin: -8px 0 20px;
    max-width: 72ch;
    font-size: var(--fs-help);
    color: var(--text-3);
    line-height: 1.5;
}

.muted, .muted a { color: var(--text-3); }
p.none, .none { color: var(--text-3); }

/* A missing value that matters ("no hotel yet"), as distinct from a dash for
   one that does not. */
.missing { color: var(--warning-ink); font-weight: 500; }

/* ==========================================================================
   Buttons — three weights plus danger. One primary per zone.
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    font: 500 14px/1.2 var(--font);
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}
.btn:active { transform: translateY(0.5px); }
.btn[disabled], .btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--module-strong);
    border-color: var(--module-strong);
    color: var(--surface);
    font-weight: 600;
}
.btn-primary:hover {
    background: var(--module-ink);
    border-color: var(--module-ink);
    color: var(--surface);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* Destructive: text only, in the danger ink. Never a red block — a delete
   should not be the loudest thing on the screen. */
.btn-danger {
    background: transparent;
    border-color: transparent;
    color: var(--danger-ink);
}
.btn-danger:hover { background: var(--danger-soft); color: var(--danger-ink); }

/* Table-row and inline size. Kept at 32px: a row of 40px buttons doubled the
   height of every table. */
.btn-sm {
    min-height: 32px;
    padding: 0 12px;
    font-size: 13px;
}

/* A square button holding only an icon (`⋯`, a switch arrow). Needs an
   aria-label. */
.btn-icon {
    width: 36px;
    min-height: 36px;
    padding: 0;
    border-color: transparent;
    background: transparent;
    color: var(--text-2);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.btn-sm { width: 32px; min-height: 32px; }

/* A button that reads as a link (inline "Change", "Show"). */
.btn-link {
    padding: 0;
    min-height: 0;
    border: 0;
    background: none;
    color: var(--module-ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }

/* A delete is its own inline <form> almost everywhere. */
form.inline, .inline-form { display: inline; margin: 0; }

/* ---- Tabs at the head of a page -----------------------------------------
   Several screens under one menu entry (Crew, Kit, an order form's sections).
   Underlined, so they read as places inside the page rather than as a filter.
   ---------------------------------------------------------------------- */
.tabs {
    display: flex;
    gap: 4px;
    margin: 4px 0 24px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 12px;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--text-2);
    font-size: 14.5px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current] {
    color: var(--text);
    font-weight: 600;
    border-bottom-color: var(--module);
}

/* ==========================================================================
   Pills (state) and tags (neutral)
   ========================================================================== */

/*
 * State pill: a dot and a word, soft ground, ink text. Confirmed / Paid / Done
 * = success; Draft / Awaiting / Proposed / Pending = warning; Cancelled /
 * Suspended / Missing = danger; Completed / Disabled = neutral.
 */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px 2px 9px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 500;
    line-height: 20px;
    white-space: nowrap;
    vertical-align: middle;
}
.pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}
/* A pill that is only a count or a word, no state: no dot. */
.pill.pill-plain::before { display: none; }

.pill-success, .pill-confirmed, .pill.status-confirmed, .pill.severity-ok,
.pill.status-paid, .pill.status-done {
    background: var(--success-soft);
    color: var(--success-ink);
}
.pill-warning, .pill-proposed, .pill.status-draft, .pill.severity-soon,
.pill.status-pending, .pill.status-awaiting {
    background: var(--warning-soft);
    color: var(--warning-ink);
}
.pill-danger, .pill-alert, .pill.status-cancelled, .pill.severity-overdue,
.pill.status-suspended, .pill.status-missing {
    background: var(--danger-soft);
    color: var(--danger-ink);
}
.pill-neutral, .pill.status-completed, .pill.severity-unknown, .pill.status-disabled {
    background: var(--surface-2);
    color: var(--text-2);
}

/* Some pills are buttons (the crew status toggles). */
button.pill {
    border: 0;
    cursor: pointer;
    font-family: inherit;
}
button.pill:hover { filter: brightness(0.96); }

/* On a coloured cell: tint with the ground rather than introduce one. */
.pill-on-color { color: inherit; background: color-mix(in srgb, var(--text) 8%, transparent); }

/* Tag: neutral, squarer, bordered. Room type, setup, a count beside a title. */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 1px 8px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12.5px;
    line-height: 20px;
    white-space: nowrap;
}
.tag-module { border-color: transparent; background: var(--module-soft); color: var(--module-ink); }

/* A count beside a heading or a menu entry: "Rooms 8". */
.count {
    display: inline-block;
    min-width: 22px;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
/* Things waiting for someone: unread site-log threads, sheets to review. */
.count-warn {
    border-color: transparent;
    background: var(--warning);
    color: var(--on-warning);
    font-weight: 600;
}

.swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--line);
    vertical-align: middle;
    margin-right: 6px;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 20px 24px;
    margin-bottom: 20px;
}
/* A card whose header and table run edge to edge. */
.card.card-flush { padding: 0; overflow: hidden; }
.card.card-flush > .card-body { padding: 20px 24px; }

.card-h,
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 16px;
}
.card-flush > .card-h {
    margin: 0;
    padding: 16px 20px 16px 24px;
    border-bottom: 1px solid var(--line);
}
.card-h h2, .card-h h3,
.card-header h2, .card-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: var(--fs-card-title);
    font-weight: 600;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
}
.card-h .card-sub { color: var(--text-3); font-size: 13.5px; }
.card-h .actions { margin-left: auto; }

/* A card's own explanatory sentence. */
.card > p:first-child, .card-body > p:first-child { margin-top: 0; }

/* Two or three cards side by side; one column on a phone. */
.grid-2, .grid-3, .grid-4 {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 > .card, .grid-3 > .card, .grid-4 > .card { margin-bottom: 0; }

/* Main column and a help column on the right (forms, order detail). */
.with-aside {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 24px;
    align-items: start;
}
.with-aside > aside { position: sticky; top: 24px; display: grid; gap: 16px; }
.with-aside > aside .card { margin: 0; padding: 18px 20px; }
.with-aside > aside .aside-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
}
.with-aside > aside .aside-title .icon { color: var(--module-ink); }
.with-aside > aside p { margin: 0 0 10px; color: var(--text-2); font-size: 14px; line-height: 1.55; }
.with-aside > aside p:last-child { margin-bottom: 0; }
.with-aside > aside .kv:not(.kv-tight) { font-size: 14px; grid-template-columns: 1fr auto; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- Key / value -------------------------------------------------------
   A `dl` as a two-column grid of fields, inside a card. Replaces full-width
   key/value tables.
   ---------------------------------------------------------------------- */
.kv {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 10px 20px;
    margin: 0;
    font-size: 14px;
}
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv.kv-tight { grid-template-columns: 96px minmax(0, 1fr); gap: 8px 14px; }

/* Fields as a grid of blocks — label above, value under — two per row. */
.fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 28px;
    margin: 0;
}
.fields > div { min-width: 0; }
.fields dt { font-size: 13px; color: var(--text-3); margin-bottom: 3px; }
.fields dd { margin: 0; overflow-wrap: anywhere; }
.fields .wide { grid-column: 1 / -1; }
/* Free text typed with line breaks (a client's notes): keep them. */
.pre-line { white-space: pre-line; }

/* ==========================================================================
   Tables
   ========================================================================== */

/* `.table` is what the templates write; `.list` is the older name. */
table.table,
table.list {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    margin-bottom: 20px;
    font-size: 14px;
}
table.table th, table.table td,
table.list th, table.list td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    /* Top: rows routinely carry a second line (a SKU, a warning). */
    vertical-align: top;
}
table.table td:first-child, table.table th:first-child,
table.list td:first-child, table.list th:first-child { padding-left: 24px; }
table.table td:last-child, table.table th:last-child,
table.list td:last-child, table.list th:last-child { padding-right: 24px; }

table.table thead th,
table.list thead th {
    padding-top: 11px;
    padding-bottom: 11px;
    background: var(--surface-head);
    color: var(--text-3);
    font-size: var(--fs-head);
    font-weight: 600;
    white-space: nowrap;
}
table.table thead th:first-child, table.list thead th:first-child { border-top-left-radius: var(--r-lg); }
table.table thead th:last-child, table.list thead th:last-child { border-top-right-radius: var(--r-lg); }
table.table tbody tr:last-child td,
table.list tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover > td,
table.list tbody tr:hover > td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* The name in a row's first column reads as the row's title. */
table.table td.title, table.table td .title { font-weight: 600; color: var(--text); }

table.table td.numeric, table.table th.numeric,
table.list td.numeric, table.list th.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* A group heading inside a table: "Upcoming · 3". */
table.table tr.group > th,
table.table tr.group > td {
    padding-top: 8px;
    padding-bottom: 8px;
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
/* A past or retired row: still there, visibly not current. */
table.table tr.is-past > td { color: var(--text-2); }
table.table tr.is-past > td .title { font-weight: 500; color: var(--text-2); }

table.table td small,
table.list td small {
    display: block;
    margin-top: 2px;
    color: var(--text-3);
    font-size: var(--fs-help);
    line-height: 1.35;
}
table.table code, table.list code { color: var(--text-2); font-size: 12.5px; }
table.table .none { color: var(--text-3); }

table.table td.actions, table.table th.actions,
table.list td.actions, table.list th.actions {
    /* `.actions` is also the flex row of page buttons; in a table it has to
       stay a cell. */
    display: table-cell;
    text-align: right;
    white-space: nowrap;
    vertical-align: middle;
}
table.table td form, table.list td form { display: inline-block; margin: 0; }
table.table td > a + form,
table.table td > form + form,
table.table td > a + a,
table.table td > form + a { margin-left: 10px; }
table.table td.actions > * { vertical-align: middle; }

/* A row that opens something: the name is the link, and its hit area is
   stretched over the whole row so a click anywhere on it works. Other links
   and buttons in the row stay above it. */
table.table tbody tr:has(.row-link) { position: relative; cursor: pointer; }
table.table .row-link { color: var(--text); }
table.table .row-link::after { content: ""; position: absolute; inset: 0; }
table.table .row-link:hover { text-decoration: none; }
table.table tr:has(.row-link) a:not(.row-link),
table.table tr:has(.row-link) button,
table.table tr:has(.row-link) details { position: relative; z-index: 1; }
table.table tr.is-past .row-link { color: var(--text-2); font-weight: 500; }
table.table td.col-go, table.table th.col-go { width: 40px; color: var(--text-3); text-align: right; vertical-align: middle; }
table.table tbody tr:hover td.col-go { color: var(--text); }
table.table td small.is-next { color: var(--module-ink); font-weight: 600; }

/* A row the operator has selected, or one an import flagged. */
tr.is-selected > td { background: var(--module-soft); }
.row-warn > td { background: var(--warning-soft); }
.row-warn > td:first-child { box-shadow: inset 3px 0 0 var(--warning); }

/* The total under a column of amounts. */
.total-row td {
    font-weight: 600;
    border-top: 1px solid var(--line-strong);
    background: var(--surface-head);
}

/* A table inside a card runs edge to edge: the card is the frame. */
.card > table.table,
.card > .table-wrap > table.table {
    border: 0;
    border-radius: 0;
    margin: 0;
}
.card > table.table thead th,
.card > .table-wrap > table.table thead th { border-radius: 0; }
.card > .table-wrap { margin: 0; }
/* The foot line of a card table: "6 events · Sorted by start date". */
.card-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    color: var(--text-3);
    font-size: 13px;
}

/* ---- Key/value tables as a card of fields --------------------------------
   A table with no head whose rows are a label and a value (a truck's details,
   a function's facts) is not a table of records: it is a record. Drawn as a
   card of fields, two to a row, label above value — the markup stays a table,
   which is what it was written as. */
table.table:not(:has(thead)):has(> tbody > tr > th + td) {
    display: block;
    padding: 22px 24px;
}
table.table:not(:has(thead)):has(> tbody > tr > th + td) > tbody {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 32px;
}
table.table:not(:has(thead)):has(> tbody > tr > th + td) > tbody > tr {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
table.table:not(:has(thead)):has(> tbody > tr > th + td) > tbody > tr > th,
table.table:not(:has(thead)):has(> tbody > tr > th + td) > tbody > tr > td {
    /* Beats the first/last-column insets of a records table. */
    padding: 0 !important;
    border: 0;
    background: none;
    text-align: left;
    overflow-wrap: anywhere;
}
table.table:not(:has(thead)):has(> tbody > tr > th + td) > tbody > tr > th {
    color: var(--text-3);
    font-size: 13px;
    font-weight: 400;
    white-space: normal;
}
table.table:not(:has(thead)):has(> tbody > tr > th + td) > tbody > tr:hover > td { background: none; }
table.table:not(:has(thead)):has(> tbody > tr > th + td) .note { margin: 6px 0 0; }

/* Wide tables scroll sideways inside their frame instead of the page. */
.table-wrap {
    position: relative;
    overflow-x: auto;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}
.table-wrap > table.table { margin-bottom: 0; min-width: 100%; width: max-content; }
.table-wrap > table.table td:first-child,
.table-wrap > table.table th:first-child { min-width: 180px; }
/* Known, bounded columns: fill the width and wrap inside cells. */
.table-wrap > table.table.table-fit { width: 100%; min-width: 900px; table-layout: fixed; }
.table-wrap > table.table.table-fit td:first-child,
.table-wrap > table.table.table-fit th:first-child { min-width: 0; }
.table-fit td { overflow-wrap: anywhere; }
.table-fit td.nowrap, .table-fit th.nowrap { overflow-wrap: normal; white-space: nowrap; }

/* ---- Toolbar at the head of a table: search left, filter right ---------- */
.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

/* ==========================================================================
   Row actions: one frequent action visible, the rest behind `⋯`
   ==========================================================================

   <div class="row-actions">
     <a href="…">RAS</a>
     <details class="menu">
       <summary class="btn btn-icon btn-sm" aria-label="More actions for Ballroom A">⋯</summary>
       <div class="menu-panel">
         <a href="…">Edit room</a>
         <a href="…">Availability</a>
         <hr>
         <form method="post" …><button class="menu-danger" data-confirm="…">Delete room…</button></form>
       </div>
     </details>
   </div>

   `<details>` so it opens with no script; `ui.js` adds Escape, click-outside and
   one-open-at-a-time. Delete is always last, below a rule, in red, confirmed. */
.row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}
.row-actions > a { font-weight: 600; padding: 4px 6px; }

.menu { position: relative; display: inline-block; }
.menu > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--surface-2); color: var(--text); }

.menu-panel {
    position: absolute;
    z-index: 60;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-2);
    text-align: left;
}
.menu.menu-left .menu-panel { right: auto; left: 0; }
.menu.menu-up .menu-panel { top: auto; bottom: calc(100% + 4px); }
.menu-panel a,
.menu-panel button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--r-sm);
    background: none;
    color: var(--text);
    font: 400 14px/1.2 var(--font);
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.menu-panel a:hover,
.menu-panel button:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.menu-panel form { display: block; margin: 0; }
.menu-panel hr {
    margin: 6px 4px;
    border: 0;
    border-top: 1px solid var(--line);
}
.menu-panel .menu-danger,
.menu-panel .menu-danger:hover { color: var(--danger-ink); }
.menu-panel .menu-danger:hover { background: var(--danger-soft); }
/* A menu entry with its reason under it ("Cancel the order — refund it first"). */
.menu-panel.menu-panel-wide { min-width: 300px; max-width: 340px; }
.menu-panel a > span, .menu-panel button > span, .menu-disabled > span { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; white-space: normal; }
.menu-panel small { color: var(--text-3); font-size: 12.5px; line-height: 1.35; }
.menu-panel .menu-danger small { color: var(--text-3); }
.menu-disabled { display: flex; padding: 0 12px; color: var(--text-3); cursor: not-allowed; }
.menu-panel .menu-label {
    padding: 8px 12px 4px;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 600;
}

/* ==========================================================================
   Filters and search
   ========================================================================== */

/* Segmented filter: tabs that each carry a count. Replaces a <select> plus a
   Filter button. Links (a server round trip) or radio labels. */
.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    border-radius: var(--r-md);
    background: var(--surface-2);
}
.segmented > a,
.segmented > button,
.segmented > label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--r-sm);
    background: none;
    color: var(--text-2);
    font: 500 14px/1.2 var(--font);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.segmented > a:hover,
.segmented > button:hover,
.segmented > label:hover { color: var(--text); text-decoration: none; }
.segmented > [aria-current],
.segmented > .is-on,
.segmented > label:has(input:checked) {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-1);
}
.segmented small,
.segmented .n {
    color: var(--text-3);
    font-size: 12.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.segmented > label input { position: absolute; opacity: 0; pointer-events: none; }
.segmented > label:has(input:focus-visible) { outline: 2px solid var(--module); outline-offset: 1px; }

/* The older chip row, kept as a segmented control so it looks the same. */
.chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    margin: 0 0 16px;
    border-radius: var(--r-md);
    background: var(--surface-2);
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 12px;
    border-radius: var(--r-sm);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}
.chip:hover { color: var(--text); text-decoration: none; }
.chip small { color: var(--text-3); font-size: 12.5px; }
.chip-on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1); }
/* Severity chips keep a state dot, never a state ground: the ground is the
   selected one. */
.chip-overdue::before, .chip-soon::before, .chip-unknown::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.chip-overdue::before { background: var(--danger); }
.chip-soon::before { background: var(--warning); }
.chip-unknown::before { background: var(--line-strong); }

/* Search field with a magnifier. The icon is an inline SVG in the markup:
   <label class="search"><svg class="icon">…</svg><input type="search" …></label> */
.search {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 1 26rem;
    min-width: 0;
}
.search .icon {
    position: absolute;
    left: 13px;
    color: var(--text-3);
    pointer-events: none;
}
.search input[type=search],
.search input[type=text] {
    width: 100%;
    min-height: 40px;
    padding: 0 12px 0 38px;
}

/* The older filter row: search + select + button. */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0 0 14px;
}
.filters input[type=search] { flex: 0 1 24rem; }

.pager {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 12px 0;
    color: var(--text-3);
}

/* ==========================================================================
   KPI tiles and gauges
   ========================================================================== */

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 0 0 24px;
}
.kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    color: var(--text);
    text-decoration: none;
}
a.kpi:hover { border-color: var(--line-strong); text-decoration: none; color: var(--text); }
.kpi-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-2);
    font-size: 13px;
}
.kpi-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.3px;
    font-variant-numeric: tabular-nums;
}
.kpi-value .kpi-unit,
.kpi-value small {
    margin-left: 4px;
    color: var(--text-2);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0;
}
.kpi-sub { color: var(--text-3); font-size: var(--fs-help); }
.kpi .gauge { margin-top: 10px; }
.kpi.warn { border-color: color-mix(in srgb, var(--warning) 45%, var(--line)); background: var(--warning-soft); }
.kpi.warn .kpi-sub { color: var(--warning-ink); }

/* A 6px bar. Success by default; `.warn` when the margin is one or less,
   `.danger` when over. Width as `style="--v: 72%"`. */
.gauge {
    display: block;
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    overflow: hidden;
}
.gauge > span {
    display: block;
    height: 100%;
    width: var(--v, 0%);
    border-radius: inherit;
    background: var(--success);
}
.gauge.warn > span { background: var(--warning); }
.gauge.danger > span { background: var(--danger); }
.gauge.neutral > span { background: var(--line-strong); }

/* ==========================================================================
   Callouts (and flashes)
   ========================================================================== */

/* Soft ground, border, icon, a short bold sentence and an action on the right.
   Replaces long warning paragraphs. */
.callout,
.flash {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 0 20px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
.flash { display: block; }
.callout > .icon { margin-top: 2px; }
.callout-body { flex: 1; min-width: 0; }
.callout-body > strong:first-child { font-weight: 600; }
.callout-body p { margin: 2px 0 0; color: var(--text-2); }
.callout-action { flex: none; align-self: center; }
.callout ul, .flash ul { margin: 6px 0 0; padding-left: 18px; }

.callout-success, .flash.success {
    border-color: color-mix(in srgb, var(--success) 35%, var(--surface));
    background: var(--success-soft);
    color: var(--success-ink);
}
.callout-warning, .flash.warning {
    border-color: color-mix(in srgb, var(--warning) 45%, var(--surface));
    background: var(--warning-soft);
    color: var(--warning-ink);
}
.callout-danger, .flash.error, .flash.danger {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--surface));
    background: var(--danger-soft);
    color: var(--danger-ink);
}
.callout-info {
    border-color: color-mix(in srgb, var(--module) 30%, var(--surface));
    background: var(--module-soft);
    color: var(--module-ink);
}
.callout-success p, .callout-warning p, .callout-danger p, .callout-info p { color: inherit; }

/* Inline warnings in a cell ("on two events that day"). */
.clash {
    display: block;
    max-width: 30ch;
    margin-top: 3px;
    color: var(--warning-ink);
    font-size: 12.5px;
    line-height: 1.4;
}
.clash-hard { color: var(--danger-ink); }

/* ==========================================================================
   Fields
   ==========================================================================

   Label above (13/600, sentence case), help under (12.5), `optional` in grey
   inside the label. Fields are styled wherever they are — a form card, an
   inline form in a table row, a filter bar. */

input[type=text], input[type=email], input[type=password], input[type=search],
input[type=url], input[type=tel], input[type=number], input[type=date],
input[type=time], input[type=datetime-local], input[type=month], input[type=color],
select, textarea {
    min-height: 40px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    color: var(--text);
    font: 400 14px/1.4 var(--font);
    font-variant-numeric: tabular-nums;
}
textarea { min-height: 96px; line-height: 1.5; resize: vertical; }
input[type=color] { padding: 4px; width: 56px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--module);
    outline-offset: -1px;
    border-color: var(--module);
}
input[disabled], select[disabled], textarea[disabled],
input[readonly], textarea[readonly] {
    background: var(--surface-2);
    color: var(--text-2);
}
/* A chevron drawn with two gradients, so it takes its colour from the tokens. */
select {
    appearance: none;
    padding-right: 34px;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
        linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
    background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
select[multiple] { background-image: none; padding-right: 12px; }
input[type=checkbox], input[type=radio] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--module-strong);
    vertical-align: -4px;
}

input[type=file] { font: inherit; font-size: 13px; color: var(--text-2); max-width: 100%; }
input[type=file]::file-selector-button {
    min-height: 36px;
    padding: 0 14px;
    margin-right: 10px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    font: 500 13px/1 var(--font);
    cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--surface-2); }

/* ---- The form frame ------------------------------------------------------ */
form.form {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 24px;
    max-width: 760px;
    margin-bottom: 20px;
}
/* A form made of section cards: the frame is the sections, not the form. */
form.form.form-sections {
    padding: 0;
    border: 0;
    background: none;
    max-width: none;
}

form.form .row, .form-section .row { margin-bottom: 18px; }
form.form .row.cols, .form-section .row.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
form.form .row.cols-3, .form-section .row.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 24px; }

form.form label,
.field > label,
label.label {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}
label .optional,
label small.optional {
    margin-left: 4px;
    color: var(--text-3);
    font-weight: 400;
}
form.form input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]),
form.form select,
form.form textarea { width: 100%; }

.hint,
form.form .hint,
.form .row small {
    display: block;
    margin-top: 6px;
    color: var(--text-3);
    font-size: var(--fs-help);
    line-height: 1.45;
}

/* A field the server refused. */
.field-error input, .field-error select, .field-error textarea,
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] {
    border-color: var(--danger);
}
/* Still red once focused: the field the message is about is the one people
   click into first. */
input[aria-invalid=true]:focus, select[aria-invalid=true]:focus, textarea[aria-invalid=true]:focus {
    outline-color: var(--danger);
    border-color: var(--danger);
}
.field-error .hint, .error-text { color: var(--danger-ink); }
.hint.is-warning { color: var(--warning-ink); }
input.input-xs { width: 4.5em; }

/* A long form with its sections listed on the left. */
.form-with-toc { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 28px; align-items: start; }
.form-toc { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.form-toc a { padding: 7px 12px; border-radius: var(--r-sm); color: var(--text-2); font-size: 14px; text-decoration: none; }
.form-toc a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.form-toc a:first-child { background: var(--module-soft); color: var(--module-ink); font-weight: 600; }
.form-with-toc .form-column { max-width: 860px; }
.form-section h3.sub-h { margin: 22px 0 4px; font-size: 15px; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--text-2); }
.danger-zone form { margin: 0; }

/* Three positions on one line per question: Not asked / Optional / Required. */
.tristate-list { display: flex; flex-direction: column; margin-bottom: 8px; }
.tristate-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tristate-row:last-child { border-bottom: 0; }

/* A radio choice as a small card ("One of them — Table, floor stand or wall"). */
.choice-card { padding: 12px 14px; margin-top: 8px !important; border: 1px solid var(--line-strong); border-radius: var(--r-md); }
.choice-card:has(input:checked) { border-color: var(--module); background: var(--module-soft); }
/* Two or three choices as cards side by side (Active / Suspended, Letter / A4). */
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-cards .choice-card { display: flex; gap: 12px; align-items: flex-start; margin: 0 !important; cursor: pointer; }
.choice-cards .choice-card strong { display: block; font-weight: 600; }
.choice-cards .choice-card small { display: block; color: var(--text-2); font-size: 13px; font-weight: 400; line-height: 1.45; }
.choice-cards input { margin-top: 2px; }
@media (max-width: 700px) { .choice-cards { grid-template-columns: 1fr; } }
.label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.btn-block { width: 100%; }
.form-card .row { margin-bottom: 16px; }
.page-actions-stack { flex-direction: column; align-items: flex-end; gap: 6px; }
.page-actions-stack form { margin: 0; }
.empty.empty-left { align-items: stretch; text-align: left; padding: 28px; }
.empty.empty-left h2 { margin: 0; }
.empty .examples { margin: 4px 0 0; }
.empty .examples .card { display: flex; flex-direction: column; gap: 4px; margin: 0; text-align: left; }
.empty .examples .tags { margin-top: 8px; }
.gauge.expo > span { background: color-mix(in srgb, var(--module) 45%, var(--surface)); }

/* A colour field with its swatch. */
.color-field { display: flex; align-items: center; gap: 10px; max-width: 320px; }
.color-chip { width: 36px; height: 36px; flex: none; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--chip, var(--surface-2)); }
.color-field input { flex: 1; }

/* A checkbox with its sentence, in a soft box: "All day — a 24h office hold". */
.check,
form.form label.check,
form.form label.inline-check,
form.form .checkbox-grid label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
}
form.form label.inline-check { display: inline-flex; align-items: center; }
form.form label.check > input { margin-top: 1px; flex: none; }
/* A form of one or two cards reads at a form's width, not the monitor's. */
.form-column { min-width: 0; max-width: 880px; }
.with-aside > .form-column { max-width: none; }
.check-box {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-head);
}
.check strong { display: block; font-weight: 600; }
.check small { display: block; color: var(--text-3); font-size: var(--fs-help); }

/* Prefix / suffix glued to a field: `$`, `%`, `@`. */
.affix {
    display: flex;
    align-items: stretch;
    width: 100%;
}
.affix > span {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 14px;
}
.affix > span:first-child { border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.affix > span:last-child { border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.affix > input { flex: 1; min-width: 0; }
.affix > span:first-child + input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.affix > input:has(+ span) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* ---- Sections: a long form split into cards ------------------------------ */
.form-section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px 24px 6px;
    margin-bottom: 20px;
}
.form-section > h2,
.form-section > legend {
    margin: 0 0 4px;
    padding: 0;
    font-size: var(--fs-card-title);
    font-weight: 600;
    color: var(--text);
}
.form-section > .section-sub { margin: 0 0 14px; color: var(--text-3); font-size: 13.5px; }
.form-section > h2 + .row,
.form-section > legend + .row { margin-top: 14px; }
fieldset.form-section { min-width: 0; margin: 0 0 20px; }
/* A legend sits on the border by default; inside the card it is a title. */
fieldset.form-section > legend { float: left; width: 100%; margin-bottom: 6px; }
fieldset.form-section > legend + * { clear: both; }

/* Grid variant: fields flow into columns; `.wide` takes the full row. */
form.form.compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px 20px;
    align-items: end;
    max-width: 100%;
}
form.form.compact .row { margin-bottom: 0; min-width: 0; }
form.form.compact .row.wide { grid-column: 1 / -1; }
form.form.compact > button,
form.form.compact .submit { grid-column: 1 / -1; justify-self: start; }
form.form.compact label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* A form that adds a row to the table above it. */
form.form.attached {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: -21px;
}

form.form .submit,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

/* ---- Save bar --------------------------------------------------------------
   Sticky at the bottom of a long form: delete on the left (danger), then
   "Unsaved changes", Cancel and Save on the right. `ui.js` toggles
   `.is-dirty` when a field changes.
   ---------------------------------------------------------------------- */
.savebar {
    position: sticky;
    bottom: 16px;
    z-index: 20;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 4px 0 20px;
    padding: 12px 16px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.savebar .spacer { flex: 1; }
.savebar .unsaved {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--text-2);
    font-size: 14px;
}
.savebar .unsaved::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
}
.savebar.is-dirty .unsaved { display: inline-flex; }

/* ---- Three-position choice: Not asked / Optional / Required --------------- */
.tristate { display: inline-flex; }
.tristate.segmented > label { min-height: 32px; font-size: 13.5px; }

/* Day pickers: the event's own days as a row of checkable pills. */
.day-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.day-grid label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}
.day-grid label:has(input:checked) { border-color: var(--module); background: var(--module-soft); color: var(--module-ink); }
.day-grid input { margin: 0; }

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px 16px;
    padding: 4px 0 8px;
}

/* An inline editor that opens inside a table row. */
tr.has-editor > td { border-bottom: none; }
tr.editor-row > td { padding-top: 0; padding-left: 28px; }
.row-editor { margin: 0; }
.row-editor > summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    color: var(--module-ink);
    font-size: 13px;
    font-weight: 600;
    list-style: none;
    cursor: pointer;
}
.row-editor > summary::-webkit-details-marker { display: none; }
.row-editor > summary::before { content: "▸"; font-size: 11px; }
.row-editor[open] > summary::before { content: "▾"; }
.row-editor form.form {
    margin: 10px 0 0;
    padding: 16px;
    background: var(--surface-head);
}

/* ==========================================================================
   Empty state, dialogs, misc
   ========================================================================== */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 24px;
    margin: 0 0 20px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--r-lg);
    background: var(--surface-head);
    color: var(--text-2);
    text-align: center;
}
.empty p { margin: 0; max-width: 52ch; }
.empty strong { color: var(--text); }

dialog.confirm,
dialog.dialog {
    min-width: 340px;
    max-width: min(520px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-3);
}
dialog::backdrop { background: color-mix(in srgb, var(--panel) 40%, transparent); }

.pre-wrap {
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-head);
    font-size: 13px;
    line-height: 1.5;
}

ul.tight { margin: 0; padding-left: 16px; }
ul.tight li { margin: 0; }

/* A secret shown once (an app token, a pairing code). */
.token-reveal {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    font-family: var(--mono);
    font-size: 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
}
.pairing-reveal {
    font-family: var(--mono);
    font-size: 20px;
    letter-spacing: 2px;
}

/* An uploaded logo, shown as it will print: on white, framed, never cropped. */
.logo-preview {
    display: block;
    max-height: 80px;
    max-width: 260px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    object-fit: contain;
}

/* The older inline-error box some forms still print. */
.alert { margin: 0 0 20px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-md); }
.alert ul { margin: 0; padding-left: 18px; }
.alert-error {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--surface));
    background: var(--danger-soft);
    color: var(--danger-ink);
}

/* Avatar: initials in a circle. */
.avatar {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
}

/* ---- Responsive helpers ----------------------------------------------- */
.sm-only, .sm-block { display: none; }
.card-text { margin: 0 0 16px; color: var(--text-2); line-height: 1.6; }
.gauge-wide { margin: 0 0 20px; }
.card-body > .actions { margin-top: 18px; }

/* ==========================================================================
   Phones
   ========================================================================== */

@media (max-width: 900px) {
    .sm-only { display: inline; }
    .sm-block { display: flex; width: 100%; margin: -8px 0 20px; }
    .hide-sm { display: none !important; }
    /* A tile that needs attention keeps its soft ground on a phone, where the
       tile row is all the overview there is. */
    .kpi.kpi-attention { border-color: color-mix(in srgb, var(--warning) 45%, var(--line)); background: var(--warning-soft); }
    .page-head.hide-in-event-sm { display: none; }

    /* A list of rows as cards: the first cell is the title, the next cells run
       on one line under it ("Level 3 · Meeting · 9 functions"), and the
       actions sit on the right. For a table whose columns are short facts. */
    .main table.stack-sm,
    .main table.stack-sm tbody { display: block; overflow: visible; border: 0; background: none; }
    table.stack-sm thead { display: none; }
    table.stack-sm tr {
        position: relative;
        display: block;
        padding: 14px 118px 14px 16px;
        border-bottom: 1px solid var(--line);
        background: var(--surface);
    }
    table.stack-sm tbody tr:last-child { border-bottom: 0; }
    .main table.stack-sm td,
    .main table.stack-sm td:first-child,
    .main table.stack-sm td:last-child { display: inline; padding: 0; border: 0; text-align: left; color: var(--text-3); font-size: 14px; }
    .main table.stack-sm td:first-child { display: block; margin-bottom: 2px; color: var(--text); font-size: 16px; }
    table.stack-sm td:not(:first-child):not(.actions):not(.hide-sm) ~ td:not(.actions):not(.hide-sm)::before { content: " · "; }
    table.stack-sm td .tag { padding: 0; border: 0; background: none; font-size: inherit; color: inherit; }
    /* A cell of chips or a two-line value: on its own line, no "·" before it. */
    .main table.stack-sm td.stack-line { display: block; margin-top: 8px; }
    table.stack-sm td.stack-line::before,
    table.stack-sm td.stack-line ~ td::before { content: none !important; }
    table.stack-sm td.stack-line .cell-sub { display: inline; margin-left: 4px; }
    table.stack-sm td.actions {
        position: absolute;
        top: 50%;
        right: 8px;
        transform: translateY(-50%);
    }
    table.stack-sm tbody tr:hover > td { background: none; }
    table.stack-sm tr:has(td.col-go) { padding-right: 44px; }
    table.stack-sm td small { display: inline; margin: 0 0 0 4px; }
    table.stack-sm tr.group { padding: 8px 16px; background: var(--surface-2); }
    table.stack-sm tr.group > th { display: inline; padding: 0; background: none; }

    .main { padding: 20px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }

    .page-head, header.page { align-items: flex-start; flex-direction: column; }
    .page-head h1, header.page h1, .main > h1 { font-size: 24px; }

    /* 44px targets on touch. */
    .btn { min-height: 44px; }
    .btn-sm { min-height: 36px; }
    input[type=text], input[type=email], input[type=password], input[type=search],
    input[type=url], input[type=tel], input[type=number], input[type=date],
    input[type=time], input[type=datetime-local], select { min-height: 44px; font-size: 16px; }

    .grid-2, .grid-3, .grid-4, .with-aside, .form-with-toc { grid-template-columns: minmax(0, 1fr); }
    .form-toc { display: none; }
    .tristate-row { flex-direction: column; align-items: flex-start; gap: 6px; }
    .with-aside > aside { position: static; }
    form.form .row.cols, .form-section .row.cols, form.form .row.cols-3, .form-section .row.cols-3, .fields { grid-template-columns: minmax(0, 1fr); }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .kpi { padding: 14px 16px; }
    .kpi-value { font-size: 24px; }
    table.table:not(:has(thead)):has(> tbody > tr > th + td) > tbody { grid-template-columns: minmax(0, 1fr); }

    .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .kv dt { margin-top: 10px; font-size: 13px; }

    .card { padding: 16px; }
    .card-flush > .card-h { padding: 14px 16px; }
    table.table td:first-child, table.table th:first-child { padding-left: 16px; }
    table.table td:last-child, table.table th:last-child { padding-right: 16px; }
    /* A wide table scrolls inside its own frame, never the page: a page that
       scrolls sideways on a phone also drags the fixed dock off screen. */
    /* `position: relative` makes the table the containing block of what it holds:
       an absolutely placed child (a screen-reader label, a `⋯` menu) otherwise
       escapes the scroll and widens the page anyway. */
    .main table { position: relative; display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .main td table, .table-wrap > table, .schedule-scroll > table { display: table; }
    .main pre, .main .pre-wrap { max-width: 100%; overflow-x: auto; }
    .main img { max-width: 100%; height: auto; }

    /* Above the dock, which floats over the bottom of the page. */
    .savebar { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
    .savebar .unsaved { flex-basis: 100%; order: -1; }
    .segmented { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
    .search { flex-basis: 100%; }
}

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