/* ==========================================================================
   Celita v2 — application shell
   Fixed topbar, fixed left rail, scrolling content. Every value here comes
   from tokens.css; no raw colours, no drop shadows, no gradients.
   ========================================================================== */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--t-body);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .page__title, .sheet__title { letter-spacing: var(--tracking-tight); }

a { color: var(--accent); }

/* The browser's own [hidden] rule is namespaced to HTML, so it passes over SVG
   and an inline icon carrying the attribute still paints. The app is full of
   inline icons that get toggled; this makes the attribute mean what it says. */
svg[hidden] { display: none; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- topbar ------------------------------------------------------ */

.app-bar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--bar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: 0 var(--s-4);
    z-index: 1030;
}

.app-bar__brand {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    text-decoration: none;
    color: var(--text);
    font-size: var(--t-body);
    font-weight: var(--w-semi);
}

/* Dark ink on transparent — reads as-is on the light bar, no filter. */
.app-bar__logo {
    height: 16px;
    width: auto;
    display: block;
}

.app-bar__title {
    font-size: var(--t-body);
    font-weight: var(--w-semi);
}

/* 320px, held to the right beside the avatar — not centred, not full-width. The
   auto margin is what puts it there: the brand and the toggle stay packed left. */
.app-bar__search {
    flex: none;
    width: 320px;
    margin-left: auto;
    position: relative;
}

.app-bar__search input {
    width: 100%;
    height: var(--control-h);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text);
    padding: 0 var(--s-3) 0 var(--s-6);
    font-family: inherit;
    font-size: var(--t-ui);
}

.app-bar__search input::placeholder { color: var(--text-dim); }

.app-bar__search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.app-bar__search svg {
    position: absolute;
    left: var(--s-2);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

/* Only the search claims the free space — a second auto margin here would split it
   with that one and leave the search stranded mid-bar instead of beside the avatar. */
.app-bar__spacer { margin-left: auto; }

.app-bar__right {
    display: flex;
    align-items: center;
    gap: var(--s-1);
}

/* ---------- avatar ------------------------------------------------------ */

.avatar {
    position: relative;
    overflow: hidden;
    width: var(--avatar);
    height: var(--avatar);
    border-radius: 50%;
    background: var(--neutral);
    color: var(--text-mid);
    display: inline-grid;
    place-items: center;
    font-family: inherit;
    font-weight: var(--w-semi);
    font-size: var(--t-label);
    border: 0;
    padding: 0;
    cursor: pointer;
    flex: none;
}

.avatar--lg { width: var(--s-7); height: var(--s-7); font-size: var(--t-lg); }

/* A face big enough to know somebody by: portrait, the shape a photo of a person is, with the
   record screens' own radius and edge rather than a circle. Twice the large avatar wide, and a
   quarter again as tall. The img covers it, so it fills without stretching. */
.avatar--portrait {
    width: calc(var(--s-7) * 2);
    height: calc(var(--s-7) * 2.5);
    border-radius: var(--r);
    border: 1px solid var(--border);
    font-size: var(--t-title);
}

/* Initials sit underneath; the photo covers them once it loads. If the file is
   missing — the normal case for legacy imports — the img removes itself. */
.avatar__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---------- user menu --------------------------------------------------- */

.user-menu { position: relative; }

/*
   The circle's own edge, on both the button in the bar and the large one in the panel.

   With initials the --neutral ground draws the circle by itself; a photograph is whatever
   colour happens to be at its rim, so a pale one simply dissolved into the bar behind it.
   The ring gives it a boundary that does not depend on the picture.

   --border-control rather than --border, and not only for the photo's sake: the small one
   is a button, and until now it had no boundary at all - a control identified by a grey
   disc, which is under the 3:1 WCAG 1.4.11 asks of one. The parent clips the photo, so the
   ring sits outside it and nothing is cropped by adding it.
*/
.user-menu .avatar { border: 1px solid var(--border-control); }

.user-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + var(--s-2));
    width: 300px;

    /* The cool face and the heavier edge the filters popover and the KPI tiles take, for
       the same reason: this is an object standing over the page, and white on white left
       it held apart by a --border edge alone - 1.2:1, which reads as no edge at all. */
    background: var(--surface-cool);
    color: var(--text);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    padding: var(--s-4);
    display: none;
}

.user-menu__panel[data-open="true"] { display: block; }

.user-menu__id { display: flex; gap: var(--s-3); align-items: center; }

.user-menu__name { font-weight: var(--w-semi); }

.user-menu__mail { color: var(--text-mid); font-size: var(--t-sm); word-break: break-all; }

.user-menu__roles { margin-top: var(--s-3); display: flex; flex-wrap: wrap; gap: var(--s-1); }

.user-menu__actions {
    margin-top: var(--s-3);
    padding-top: var(--s-3);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}

/*
   A menu entry, built like a rail entry rather than like a button: 32px, a 16px glyph at
   1.5px, 13px/500 in --text-mid, and a radius only on hover. Three of these stack inside
   the panel where three labelled buttons could not sit across it.

   The anchor, the plain button and the sign-out form's submit all wear it, so the three
   read as one list however differently they are built underneath.
*/
.user-menu__item {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--s-2);
    border: 0;
    border-radius: var(--r);
    background: none;
    font: inherit;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text-mid);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

/* Lifts to white rather than dimming to --bg, the way everything standing on the cool
   face does - here the row is the foreground and the panel behind it is already tinted. */
.user-menu__item:hover { background: var(--surface); color: var(--text); }

.user-menu__item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* A plain glyph, no tile and no circle behind it. Not from the --nav-* palette - that one
   tints the rail's icons and nothing else. */
.user-menu__item svg { flex: none; color: var(--text-dim); }
.user-menu__item:hover svg { color: var(--text-mid); }

/* ---------- org chart ---------------------------------------------------
   An indented tree drawn from a nested <ul>: every line is a 1px border on a
   list item, so there is no SVG to keep in step with the markup and the chart
   still reads as a list of people with styles off.

   It runs downwards rather than across. Drawn the classic way, one manager with
   nine reports came to 2,500px of sideways scrolling and four visible faces at
   a time; indented, the width is fixed and the page grows with the depth of the
   reporting line, which is the small number. */

/* The tree pans inside its own pane. Narrow cards keep it inside the viewport
   for a normal team, but a wide row of siblings is a diagram rather than a
   table, and squeezing it would make it unreadable rather than tidy. */
.org-wrap {
    overflow: auto;
    padding: var(--s-4);
}

.org-loading,
.org-empty {
    padding: var(--s-7) var(--s-4);
    text-align: center;
    color: var(--text-mid);
}

/* Sized to the tree, but never narrower than the pane. A centred flex row that
   outgrows its container overflows *both* ways, and the half hanging off the
   left cannot be scrolled to - it is simply gone. */
.org-tree {
    width: max-content;
    min-width: 100%;
}

.org-tree ul {
    display: flex;
    justify-content: center;
    list-style: none;
    margin: 0;
    /* Room for the connector that drops into this row. */
    padding: var(--s-5) 0 0;
    position: relative;
}

/* The outermost row has nothing above it to connect to. */
.org-tree > ul { padding-top: 0; }

.org-tree li {
    position: relative;
    padding: var(--s-5) var(--s-2) 0;
    text-align: center;
}

/* The two halves of the line above a row of siblings, and the stub dropping
   from it into each node. */
.org-tree li::before,
.org-tree li::after {
    content: "";
    position: absolute;
    top: 0;
    right: 50%;
    width: 50%;
    height: var(--s-5);
    border-top: 1px solid var(--border-control);
}

.org-tree li::after {
    right: auto;
    left: 50%;
    border-left: 1px solid var(--border-control);
}

/* An only child needs no crossbar - just the drop, which its parent draws. */
.org-tree li:only-child::before { display: none; }
.org-tree li:only-child::after { border-top: 0; }

/* The ends of the row stop at the outermost node rather than running past it. */
.org-tree li:first-child::before { border: 0; }
.org-tree li:last-child::after { border-top: 0; }
.org-tree li:last-child::before { border-right: 1px solid var(--border-control); }

/* The line down from a manager into their reports' crossbar. */
.org-tree li > ul::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    height: var(--s-5);
    border-left: 1px solid var(--border-control);
}

/* The root of each tree has no line coming into it. */
.org-tree > ul > li::before,
.org-tree > ul > li::after { display: none; }

/* A portrait card: picture, then name, role, and the two facts worth carrying.
   Narrow on purpose - read across, a node's width is multiplied by every sibling
   in the row, and a wide one turns a handful of reports into a wall. */
.org-node {
    /* inline-flex, not flex: the parent centres it with text-align, and a
       block-level card would sit at the left of a list item as wide as the whole
       row of children below it - which puts a manager nowhere near the line
       drawn down to their reports. */
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 150px;
    padding: var(--s-2);
    /* The heavier edge, not the divider one: a node is an object on the panel
       rather than a rule drawn across it, and at --border it dissolved into the
       white behind it. */
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    background: var(--surface-cool);
    text-decoration: none;
    color: var(--text);
}

/* Hover lifts the card to white rather than dimming it - the opposite way round
   from a table row, because here the card is the foreground and the panel behind
   it is the plain surface. */
.org-node:hover { background: var(--surface); }

/* The portrait is the app's own avatar, enlarged: round, initials underneath,
   photo over the top once it loads. Reusing it rather than building a second
   one means a face here and a face in a grid are the same object.

   The ring is what makes it read as a portrait rather than a letter in a table
   cell - two pixels, in the control edge, which is the only tone in the palette
   with enough weight to hold a circle against the card's tint. */
.avatar--org {
    width: 64px;
    height: 64px;
    margin-bottom: var(--s-1);
    border: 2px solid var(--border-control);
    font-size: var(--t-lg);
    /* The whole card is the link; the avatar is not separately clickable. */
    cursor: inherit;
}

/* A card this narrow cannot hold a long name on one line, and truncating it
   would leave several of these people unnameable - so they wrap. */
.org-node__name {
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    line-height: 1.25;
}

.org-node__role { font-size: var(--t-sm); color: var(--text-mid); line-height: 1.25; }

/* --text-mid, not --text-dim: these are facts to be read, and the dim tone is
   reserved for placeholders and decorative icons because it does not clear
   4.5:1. See the note in tokens.css. */
.org-node__fact { font-size: var(--t-sm); color: var(--text-mid); line-height: 1.3; }

.org-node__fact--num { font-variant-numeric: tabular-nums; }

/* The one line that must not wrap: an address has no natural break and would
   push every card in the row taller. */
.org-node__mail {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* How many people sit under this one. Quiet: it is a footnote on the node, and
   the branch below already shows the same thing. The 6px radius, not a pill -
   pill radius belongs to status badges and this is a count. */
/* How many people this person manages. Rendered only when there are any - a
   card reading "Manages 0" would be noise on every leaf of the tree. Ruled off
   from the facts above it, because it describes the branch below rather than
   the person. */
.org-node__manages {
    width: 100%;
    margin-top: var(--s-1);
    padding-top: var(--s-1);
    border-top: 1px solid var(--border);
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    color: var(--text-mid);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* Search dims rather than filters: a chart with the middle removed would draw
   reporting lines that do not exist. */
.org-node--dim { opacity: .3; }

/* ---------- grid row menu -----------------------------------------------
   Right-click on a row. Above the rail and the topbar, under the toasts. A
   1px border rather than a shadow, like every other raised edge in the app —
   the four module buttons are the only exception to that. */

.ctx-menu {
    position: fixed;
    z-index: 1090;
    min-width: 180px;
    padding: var(--s-1);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
}

.ctx-menu[hidden] { display: none; }

.ctx-menu__item {
    display: flex;
    align-items: center;
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--s-3);
    border: 0;
    border-radius: var(--r);
    background: transparent;
    font: inherit;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.ctx-menu__item[hidden] { display: none; }

.ctx-menu__item:hover { background: var(--bg); }

/* Off-screen holder for the execCommand copy fallback. */
.ctx-menu__scratch {
    position: fixed;
    top: 0;
    left: -9999px;
    opacity: 0;
}

/* ---------- left rail ---------------------------------------------------
   No right border: the content surface provides the edge. Nav items carry no
   border, background or radius of their own — hover and active do that work. */

.rail {
    position: fixed;
    top: var(--bar-h);
    bottom: 0;
    left: 0;
    width: var(--rail-w);
    background: var(--bg);
    transition: width .15s ease;
    z-index: 1020;

    /* Context list above, module buttons pinned below. */
    display: flex;
    flex-direction: column;
}

/* 8px inline, not 12px: this padding is the whole gap between a nav item and the
   resize handle on the rail's edge, and at 12px the two read as disconnected. */
.rail__context {
    flex: 1;
    min-height: 0;
    overflow-y: auto;

    /* The top inset used to come from the section heading's margin; the headings
       are gone, so the list carries it. */
    padding: var(--s-2) var(--s-2) var(--s-3);
}

/* Only the chosen module's list is on show. */
.rail__group { display: none; }
.rail__group[data-open="true"] { display: block; }

/* margin-top:auto, not just the context list's flex:1 — collapsed, the context
   list is display:none and the modules would otherwise jump to the top. */
.rail__modules {
    flex: none;
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: var(--s-2);
}

/* Nav item and module button share their metrics; their surfaces differ — the
   context list stays flat, the modules are raised. */
.rail__link,
.rail__module {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--s-2);
    font-family: inherit;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text-mid);
    text-decoration: none;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

/* A context entry is not a card: no border, background or radius of its own. */
.rail__link {
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 0;
    background: transparent;
}

/* One hue per destination — set on the item so the glyph can draw from it.
   The tint lands on the glyph alone: no tile, no circle, no coloured label.

   Keyed on the attribute rather than on .rail__link, so the same hue reaches the
   tab strip: a tab carries the data-nav of the section it belongs to, and its
   glyph is the same glyph in the same colour as the rail entry beside it. Only
   an element that actually reads --nav-accent shows anything, so this stays
   inert everywhere else. */
.rail__link,
.rail__module { --nav-accent: var(--text-mid); }

[data-nav="individuals"] { --nav-accent: var(--nav-individuals); }
[data-nav="companies"]   { --nav-accent: var(--nav-companies); }
[data-nav="hr"]          { --nav-accent: var(--nav-hr); }
[data-nav="home"]        { --nav-accent: var(--nav-home); }
[data-nav="tickets"]     { --nav-accent: var(--nav-tickets); }
[data-nav="recurring"]   { --nav-accent: var(--nav-recurring); }
[data-nav="assets"]      { --nav-accent: var(--nav-assets); }
[data-nav="reminders"]   { --nav-accent: var(--nav-reminders); }
[data-nav="processes"]   { --nav-accent: var(--nav-processes); }
[data-nav="users"]       { --nav-accent: var(--nav-users); }
[data-nav="activity"]    { --nav-accent: var(--nav-activity); }
[data-nav="lookups"]     { --nav-accent: var(--nav-lookups); }
[data-nav="logs"]        { --nav-accent: var(--nav-logs); }
[data-nav="recyclebin"]  { --nav-accent: var(--nav-logs); }
[data-nav="search"]      { --nav-accent: var(--nav-search); }
[data-nav="settings"]    { --nav-accent: var(--nav-settings); }

.rail__module[data-module="client"] { --nav-accent: var(--nav-individuals); }
.rail__module[data-module="hr"]     { --nav-accent: var(--nav-hr); }
.rail__module[data-module="home"]   { --nav-accent: var(--nav-home); }
.rail__module[data-module="admin"]  { --nav-accent: var(--nav-users); }

.rail__link svg,
.rail__module svg {
    flex: none;
    width: 16px;
    height: 16px;
    color: var(--nav-accent);
}

.rail__link:hover {
    background: var(--accent-bg);
    border-radius: var(--r);
    color: var(--text);
}

/* The entire active treatment for a context entry: accent text, accent-bg, 2px bar. */
.rail__link[aria-current="page"] {
    background: var(--accent-bg);
    border-left-color: var(--accent);
    border-radius: var(--r);
    color: var(--accent);
}

/* ---------- module buttons ----------------------------------------------
   The one raised surface in the app, and the one place a gradient and a drop
   shadow are allowed: a light top-to-bottom fall, a 1px edge, a hairline
   highlight along the top and a soft drop beneath. Requested deliberately;
   the exception is recorded in CLAUDE.md and goes no further than these four. */

.rail__module {
    margin-top: var(--s-1);
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: linear-gradient(180deg, var(--raise-top), var(--raise-bottom));
    box-shadow: var(--raise-shadow), var(--raise-highlight);
    transition: background .12s, box-shadow .12s, transform .06s;
}

.rail__module:first-child { margin-top: 0; }

.rail__module:hover {
    background: linear-gradient(180deg, var(--surface), var(--raise-top));
    color: var(--text);
}

/* Presses in rather than lighting up — the drop is replaced by an inset. */
.rail__module:active {
    box-shadow: var(--press-shadow);
    transform: translateY(1px);
}

/* Selected: held down. Accent is permitted here — it is the active nav indicator. */
.rail__module[aria-pressed="true"] {
    background: linear-gradient(180deg, var(--accent-bg-deep), var(--accent-bg));
    border-color: var(--accent-border);
    box-shadow: var(--press-shadow);
    color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
    .rail__module { transition: none; }
    .rail__module:active { transform: none; }
}

/* The glyph keeps its own hue when active — the accent-bg, the left bar and the
   label already say which row is current, and recolouring the icon would lose
   the one thing that makes the rail scannable by colour. */

/* Administration used to take an extra 8px here to set it apart from the working
   modules. Against items that otherwise stack flush it read as a misalignment
   rather than as grouping, so the modules are now evenly spaced. */

/* An entity the rewrite has not reached yet: visible so the shape of the module
   is honest, but plainly not usable. */
.rail__link--soon {
    color: var(--text-dim);
    cursor: not-allowed;
}

/* Keeps its hue so the rail still reads as a colour-coded set, but dimmed enough
   that an entity the rewrite has not reached yet cannot pass for a live one. */
.rail__link--soon svg { opacity: .45; }

.rail__link--soon:hover { background: transparent; color: var(--text-dim); }

/* ---------- rail resizer ------------------------------------------------
   Drags --rail-w, which both .rail (width) and .app-content (margin-left) read,
   so one gesture resizes both panels. */

.rail__resizer {
    position: absolute;
    top: 0;
    right: -2px;
    bottom: 0;
    width: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: col-resize;
    touch-action: none;
    z-index: 2;
}

/* The resting cue — a grip mark, the way a split pane advertises itself. A
   full-height rule would do the job but the rail deliberately draws no right
   border, so the affordance is this instead: present, small, and off the accent. */
.rail__resizer::before {
    content: "";
    width: 3px;
    height: var(--s-5);
    border-radius: var(--r);   /* clamps to a rounded bar at this width */

    /* --text-mid, not --text-dim: this mark is the only thing identifying the
       control, and WCAG 1.4.11 wants 3:1 for that. --text-dim manages 2.5:1 on
       --bg; --text-mid clears it at 7.4:1 and is the more findable cue besides. */
    background: var(--text-mid);
    transition: height .12s;
}

/* Grows rather than darkens — the colour is already carrying its weight. */
.rail__resizer:hover::before,
.rail__resizer:focus-visible::before,
body[data-resizing="true"] .rail__resizer::before {
    height: var(--s-7);
}

/* Only while actually dragging: the full edge, so the boundary being moved is
   readable against the content. Transient, so it is not the "right border". */
body[data-resizing="true"] .rail__resizer { background: var(--text-dim); }

.rail__resizer:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }

/* While dragging, the width must track the pointer exactly — the ease would lag. */
body[data-resizing="true"] { cursor: col-resize; user-select: none; }
body[data-resizing="true"] .rail,
body[data-resizing="true"] .app-content { transition: none; }

body[data-rail="collapsed"] .rail__resizer { display: none; }

body[data-rail="collapsed"] .rail { width: var(--rail-w-collapsed); }
body[data-rail="collapsed"] .rail__label { display: none; }

/* Collapsed, the pane is module icons only — as the Outlook pane does. */
body[data-rail="collapsed"] .rail__context { display: none; }
body[data-rail="collapsed"] .rail__modules { border-top: 0; }

body[data-rail="collapsed"] .rail__module {
    justify-content: center;
    padding: 0;
}

/* ---------- content ----------------------------------------------------- */

.app-content {
    margin-left: var(--rail-w);
    padding-top: var(--bar-h);
    min-height: 100%;
    transition: margin-left .15s ease;
}

body[data-rail="collapsed"] .app-content { margin-left: var(--rail-w-collapsed); }

/* Flush to the shell. The page's surface runs edge to edge — it meets the rail on
   the left and the tab strip above with no gutter at all, so the active tab reads
   as joined to the content it belongs to. */
.page { padding: 0; }

/* The single surface a page is made of. Border and radius come off the edges that
   now touch the shell; one bottom rule marks where the surface ends. */
.page-root > .card,
.page-root > .lookup-layout > .card {
    border-radius: 0;
    border-width: 0 0 1px;
}

/* With the strip on show, the surface closes into a box beneath it: the tabs draw
   the top edge, the surface supplies the other three, and the two read as one
   tabbed container. It matches --tab-border so the box and the tab row are the
   same line. On a lone tab there is no strip, so the surface stays flush. */
.tabstrip:not([hidden]) + .tabpanels .page-root > .card,
.tabstrip:not([hidden]) + .tabpanels .page-root > .lookup-layout > .card {
    border-color: var(--tab-border);
}

.tabstrip:not([hidden]) + .tabpanels .page-root > .card {
    border-left-width: 1px;
    border-right-width: 1px;
}

/* Two panes share one divider, so only the outer edges close the box. */
.tabstrip:not([hidden]) + .tabpanels .page-root > .lookup-layout > .card:first-child {
    border-left-width: 1px;
}

.tabstrip:not([hidden]) + .tabpanels .page-root > .lookup-layout > .card:last-child {
    border-right-width: 1px;
}

/* Pages that are prose or tiles rather than one surface keep an inset. */
.page-root--inset { display: block; padding: var(--s-4); }

/* ---------- workspace tabs ---------------------------------------------- */

.tabstrip {
    position: sticky;
    top: var(--bar-h);
    display: flex;
    align-items: stretch;

    /* Flush: tabs share their edges rather than floating apart. */
    gap: 0;
    padding: var(--s-2) 0 0;
    background: var(--bg);

    /* No border-bottom here. The rule is drawn by the tabs' own bottom edges plus
       the filler below, because this box is a scroll container (overflow-x) and so
       clips at its padding box — a tab hanging 1px past that to paint over a
       border on the strip would simply have that 1px cut off. */
    z-index: 1010;

    /* Tabs shrink before the strip scrolls, so it only scrolls once they are
       down to their minimum — the same bargain the grids make. */
    overflow-x: auto;
    scrollbar-width: none;
}

.tabstrip::-webkit-scrollbar { display: none; }
.tabstrip[data-loading="true"] { cursor: progress; }

/* Carries the rule on past the last tab to the edge of the strip. A flex item, so
   it lives inside the scroll container and is not clipped; basis 0 so it asks for
   no width of its own and simply takes whatever the tabs leave. */
.tabstrip::after {
    content: "";
    flex: 1 0 0;
    border-bottom: 1px solid var(--tab-border);
}

/* Needed explicitly: display:flex above would otherwise beat the hidden attribute. */
.tabstrip[hidden] { display: none; }

.tab {
    display: inline-flex;
    align-items: center;

    /* For z-index below — the selected tab has to draw over its neighbours. */
    position: relative;

    /* Tight, because the root tab's trail sits inside this gap too. */
    gap: var(--s-1);
    flex: 0 1 auto;
    min-width: 88px;
    max-width: 220px;
    height: var(--control-h);

    padding: 0 var(--s-2) 0 var(--s-3);

    /* Every tab carries its own body and edge, so the strip reads as a row of
       tabs rather than as loose labels when none of them is the one in front. */
    border: 1px solid var(--tab-border);

    /* The same 2px rail the selected tab lights in accent — one anatomy for every
       tab, muted here and lit there, rather than a bar that only exists when
       selected. Being present on all of them, selecting one shifts nothing. */
    border-top: 2px solid var(--tab-border);
    border-radius: var(--r) var(--r) 0 0;
    background: var(--tab-idle);
    font-family: inherit;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text-mid);
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s;
}

/* Neighbours share one edge instead of stacking two 1px borders side by side. */
.tab + .tab { margin-left: -1px; }

/* Lifts towards the surface without arriving at it — that is the selected tab's. */
.tab:hover { background: var(--bg); color: var(--text); }

/* The active tab is the nav indicator for the workspace, so it takes the accent:
   a 2px bar on top, the content surface behind it, and its bottom border painted
   out so it runs straight into the panel below. */
.tab[aria-selected="true"] {
    background: var(--surface);

    /* Over its neighbours, so the shared edges do not clip its accent border and
       the break it paints in the rule below runs the tab's full width. */
    z-index: 1;

    /* The edge takes the accent's light variant rather than staying neutral, so
       the whole tab belongs to the rail lit above it. */
    border-color: var(--accent-border);
    border-top-color: var(--accent);

    /* Its own stretch of the rule turned white, so this tab alone opens into the
       panel below and the line breaks exactly across its width. */
    border-bottom-color: var(--surface);
    color: var(--text);
    font-weight: var(--w-semi);
}

.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* The section's glyph, cloned from the rail entry that owns the tab, in that
   section's own hue - so a tab is recognisable before its label is read, and
   matches the rail entry beside it. The tint is on the glyph alone, as on the
   rail: the label stays --text-mid and the tab keeps its neutral body.

   Full colour whether or not the tab is selected, for the same reason the rail
   colours every entry: the hue names the destination, it does not report state.
   Falls back to the dim tone for any section with no data-nav to draw from.
   14px rather than the rail's 16px - the strip is shorter than a nav row. */
.tab__icon {
    display: inline-flex;
    align-items: center;
    flex: none;
    color: var(--nav-accent, var(--text-dim));
}

.tab__icon svg { width: 14px; height: 14px; }

.tab__label { overflow: hidden; text-overflow: ellipsis; }

/* The grid's tab wears its trail — "Client › Individuals" — so the strip says
   where you are without a second bar above it. The module part stays light so the
   grid's own name is what the eye lands on, and it is plain text: the tab is the
   button, and a button cannot be nested inside one. */
.tab--root { max-width: 320px; padding-right: var(--s-3); }

.tab__crumb {
    flex: none;
    color: var(--text-mid);
    font-weight: var(--w-normal);
}

.tab__sep {
    display: inline-flex;
    align-items: center;
    flex: none;
    color: var(--text-dim);
}

.tab__close {
    display: inline-grid;
    place-items: center;
    flex: none;
    margin-left: var(--s-1);
    width: var(--s-4);
    height: var(--s-4);
    border-radius: var(--r);
    color: var(--text-dim);
}

.tab__close:hover { background: var(--border); color: var(--text); }

.tabpanel[hidden] { display: none; }

/* ---------- page head --------------------------------------------------- */

.page__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s-4);
    margin-bottom: var(--s-5);
    flex-wrap: wrap;
}

.page__title { font-size: var(--t-title); font-weight: var(--w-semi); margin: 0; }

.page__sub { color: var(--text-mid); font-size: var(--t-ui); margin: var(--s-1) 0 0; }

/* ---------- card -------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
}

.card__head {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border);
    font-weight: var(--w-semi);
}

.card__body { padding: var(--s-4); }

/* Saves three inline margin overrides across the views. */
.card__body > :first-child { margin-top: 0; }
.card__body > :last-child { margin-bottom: 0; }

/* A button following prose needs the gap the prose does not carry. */
.card__body > .page__sub + .btn { margin-top: var(--s-4); }

/* ---------- stats ------------------------------------------------------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--s-4);
    margin-bottom: var(--s-4);
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: var(--s-4);
}

.stat__label {
    color: var(--text-mid);
    font-size: var(--t-label);
    font-weight: var(--w-medium);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat__value {
    font-size: var(--t-xl);
    font-weight: var(--w-semi);
    font-variant-numeric: tabular-nums;
    margin-top: var(--s-2);
}

/* A stat whose value is text, not a figure. */
.stat__value--text {
    font-size: var(--t-body);
    font-weight: var(--w-normal);
    font-variant-numeric: normal;
    word-break: break-word;
}

/* ---------- toolbar ----------------------------------------------------- */

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.toolbar__spacer { flex: 1 1 auto; }


.field-search {
    position: relative;
    min-width: 260px;
}

.field-search--fill { min-width: 0; flex: 1; }

/* A search sharing its row with more than a grid's toolbar carries — the documents
   section puts a title, a count, this, a select, the Filters button and the primary
   action on one 44px line, and all of it has to hold at 1280px. */
.field-search--compact { min-width: 180px; }

.field-search input {
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--s-3) 0 var(--s-6);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    font-family: inherit;
    font-size: var(--t-ui);
    color: var(--text);
    background: var(--surface);
}

.field-search input::placeholder { color: var(--text-dim); }

.field-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.field-search svg {
    position: absolute;
    left: var(--s-2);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

/* ---------- buttons ----------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    height: var(--control-h);
    padding: 0 var(--s-3);
    border-radius: var(--r);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    background: transparent;
    color: var(--text);
}

/* Needed explicitly: the display:flex above otherwise beats the browser's own
   [hidden] rule, which is why a dialog's Remove button showed on the Add form. Same
   reason .tabstrip[hidden] exists. */
.btn[hidden] { display: none; }

.btn:disabled { color: var(--text-dim); cursor: not-allowed; }

.btn--primary { background: var(--accent); color: var(--surface); }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--primary:disabled { background: var(--border); color: var(--text-dim); }

.btn--subtle { border-color: var(--border-control); background: var(--surface); color: var(--text); }
.btn--subtle:hover:not(:disabled) { background: var(--bg); }

.btn--ghost { color: var(--text-mid); }
.btn--ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn--danger { border-color: var(--border-control); background: var(--surface); color: var(--danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger-bg); }

.btn--sm { height: var(--s-5); padding: 0 var(--s-2); font-size: var(--t-sm); }

/* A select wearing button chrome — the arrow needs the padding back. */
.btn--select { padding-inline: var(--s-2); }

/* A button carrying only an icon is a square, like .icon-btn. */
.btn--icon { width: var(--control-h); padding: 0; }

/* Icon-only: a 32px square. */
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: var(--control-h);
    height: var(--control-h);
    padding: 0;
    border: 0;
    border-radius: var(--r);
    background: transparent;
    color: var(--text-mid);
    cursor: pointer;
}

.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ---------- grid -------------------------------------------------------- */

/* Grids never scroll sideways. Each grid fixes a width for every column except
   one, and that one absorbs the leftover space — and gets squeezed first. */
.grid-wrap { overflow-x: hidden; }

table.grid {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--t-ui);
}

/* Column widths live here rather than as style="" on <col>. The flexible column
   carries no width; the rest are percentages so they shrink with the viewport
   instead of squeezing the identity column down to nothing. */
.grid--individuals col:nth-child(2) { width: 13%; }
.grid--individuals col:nth-child(3) { width: 12%; }
.grid--individuals col:nth-child(4) { width: 12%; }
.grid--individuals col:nth-child(5) { width: 14%; }
.grid--individuals col:nth-child(6) { width: 11%; }

.grid--employees col:nth-child(2) { width: 17%; }
.grid--employees col:nth-child(3) { width: 13%; }
.grid--employees col:nth-child(4) { width: 13%; }
.grid--employees col:nth-child(5) { width: 11%; }
.grid--employees col:nth-child(6) { width: 11%; }

.grid--employees td:nth-child(5) { font-variant-numeric: tabular-nums; }

/* User is the column with no width - it absorbs whatever is left over. */
.grid--users col:nth-child(2) { width: 18%; }
.grid--users col:nth-child(3) { width: 24%; }
.grid--users col:nth-child(4) { width: 12%; }

/* Internal, and under it the employee it belongs to. Two lines in a 44px row, which is
   what the name cell beside it already does. */
.cell-kind { display: flex; flex-direction: column; }

.cell-kind__who {
    font-size: var(--t-sm);
    color: var(--text-mid);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Role is the column with no width; the three counts beside it are narrow and fixed. */
.grid--roles col:nth-child(2) { width: 10%; }
.grid--roles col:nth-child(3) { width: 10%; }
.grid--roles col:nth-child(4) { width: 12%; }

.grid--roles td:nth-child(2),
.grid--roles td:nth-child(3) { font-variant-numeric: tabular-nums; }

/* The name, and under it what the role is for - the same two-line cell the user grid
   uses for a name over its email. */
.cell-role__desc {
    display: block;
    font-size: var(--t-sm);
    color: var(--text-mid);
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid--values col:nth-child(1) { width: 30%; }
.grid--values col:nth-child(3) { width: 9%; }
.grid--values col:nth-child(4) { width: 13%; }
.grid--values col:nth-child(5) { width: 30%; }

/* What the list keeps with each value (Banks: address and swift code), on one line. */
.grid--values td.value-details {
    color: var(--text-mid);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grid--values [data-details-col][hidden] { display: none; }

/* The Assets section's jump row is hidden until there are two groups to jump between; the
   class sets its own display, which would otherwise win over the attribute. */
.asset-jump[hidden] { display: none; }

/* The type-specific fields, under the fixed Asset type and Name pair. */
.asset-fields { margin-top: var(--s-4); }

/* The Yes/No answers of an asset, side by side in one row in the form's right-hand column.
   Each takes a quarter of that column, so the segments are tightened to fit and a long label
   wraps rather than pushing its neighbour. */
.asset-flags {
    grid-column: 2;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s-2);
}

/* Cells in the row are as tall as the tallest, and the label takes the slack, so a label that
   wraps ("Online Banking") pushes nothing: every control sits on the same line at the bottom. */
.asset-flags .field__label { flex: 1 1 auto; overflow-wrap: anywhere; }

/* A lone answer on a row of its own, in the left-hand column. */
.asset-flags--start { grid-column: 1; }

/* Several answers take the whole row, one quarter of the form's width each (the container
   queries below only narrow it further, so they still apply to the two-by-two case). */
.asset-flags--full { grid-column: 1 / -1; }

.asset-flags .segmented__option { padding: 0 var(--s-2); }

/* The row's width is the form's, not the window's: the dialog is narrower than the window
   below ~750px, so the breakpoints are on the form itself. Wide enough, the row sits in the
   right-hand column; narrower, it takes the full width so each quarter stays wide enough for
   its segments; narrower still, it becomes two rows of two. */
.asset-fields { container-type: inline-size; }

@container (max-width: 560px) {
    .asset-flags { grid-column: 1 / -1; }
}

@container (max-width: 480px) {
    .asset-flags { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* A secret field with its show/hide eye. The shared affix reserves room on the left for a
   leading icon; there is none here, so that room goes back to the text. */
.field .input-affix.asset-secret > input[type] { padding-left: var(--s-2); }

/* Two icon buttons now, so the text keeps clear of both. The eye holds the right edge; the
   copy button sits against it. */
.field .input-affix.asset-secret:has(.input-affix__btn) > input[type] { padding-right: var(--s-2); }

.field .input-affix.asset-secret:has(.input-affix__btn:not([hidden])) > input[type] {
    padding-right: calc(var(--control-h) * 2);
}

.input-affix__btn.asset-secret__copy { right: var(--control-h); }

/* The button sets its own display, which would otherwise win over [hidden] and leave it showing. */
.input-affix__btn[hidden] { display: none; }

/* A list of named files - utility bills. The files already held, one to a line, then the row
   that adds another: a name, the file, and the button. */
.asset-files {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    padding: var(--s-3);
    border: 1px solid var(--border);
    border-radius: var(--r);
}

.asset-files__list { display: flex; flex-direction: column; }

.asset-files__row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: var(--control-h);
    font-size: var(--t-ui);
    border-bottom: 1px solid var(--border);
}

.asset-files__row:last-child { border-bottom: 0; }

/* The name takes what the links and the button leave, and clips rather than wrapping. */
.asset-files__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asset-files__add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
    align-items: center;
    gap: var(--s-2);
}

.asset-files__add input[type="text"] {
    height: var(--control-h);
    min-width: 0;
    padding: 0 var(--s-2);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    font-size: var(--t-ui);
}

.asset-files__add input[type="file"] { min-width: 0; font-size: var(--t-ui); }

/* Narrow forms stack the three, so none is squeezed below reading width. */
@container (max-width: 480px) {
    .asset-files__add { grid-template-columns: 1fr; }
}

/* A file field: what is stored, with its actions, over the picker for a new one. */
.asset-file { display: flex; flex-direction: column; gap: var(--s-2); }

/* The picker takes the edge of any other control: 32px, --border-control, the shared radius.
   Its button is a segment inside that edge, divided from the file name by a 1px rule. */
.asset-file input[type="file"] {
    box-sizing: border-box;
    width: 100%;
    height: var(--control-h);
    padding: 0;
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text-mid);
    font-family: inherit;
    font-size: var(--t-ui);
    line-height: calc(var(--control-h) - 2px);
}

.asset-file input[type="file"]::file-selector-button {
    height: 100%;
    margin: 0 var(--s-2) 0 0;
    padding: 0 var(--s-3);
    border: 0;
    border-right: 1px solid var(--border-control);
    border-radius: 0;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: var(--t-ui);
    font-weight: 500;
    cursor: pointer;
}

.asset-file input[type="file"]:hover::file-selector-button { background: var(--border); }

.asset-file__current {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    font-size: var(--t-ui);
}

.asset-file__current .choice { margin-left: 0; }

/* Asset type fields: Label is the column with no width; the rest are fixed. */
.grid--fields col:nth-child(2) { width: 18%; }
.grid--fields col:nth-child(3) { width: 15%; }
.grid--fields col:nth-child(4) { width: 10%; }
.grid--fields col:nth-child(5) { width: 9%; }
.grid--fields col:nth-child(6) { width: 11%; }

/* The key is an identifier somebody may have to type into an import, so it reads as one. */
.grid--fields code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--t-sm);
    color: var(--text-mid);
}

/* Availability matrix: the type name is the column with no width; each kind of record is
   a fixed column holding one centred checkbox. */
.grid--matrix col:nth-child(n+2) { width: 16%; }

.grid--matrix th.is-check,
.grid--matrix td.is-check { text-align: center; }

.grid--matrix input[type="checkbox"] { accent-color: var(--accent); }

/* [hidden] on a row of a choice list: .choice sets its own display, which would otherwise
   win over the attribute and leave the row standing. */
.choice[hidden] { display: none; }

/* Numeric columns get tabular figures so digits line up down the column. */
.grid--individuals td:nth-child(2),
.grid--values td:nth-child(3) { font-variant-numeric: tabular-nums; }

table.grid thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    text-align: left;
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-mid);
    border-bottom: 1px solid var(--border);
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    z-index: 1;
}

table.grid thead th .th-btn {
    all: unset;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: var(--s-1);
    width: 100%;
    padding: var(--s-2) var(--s-3);
    cursor: pointer;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
}

table.grid thead th .th-btn:hover { background: var(--bg); color: var(--text); }

/* A header whose column is too short for its label: the label is what gives way, cut with an
   ellipsis, and the arrow keeps its place. As a bare text node the label could not shrink, so
   it pushed the arrow out past the edge of the clipped header and the column looked unsortable.
   The button's title carries the whole label for whoever it has been cut for. */
table.grid thead th .th-btn__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
table.grid thead th .th-btn .sort-ind { flex: none; }

/* `all: unset` above takes the focus ring with it, so it is put back. A sort control
   reachable by tab has to be visible when it is reached. */
table.grid thead th .th-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

table.grid thead th.is-plain { padding: var(--s-2) var(--s-3); }

.sort-ind { opacity: 0; transition: opacity .1s; }
th[aria-sort="ascending"] .sort-ind,
th[aria-sort="descending"] .sort-ind { opacity: 1; }
th[aria-sort="descending"] .sort-ind { transform: rotate(180deg); }

/* The action history says every column sorts: a quiet up-and-down arrow on each header, and
   on the sorted one a single arrow in full ink pointing the way it runs. The other grids show
   an arrow only on the sorted column; this one has a short, whole list and no filter row to
   hint that its headers are controls. The unsorted glyph is decorative, so --text-dim is
   right for it - the label beside it carries the meaning. */
.grid--ticket-actions .sort-ind,
.grid--asset .sort-ind,
.grid--associates .sort-ind,
.grid--tickets .sort-ind { opacity: 1; color: var(--text-dim); transform: none; }
.grid--ticket-actions th[aria-sort] .sort-ind,
.grid--asset th[aria-sort] .sort-ind,
.grid--associates th[aria-sort] .sort-ind,
.grid--tickets th[aria-sort] .sort-ind { color: var(--text); }
.grid--ticket-actions th[aria-sort="ascending"] .sort-ind__down,
.grid--ticket-actions th[aria-sort="descending"] .sort-ind__up,
.grid--asset th[aria-sort="ascending"] .sort-ind__down,
.grid--asset th[aria-sort="descending"] .sort-ind__up,
.grid--associates th[aria-sort="ascending"] .sort-ind__down,
.grid--associates th[aria-sort="descending"] .sort-ind__up,
.grid--tickets th[aria-sort="ascending"] .sort-ind__down,
.grid--tickets th[aria-sort="descending"] .sort-ind__up { display: none; }

/* height on a cell acts as a minimum, so two-line cells still grow. */
table.grid tbody td {
    height: var(--row-h);
    padding: 0 var(--s-3);
    border-bottom: 1px solid var(--border);
    color: var(--text-mid);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

table.grid tbody tr:hover td { background: var(--bg); }

/* Rows are the affordance — there is no edit button on any grid. */
table.grid tbody tr[data-id],
table.grid tbody tr[data-assoc-row],
table.grid tbody tr[data-docs-row] { cursor: pointer; }

table.grid tbody tr[data-id]:focus-visible,
table.grid tbody tr[data-assoc-row]:focus-visible,
table.grid tbody tr[data-docs-row]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

table.grid tbody tr[data-id]:focus-visible td,
table.grid tbody tr[data-assoc-row]:focus-visible td,
table.grid tbody tr[data-docs-row]:focus-visible td { background: var(--accent-bg); }

/* A cell that leads somewhere other than where its row leads. On the associates
   grid the row edits the link and the name opens the record it names, so the name
   has to say so — a link, in the one colour that means it. */
.cell-link { color: var(--accent); text-decoration: none; }
.cell-link:hover { text-decoration: underline; }

.cell-user { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.cell-user > .avatar { flex: none; cursor: inherit; }
.cell-user__text { min-width: 0; }
.cell-user__name,
.cell-user__mail,
.cell-user__assoc { display: block; overflow: hidden; text-overflow: ellipsis; }
.cell-user__name { font-weight: var(--w-medium); color: var(--text); }
.cell-user__mail { color: var(--text-mid); font-size: var(--t-sm); }
/* --text-dim would be 2.5:1 on the surface; this is text people read, so it keeps --text-mid. */
.cell-user__assoc {
    display: flex;
    align-items: baseline;
    gap: var(--s-2);
    color: var(--text-mid);
    font-size: var(--t-sm);
}

.cell-user__assoc-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* "+2": a count, not a status, so plain tabular text on a neutral chip - pill radius is for
   badges - and it never shrinks away when the name beside it is long. */
.cell-user__more {
    flex: none;
    padding: 0 var(--s-1);
    border-radius: var(--r);
    background: var(--neutral);
    color: var(--text);
    font-weight: var(--w-medium);
    font-variant-numeric: tabular-nums;
}

/* Three lines breathe: the name, the email and the links each get a line of their own and
   the row is taller to hold them, where the other grids keep to --row-h. */
.grid--individuals .cell-user__text { display: flex; flex-direction: column; gap: var(--s-1); }
.grid--individuals tbody td { height: var(--row-h-stacked); }

/* ---------- the associations card ----------------------------------------
   What the hover on a person's links opens. The filters popover's face and edge, for the
   same reason: an object sitting on a white grid, held apart by tint and an edge and
   nothing else - no shadow, no arrow. It is a tooltip, so nothing in it takes the pointer. */
.assoc-card {
    position: fixed;
    inset: auto;
    margin: 0;
    z-index: 10;
    width: 340px;
    max-width: calc(100vw - var(--s-4));
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-3);
    overflow: visible;
    background: var(--surface-cool);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    color: var(--text);
    font-size: var(--t-ui);
    pointer-events: none;
}

.assoc-card[hidden] { display: none; }

.assoc-card__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-3);
    padding-bottom: var(--s-2);
    border-bottom: 1px solid var(--border);
    font-weight: var(--w-semi);
    letter-spacing: var(--tracking-tight);
}

.assoc-card__count { color: var(--text-mid); font-size: var(--t-sm); font-weight: var(--w-normal); }

.assoc-card__group { display: flex; flex-direction: column; gap: var(--s-1); }

.assoc-card__label {
    margin: 0;
    color: var(--text-mid);
    font-size: var(--t-label);
    font-weight: var(--w-medium);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.assoc-card__list { display: flex; flex-direction: column; gap: var(--s-1); margin: 0; padding: 0; list-style: none; }

.assoc-card__list li {
    display: flex;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-1) 0;
}

.assoc-card__name { min-width: 0; font-weight: var(--w-medium); overflow-wrap: anywhere; }

.assoc-card__role { flex: none; max-width: 50%; color: var(--text-mid); text-align: right; }

/* One of several values a cell holds, stacked - a person's two mobile numbers. */
.cell-line { display: block; overflow: hidden; text-overflow: ellipsis; }

/* The same two-line cell without an avatar - a company has no face. */
.cell-strong,
.cell-sub { display: block; overflow: hidden; text-overflow: ellipsis; }
.cell-strong { font-weight: var(--w-medium); color: var(--text); }
.cell-sub { color: var(--text-mid); font-size: var(--t-sm); }

.grid--companies col:nth-child(2) { width: 20%; }
.grid--companies col:nth-child(3) { width: 14%; }
.grid--companies col:nth-child(4) { width: 10%; }
.grid--companies col:nth-child(5) { width: 11%; }
.grid--companies col:nth-child(6) { width: 11%; }

.grid--companies td.num,
.grid--companies th.num { text-align: right; font-variant-numeric: tabular-nums; }

.grid-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-top: 1px solid var(--border);
    color: var(--text-mid);
    font-size: var(--t-sm);
    font-variant-numeric: tabular-nums;
    flex-wrap: wrap;
}

.pager { display: flex; align-items: center; gap: var(--s-1); font-variant-numeric: tabular-nums; }

.grid-empty, .grid-loading {
    padding: var(--s-7) var(--s-4);
    text-align: center;
    color: var(--text-mid);
    white-space: normal;
}

.spinner {
    width: var(--s-4);
    height: var(--s-4);
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    animation: spin .7s linear infinite;
    vertical-align: -3px;
    margin-right: var(--s-2);
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2s; }
    .rail, .app-content, .tab { transition: none; }
}

/* ---------- badges ------------------------------------------------------ */

.pill {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    padding: 2px var(--s-2);
    border-radius: var(--r-full);
    font-size: var(--t-label);
    font-weight: var(--w-medium);
    background: var(--bg);
    color: var(--text-mid);
    white-space: nowrap;
}

/*
   A role carries no status, so it has no tinted ground to draw its own shape - at --bg it
   is a word on a chip a shade off whatever is behind it, and on the user menu's cool face
   the two are near enough to touching that the chip disappears. The edge is what makes it
   read as a badge.

   --border-control, the edge this app gives an object standing on a surface, rather than
   --border, which at 1.1:1 against the chip's own ground would be no edge at all. The
   status pills keep their fills and take none: their ground already says what they are.
*/
.pill--role {
    background: var(--bg);
    color: var(--text-mid);
    border: 1px solid var(--border-control);
}
.pill--on { background: var(--ok-bg); color: var(--ok); }
.pill--off { background: var(--warn-bg); color: var(--warn); }
.pill--alert { background: var(--danger-bg); color: var(--danger); }
.pill--muted { background: var(--bg); color: var(--text-mid); }

/* An inactive record in a list: the name steps back as well as the Status pill saying so,
   so it reads as not live from across the row. */
table.grid tr.is-inactive .cell-strong { color: var(--text-mid); }

/* A checkbox row that carries a status beside its name, such as an inactive company. */
.choice .pill { margin-left: auto; }

.pill-list { display: inline-flex; flex-wrap: wrap; gap: var(--s-1); }

/* ---------- toolbar note ------------------------------------------------ */

/* Sits where a toolbar's controls would, so it takes the leftover width rather
   than pushing the Refresh button off the end. */
.toolbar__note {
    margin: 0;
    max-width: 68ch;
    font-size: var(--t-ui);
    color: var(--text-mid);
}

/* ---- salary slips ------------------------------------------------------- */

.grid--salary-slips col:nth-child(2) { width: 14%; }
.grid--salary-slips col:nth-child(3),
.grid--salary-slips col:nth-child(4),
.grid--salary-slips col:nth-child(5) { width: 11%; }
.grid--salary-slips col:nth-child(6) { width: 13%; }
.grid--salary-slips col:nth-child(7) { width: 18%; }

/* Money columns line up digit under digit, like every other numeric column. */
.grid--salary-slips td.num,
.grid--salary-slips th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* The slip's reference, under the employee's name: present for anyone who needs to
   quote it, quiet enough not to compete with the name. */
.grid--salary-slips .slip-ref {
    display: block;
    margin-top: 2px;
    font-size: var(--t-sm);
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.grid--salary-slips .slip-actions { text-align: right; white-space: nowrap; }

/* A row opens the slip, so it should look as if it does. */
.grid--salary-slips tbody tr[data-id] { cursor: pointer; }
.grid--salary-slips .slip-actions .btn + .btn { margin-left: var(--s-1); }

/* Earnings and Deductions side by side, as the people filling this in already read it.
   One column below 900px - two columns of money inputs at phone width is unreadable. */
.slip-ledger {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-4);
    margin-top: var(--s-4);
}

@media (max-width: 900px) {
    .slip-ledger { grid-template-columns: 1fr; }
}

.slip-ledger__head {
    margin: 0 0 var(--s-2);
    padding-bottom: var(--s-1);
    border-bottom: 1px solid var(--border);
    font-size: var(--t-ui);
    font-weight: 600;
    letter-spacing: -0.011em;
}

/* The three totals. Output, not input - so they read as a statement rather than as more
   fields, set off by a rule above instead of a panel of their own. */
.slip-totals {
    margin: var(--s-4) 0 0;
    padding-top: var(--s-3);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}

.slip-totals > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s-3);
}

.slip-totals dt { color: var(--text-mid); font-size: var(--t-ui); }

.slip-totals dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.slip-totals__net dt { color: var(--text); font-weight: 600; }
.slip-totals__net dd { font-weight: 600; font-size: var(--t-lg); }

/* Salary packages on an employee record. Company is the column with no width - it takes
   the leftover space, and these names are long. */
.grid--salary-details col:nth-child(2) { width: 18%; }
.grid--salary-details col:nth-child(3),
.grid--salary-details col:nth-child(4) { width: 11%; }
.grid--salary-details col:nth-child(5),
.grid--salary-details col:nth-child(6) { width: 13%; }
.grid--salary-details col:nth-child(7) { width: 10%; }

.grid--salary-details td.num,
.grid--salary-details th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* The currency beside a total: present for anyone who needs it, quiet enough that the
   figure is still what the eye lands on. */
.grid--salary-details .sd-ccy,
.grid--employee-slips .sd-ccy { color: var(--text-dim); font-size: var(--t-sm); }

/* The slips an employee has been paid, on their own record. Month is the column with no
   width; it carries the reference on a second line the way the name cell does elsewhere. */
.grid--employee-slips col:nth-child(2),
.grid--employee-slips col:nth-child(3),
.grid--employee-slips col:nth-child(4) { width: 15%; }
.grid--employee-slips col:nth-child(5) { width: 15%; }
.grid--employee-slips col:nth-child(6) { width: 10%; }

.grid--employee-slips td.num,
.grid--employee-slips th.num { text-align: right; font-variant-numeric: tabular-nums; }

.grid--employee-slips .slip-ref {
    display: block;
    margin-top: 2px;
    font-size: var(--t-sm);
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.grid--employee-slips .slip-actions { text-align: right; white-space: nowrap; }

/* ---- reminders ---------------------------------------------------------- */

/* Belongs to is the column with no width - it takes the leftover space, and it is the
   column the eye goes to first. */
/* Belongs to is the column with no width - it takes the leftover. The fourth holds one
   16px glyph, the link to the document itself, and needs no more than that. */
.grid--reminders col:nth-child(2) { width: 11%; }
.grid--reminders col:nth-child(3) { width: 24%; }
.grid--reminders col:nth-child(4) { width: 5%; }
.grid--reminders col:nth-child(5) { width: 12%; }
.grid--reminders col:nth-child(6) { width: 14%; }

/* The glyph sits on the row's own line rather than pushing it taller. */
.grid--reminders .reminder-file { line-height: 0; }

.grid--reminders .reminder-date { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The document's number under its type, the way the slip reference sits under a name. */
.grid--reminders .reminder-no {
    display: block;
    margin-top: 2px;
    font-size: var(--t-sm);
    color: var(--text-dim);
}

/* ---------- the dashboard ------------------------------------------------

   What is running out, and when. Panels on the page's inset rather than one surface:
   each answers a different question and the gaps between them say so.

   Two columns from 1100px, one below it. The lead and the queue run the full width,
   because a hero figure centred in a half-width card reads as an advert. */

.dash {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-4);

    /* Where the fixed chrome ends, so anything this page scrolls to stops clear of it.
       The same arithmetic .record-shell does, and for the same reason - the offset lives
       with the chrome that causes it rather than being a number in a script. */
    --dash-top: var(--bar-h);
}

.tabstrip:not([hidden]) + .tabpanels .dash {
    --dash-top: calc(var(--bar-h) + var(--s-2) + var(--control-h));
}

/* The list every mark fills. Clicking one scrolls its head to the top of the window, so
   the rows get the whole screen instead of the sliver under the charts. */
.dash__panel--wide { scroll-margin-top: calc(var(--dash-top) + var(--s-4)); }

/*
   While it is answering a mark, the panel takes a screenful whether or not its rows fill
   one.

   Not decoration: scrollIntoView can only scroll as far as the page goes, so a list of
   four rows at the foot of a tall page cannot be brought to the top at all - the browser
   runs out of document and leaves it exactly where it was complained about, down in the
   last inch. Giving the panel the height makes the scroll possible.

   Only while answering. On the queue it opens with, the same rule would be a cardful of
   nothing under six rows. */
.dash__panel--wide.is-answering {
    min-height: calc(100vh - var(--dash-top) - var(--s-6));
}

.dash__lead,
.dash__panel--wide { grid-column: 1 / -1; }

@media (max-width: 1100px) {
    .dash { grid-template-columns: 1fr; }
}

/* The lead carries its own KPI row, so the body above it gives up the padding the row
   then supplies - otherwise the two stack 32px apart for no reason. */
.dash__lead .card__body { padding-bottom: 0; }

.dash__lead-label {
    font-size: var(--t-label);
    font-weight: var(--w-medium);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-mid);
    margin: 0;
}

/* The one number the page leads with, and the only one at this size. Proportional
   figures, not tabular: equal-width digits make a number like 121 look loose at 48px.
   The same sans as everything else - a display face here reads as decoration. */
.hero {
    font-size: 48px;
    font-weight: var(--w-semi);
    letter-spacing: var(--tracking-tight);
    line-height: 1.05;
    color: var(--text);
    margin: var(--s-1) 0 0;
}

.dash__lead-sub {
    margin: var(--s-1) 0 0;
    font-size: var(--t-ui);
    color: var(--text-mid);
    max-width: 60ch;
}

.dash__title { font-size: var(--t-lg); font-weight: var(--w-semi); margin: 0; }

.dash__note { margin: 2px 0 0; font-size: var(--t-sm); color: var(--text-mid); }

/* The card head holds a title, what the list is showing, and the ways out of it. The
   first of those pushed right takes the rest with it. */
.dash__panel .card__head { display: flex; align-items: baseline; gap: var(--s-3); }
.dash__more { font-size: var(--t-ui); }
.dash__more:first-of-type { margin-left: auto; }

/* The head's note sits beside the title rather than under it, so a changing count does
   not change the panel's height. */
.dash__panel .card__head .dash__note { margin: 0; }

/* ---- charts -------------------------------------------------------------

   One series on every chart here - how many documents - so none carries a legend, and
   the only colour that appears means urgency. Marks are thin, the axis is a hairline a
   step off the surface, and the air around a bar is the band's leftover rather than
   something the bar grew into. */

.chart { position: relative; }

.chart__loading,
.chart__empty { margin: 0; font-size: var(--t-ui); color: var(--text-mid); }

/* The plot: an axis of ticks down the left, the marks to the right of it. */
.plot { display: flex; gap: var(--s-2); }

.plot__axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 160px;
    font-size: var(--t-sm);
    color: var(--text-dim);

    /* Ticks are a column of numbers that must line up under each other. */
    font-variant-numeric: tabular-nums;
    text-align: right;
    min-width: var(--s-5);
}

/* The tick sits on its gridline rather than above it, so the two read as one mark. */
.plot__tick { line-height: 0; }

.plot__area { position: relative; flex: 1; min-width: 0; }

/* Solid hairlines, never dashed: dashing reads as a threshold when it is only a grid.
   Three lines - nought, half and the top - which is as much structure as a seven-column
   chart can use without the grid competing with the data. */
.plot__grid {
    position: absolute;
    inset: 0 0 auto;
    height: 160px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.plot__grid::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    border-top: 1px solid var(--border);
}

.columns {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: var(--s-2);
    height: 160px;
}

/* A column is the whole band - value, mark and label - so the hit target is the band
   and not the 24px of ink in it. */
.column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    border-radius: var(--r);
}

/* Every mark fills the list at the foot of the page with the documents it counted. They
   are buttons because they act on this page rather than travelling off it - but they must
   not look like buttons: a chart whose marks wear chrome stops reading as a chart. So the
   element is reset to nothing and the only states are a hover ground, the focus ring, and
   the ground staying put on the one that is answering. */
button.column,
button.bar-row {
    appearance: none;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: inherit;
    cursor: pointer;
}

.column.is-linked:hover,
.bar-row.is-linked:hover,
.column[aria-pressed="true"],
.bar-row[aria-pressed="true"] { background: var(--bg); }

.column:focus-visible,
.bar-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The row is a grid of three; the button has to keep being that grid. */
button.bar-row {
    display: grid;
    width: 100%;
    border-radius: var(--r);
    padding: var(--s-1) var(--s-2);
    margin: 0 calc(var(--s-2) * -1);
}

.column__value {
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    color: var(--text);
    font-variant-numeric: tabular-nums;
    margin-bottom: var(--s-1);

    /* Holds its line whether or not this column is one of the labelled ones, so the
       bars all start from the same floor. */
    min-height: 1em;
}

/* Capped at 24px and centred: the leftover is the band's air, not something to fill.
   Rounded at the data end, square where it meets the baseline. */
.column__bar {
    width: 100%;
    max-width: 24px;
    height: var(--column-height, 0%);
    background: var(--text-mid);
    border-radius: 4px 4px 0 0;
}

/* The one emphasis on the page. What has already run out is the only bucket that is
   wrong rather than merely near, and the label says so too - never colour alone. */
.column--over .column__bar { background: var(--danger); }

.column__label {
    margin-top: var(--s-2);
    font-size: var(--t-sm);
    color: var(--text-mid);
    white-space: nowrap;
}

/* A label under the plot needs the room the plot does not carry. */
.columns { padding-bottom: 0; }
.plot__area { padding-bottom: 28px; }

/* The hover layer. It never carries a value that is not also in the axis or the table -
   it saves a trip, it does not gate anything. */
.chart__tip {
    position: absolute;
    left: var(--tip-x, 0);
    top: var(--tip-y, 0);
    transform: translate(-50%, calc(-100% - var(--s-2)));
    z-index: 1;
    padding: var(--s-1) var(--s-2);
    background: var(--text);
    color: var(--surface);
    border-radius: var(--r);
    font-size: var(--t-sm);
    white-space: nowrap;
    pointer-events: none;
}

/* Horizontal bars: a name, the mark, and its value at the tip. The value sits outside
   the bar, so a short bar can never clip the number it is meant to be saying. */
.bars { display: flex; flex-direction: column; gap: var(--s-3); }

/* 18ch for the name: the document types run to "Immigration Establishment Card", and a
   column narrow enough to clip "Trade License" tells the reader less than the bar does.
   It still ellipses rather than wrapping - a two-line name would break the row rhythm -
   and the full text rides the title attribute. */
.bar-row {
    display: grid;
    grid-template-columns: minmax(0, 18ch) minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--s-3);
}

.bar-row__label {
    font-size: var(--t-ui);
    color: var(--text-mid);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Rounded at the data end, square at the baseline it grows from. */
.bar-row__fill {
    height: 12px;
    width: var(--bar-width, 0%);
    background: var(--text-mid);
    border-radius: 0 4px 4px 0;
}

.bar-row__value {
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* ---- KPI tiles ----------------------------------------------------------

   Its own name, not .stat: that one is already taken by Home's stat-grid cards, and
   reusing it had the two components overwriting each other - these tiles picking up
   Home's uppercase label, Home's cards picking up this one's cursor and face. A shared
   class is a shared component, and these are not the same thing. */

/* The headline numbers, each with a meter of its share of the whole book. One tile for
   what is overdue and one per reminder-email day, so as many as the setting names: they
   share the row while each can stay 160px wide, then one column at 900px - two columns of
   figures at phone width read as a table that is not one. */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--s-3);
    padding: var(--s-4);
    border-bottom: 1px solid var(--border);
}

@media (max-width: 900px) {
    .kpi-row { grid-template-columns: 1fr; }
}

/* A tile that fills the list says so on hover, and stays lit while it is the one being
   answered - the same two states the chart marks have. */
.kpi[data-filter]:hover,
.kpi[aria-pressed="true"] { background: var(--surface); }

/* Each tile is the control that shows its own list, so it is a button - but it reads as
   a figure, not as a toolbar control: 1px edge, no shadow.

   The cool face and the heavier edge the org chart's nodes and the filters popover take,
   for the same reason: a tile is an object standing on the white card, and white on white
   left it held apart by a --border edge alone - 1.2:1, which reads as no edge at all. */
.kpi {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-1);
    padding: var(--s-3);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    background: var(--surface-cool);
    text-align: left;
    cursor: pointer;
    font: inherit;
}

/* Lifts to white rather than dimming to --bg - the way round an object on a panel
   hovers, and the opposite of a table row. */
.kpi:hover { background: var(--surface); }

.kpi:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.kpi--loading { color: var(--text-mid); cursor: default; }

.kpi__label {
    font-size: var(--t-ui);
    color: var(--text-mid);
}

/* Proportional figures, not tabular: tabular-nums gives every digit the width of a 0,
   which at this size makes a number like 121 look loose. Tabular belongs in columns
   that must align vertically, not under a standalone figure. */
.kpi__value {
    font-size: var(--t-xl);
    font-weight: var(--w-semi);
    letter-spacing: var(--tracking-tight);
    line-height: 1.1;
    color: var(--text);
}

/* The meter. The track is the lighter step of the fill's own ramp, so the state reads
   across the whole bar rather than only where it is filled. */
.kpi__meter {
    display: block;
    width: 100%;
    height: 4px;
    margin-top: var(--s-1);
    border-radius: var(--r-full);
    background: var(--surface);
    overflow: hidden;
}

.kpi__fill {
    display: block;
    height: 100%;
    width: var(--kpi-share, 0%);
    border-radius: var(--r-full);
    background: var(--text-mid);
}

/* --text-mid, not --text-dim: this line is read - it is the denominator that makes the
   figure above it mean anything - and --text-dim is for placeholders and decorative
   glyphs, where WCAG exempts it. On the tile's face it would be 2.4:1; this is 7.1:1. */
.kpi__foot { font-size: var(--t-sm); color: var(--text-mid); }

/* Severity. The fill carries it and the label names it - never colour alone. Each pair
   is the app's own status tokens: the fill on its own light step.

   Named for the severity rather than for one screen's buckets - .kpi--over meant nothing
   on the logs screen - and a tile only takes one when its figure is above zero, so a red
   0 cannot read as an alarm. A tile with nothing wrong keeps the plain ink and gray
   above. */
.kpi--danger .kpi__value { color: var(--danger); }
.kpi--danger .kpi__meter { background: var(--danger-bg); }
.kpi--danger .kpi__fill { background: var(--danger); }

.kpi--warn .kpi__value { color: var(--warn); }
.kpi--warn .kpi__meter { background: var(--warn-bg); }
.kpi--warn .kpi__fill { background: var(--warn); }

/* ---- logs --------------------------------------------------------------- */

/* Message is the column with no width - it takes the leftover space, and it is the
   column anybody is actually reading. */
.grid--logs col:nth-child(1) { width: 20%; }
.grid--logs col:nth-child(2) { width: 9%; }
.grid--logs col:nth-child(3) { width: 14%; }
.grid--logs col:nth-child(5) { width: 16%; }

/* Timestamps line up digit under digit, like every other column of figures. */
.grid--logs .log-when { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* One line of message, clipped. The whole of it is in the entry, and a log whose rows
   are three lines tall shows a third as much at a glance. */
.grid--logs .log-msg {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grid--logs .log-has-ex { color: var(--danger); font-size: var(--t-sm); }

/* ---- recycle bin -------------------------------------------------------- */

/* The file is the column with no width: it takes the leftover space, and it is the one
   being read. */
.grid--recyclebin col:nth-child(2) { width: 20%; }
.grid--recyclebin col:nth-child(3) { width: 8%; }
.grid--recyclebin col:nth-child(4) { width: 15%; }
.grid--recyclebin col:nth-child(5) { width: 10%; }
.grid--recyclebin col:nth-child(6) { width: 11%; }
.grid--recyclebin col:nth-child(7) { width: 22%; }

.grid--recyclebin td.num,
.grid--recyclebin th.num { text-align: right; font-variant-numeric: tabular-nums; }

.grid--recyclebin .bin-when { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The second line under a name: what the file was called when it was uploaded, or who
   deleted it. Quiet, like the note under a dataset name elsewhere. */
.grid--recyclebin .bin-sub {
    display: block;
    margin-top: 2px;
    font-size: var(--t-sm);
    color: var(--text-dim);
}

.grid--recyclebin .bin-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-1);
}

.log-message {
    margin: var(--s-3) 0 0;
    font-size: var(--t-ui);
    white-space: pre-wrap;
}

/* Pre-formatted and scrolled rather than wrapped: a stack trace read with its
   indentation destroyed is a stack trace nobody reads. */
.log-stack {
    margin: var(--s-3) 0 0;
    padding: var(--s-3);
    max-height: 340px;
    overflow: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--t-sm);
    line-height: 1.5;
    color: var(--text-mid);
    white-space: pre;
}

/* The employee's copy: the same figures with nothing to type. */
.slip-read { margin: 0; display: flex; flex-direction: column; gap: var(--s-2); }

.slip-read > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s-3);
    padding-bottom: var(--s-2);
    border-bottom: 1px solid var(--border);
}

.slip-read dt { color: var(--text-mid); font-size: var(--t-ui); }
.slip-read dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ---------- settings ----------------------------------------------------

   One block per setting: the control, then in prose what follows from it.
   Capped at reading width — a setting is a sentence with a select in it, and
   stretching either across a 1600px card makes a small choice look like a form.

   The control is capped separately and tighter: a select as wide as the prose
   reads as holding more than one word's worth of answer. */
.setting { display: flex; flex-direction: column; gap: var(--s-3); max-width: 68ch; }

.setting__control { max-width: 320px; }

.setting__title {
    margin: 0;
    font-size: var(--t-lg);
    font-weight: var(--w-semi);
    letter-spacing: -0.011em;
    color: var(--text);
}

/* .alert and .field set their own display, which would otherwise win over [hidden]. */
.alert[hidden],
.setting .field[hidden] { display: none; }

.setting__note {
    margin: 0;
    font-size: var(--t-ui);
    color: var(--text-mid);
}

/* The consequences of the setting, as a list rather than a paragraph: there are
   three of them and they are the reason somebody hesitates before changing it. */
.setting__list {
    margin: 0;
    padding-left: var(--s-4);
    font-size: var(--t-ui);
    color: var(--text-mid);
}

.setting__list li + li { margin-top: var(--s-1); }

/* Names the paper the rule currently points at, inside the prose around it.
   --text at 500, not the accent: this is emphasis, and the accent has four
   places that are not this one. */
.setting__subject { font-weight: var(--w-medium); color: var(--text); }

/*
 * The settings page, after the browser settings pages it borrows from: a short list of
 * sections on the left, and on the right a heading over one bordered surface of rows. Each
 * row names a setting and says in a line what is in it; pressing it opens that setting on its
 * own page, with the way back above it. Flat throughout - 1px borders, --r, no shadow - and
 * the accent only where the navigation says "you are here".
 */
.settings-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: var(--s-6);
    align-items: start;
    padding: var(--s-5);
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}

/* A nav item as the rail's are: no border or fill at rest, radius on hover only, and the
   accent bar, text and wash for the one that is current. */
.settings-nav__item {
    position: relative;
    height: 32px;
    padding: 0 var(--s-2);
    border: 0;
    border-radius: 0;
    background: none;
    font: inherit;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text-mid);
    text-align: left;
    cursor: pointer;
}

.settings-nav__item:hover { background: var(--bg); border-radius: var(--r); color: var(--text); }

.settings-nav__item[aria-current="page"] {
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 0;
}

.settings-nav__item[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent);
}

.settings-nav__item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.settings-main { max-width: 760px; min-width: 0; }

.settings-main__title {
    margin: 0;
    font-size: var(--t-title);
    font-weight: var(--w-semi);
    letter-spacing: -0.011em;
    color: var(--text);
}

.settings-main__hint {
    margin: var(--s-1) 0 var(--s-4);
    font-size: var(--t-ui);
    color: var(--text-mid);
}

.settings-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
}

.settings-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    width: 100%;
    min-height: 64px;
    padding: var(--s-3) var(--s-4);
    border: 0;
    border-bottom: 1px solid var(--border);
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.settings-row:first-child { border-top-left-radius: var(--r); border-top-right-radius: var(--r); }

.settings-row:last-child {
    border-bottom: 0;
    border-bottom-left-radius: var(--r);
    border-bottom-right-radius: var(--r);
}

.settings-row:hover { background: var(--bg); }
.settings-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.settings-row__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.settings-row__name { font-size: var(--t-body); font-weight: var(--w-medium); color: var(--text); }
.settings-row__hint { font-size: var(--t-ui); color: var(--text-mid); }
.settings-row__chevron { flex: none; color: var(--text-mid); }

/* One setting, opened: the way back, the name, and its form on the same kind of surface. */
.settings-back {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    height: 32px;
    margin: 0 0 var(--s-2) calc(-1 * var(--s-1));
    padding: 0 var(--s-2) 0 var(--s-1);
    border: 0;
    border-radius: var(--r);
    background: none;
    font: inherit;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text-mid);
    cursor: pointer;
}

.settings-back:hover { background: var(--bg); color: var(--text); }
.settings-back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: var(--s-4) var(--s-5) var(--s-5);
}

/* .setting is the form column the settings always had; inside a card it fills it. */
.settings-card.setting { max-width: none; }

@media (max-width: 900px) {
    .settings-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
    .settings-nav { flex-direction: row; flex-wrap: wrap; }
}

/* A second setting gets a rule above it, the way the record sections do. */
.setting + .setting {
    margin-top: var(--s-5);
    padding-top: var(--s-5);
    border-top: 1px solid var(--border);
}

/* ---------- forms ------------------------------------------------------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-4);
}

.field { display: flex; flex-direction: column; gap: var(--s-1); }
/* display above beats the browser's own [hidden] rule, so a field hidden by script needs this. */
.field[hidden] { display: none; }
.field--full { grid-column: 1 / -1; }
.field--col1 { grid-column: 1; }
.field--col2 { grid-column: 2; }

/* The display above beats the browser's own [hidden] rule, so a field a dialog hides
   stayed on screen showing the last record's answer. Same reason .btn[hidden] exists. */
.field[hidden] { display: none; }

/* ---------- a field that suggests as you type ----------------------------

   Built like the filters popover: a relative box around the control, the list absolute
   beneath it, --surface with a 1px edge and nothing else — no shadow, no arrow — and it
   shows on data-open. The box wraps the control alone rather than the whole field, so the
   list stays against the input when the field's error line is showing. Rows read like
   .lookup-list-item: hover to --bg, and the row the keyboard is on to --accent-bg, which
   is what that token is for.

   It is inside the sheet body, which scrolls, so the list is clipped at the body's edge
   rather than escaping it. Six rows is the cap for that reason as much as for the reading:
   the fields that carry one sit at the top of their form. */

.combo { position: relative; }

.combo__list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + var(--s-1));

    /* Over the fields below it, and over a grid's sticky header at 1. */
    z-index: 3;

    display: none;
    flex-direction: column;
    gap: 1px;

    /* Six rows and a little, so a longer list is plainly a list that scrolls. */
    max-height: calc(var(--control-h) * 6);
    overflow-y: auto;

    margin: 0;
    padding: var(--s-1);
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
}

.combo__list[data-open="true"] { display: flex; }

.combo__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-1) var(--s-2);
    border-radius: var(--r);
    cursor: pointer;
    min-width: 0;
}

.combo__item:hover { background: var(--bg); }

/* The row the arrow keys are on. Not :focus — focus stays in the input the whole way
   down the list, which is what aria-activedescendant is for. */
.combo__item[aria-selected="true"] { background: var(--accent-bg); }

.combo__name {
    font-size: var(--t-ui);
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.combo__meta {
    flex: none;
    font-size: var(--t-sm);
    color: var(--text-mid);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* What the cap left out. A line, not a row: there is nothing to pick here, and it must
   not read as the seventh document. */
.combo__more {
    padding: var(--s-1) var(--s-2);
    font-size: var(--t-sm);
    color: var(--text-dim);
}

/* A value the record computes rather than stores - years of business, the employee
   count. It reads as a field so the row keeps its rhythm, but it is deliberately not
   a control: no --border-control edge, because there is nothing here to type in or
   press, and an input-looking box that rejects every keystroke is a worse lie than a
   plain readout. */
.field__readout {
    display: flex;
    align-items: center;
    height: var(--control-h);
    padding: 0 var(--s-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--bg);
    font-size: var(--t-ui);
    color: var(--text-mid);
    font-variant-numeric: tabular-nums;
}

.field > label {
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    color: var(--text-mid);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"],
.field input[type="month"],
.field input[type="tel"],
.field input[type="search"],
.field input[type="number"],
.field select {
    height: var(--control-h);
    padding: 0 var(--s-2);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    font-size: var(--t-ui);
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    width: 100%;
}

.field input[type="date"],
.field input[type="month"],
.field input[type="number"],
.field input[type="tel"] { font-variant-numeric: tabular-nums; }

.field textarea {
    padding: var(--s-2);
    min-height: 72px;
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    font-size: var(--t-ui);
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    width: 100%;
    resize: vertical;
}

/* A date box (date-input.js): the text box the setting's format is written in, and a calendar
   button inside its right edge that opens the browser's picker. The picker itself is an
   invisible input over the box, so the calendar opens right under it. */
.date-field {
    position: relative;
    display: block;
    width: 100%;
}

.date-field > .date-field__input {
    padding-right: var(--control-h);
    font-variant-numeric: tabular-nums;
}

.date-field__btn {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--control-h);
    height: var(--control-h);
    padding: 0;
    border: 0;
    border-radius: 0 var(--r) var(--r) 0;
    background: none;
    color: var(--text-mid);
    cursor: pointer;
}

.date-field__btn:hover { color: var(--text); }

.date-field__btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* A box that cannot be changed has no calendar to offer. */
.date-field > .date-field__input:disabled ~ .date-field__btn { display: none; }

.date-field__native {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.field ::placeholder { color: var(--text-dim); }

.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.field input[aria-invalid="true"] { border-color: var(--danger); }

/* Shown rather than edited — a value the record has but this screen cannot change. */
.field input:disabled,
.field select:disabled,
.field textarea:disabled {
    background: var(--bg);
    color: var(--text-mid);
    cursor: not-allowed;
}

/* Shown, never typed: the same flat look as a disabled control, but still
   selectable so the value can be copied. */
.field input[readonly] {
    background: var(--bg);
    color: var(--text-mid);
    cursor: default;
}

.field input[readonly]:focus {
    border-color: var(--border-control);
    box-shadow: none;
}

/* A disabled dropdown's stand-in (select-mirror.js): the same look as the disabled control it
   replaces, but its text can be selected and copied. */
.select-mirror {
    display: block;
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--s-2);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    background: var(--bg);
    color: var(--text-mid);
    font-size: var(--t-ui);
    line-height: calc(var(--control-h) - 2px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: text;
    cursor: text;
}

.select-mirror[hidden] { display: none; }
.select-mirror.is-empty { color: var(--text-dim); }
select.select-mirrored { display: none; }

.field__hint { font-size: var(--t-sm); color: var(--text-mid); }
.field__hint--block { display: block; margin-top: var(--s-3); }
.field__error { font-size: var(--t-sm); color: var(--danger); }
.field__error:empty { display: none; }

.choice-list { display: flex; flex-direction: column; gap: var(--s-1); }

/* A list too long to lay out in full - every company on the books. It scrolls inside its
   own edge, so the rest of the record keeps its rhythm however many there are. 240px is
   about eight rows: enough to browse, short enough not to swallow the screen. */
.choice-list--scroll {
    max-height: 240px;
    overflow-y: auto;
    padding: var(--s-1);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    background: var(--surface);
}

/* A checkbox and its label on one line — not a card. The bordered, tinted row
   this used to draw put --accent-bg across the full width of the surface for
   every checked box, which is the accent as a large surface and the accent
   outside the four places it is allowed. The tick already says it is on. */
.choice {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-1) var(--s-2);
    border-radius: var(--r);
    cursor: pointer;
    font-size: var(--t-ui);

    /* Pulls the box back level with the label above the list; the hover chip
       still gets its padding, spent leftwards into the panel's own inset. */
    margin-left: calc(var(--s-2) * -1);
}

/* The only chrome it carries, and only while pointed at — as a nav item does. */
.choice:hover { background: var(--bg); }

.choice input { accent-color: var(--accent); }

/* A floor rather than a fixed width, so the descriptions line up under each
   other without a longer role name ever being clipped. */
.choice__name {
    font-weight: var(--w-medium);
    color: var(--text);
    min-width: var(--s-7);

    /* Keeps its own width. Left to shrink, a two-word name wrapped inside a box narrower
       than its words and ran into the description beside it. */
    flex: none;
    white-space: nowrap;
}
.choice__desc { color: var(--text-mid); font-size: var(--t-sm); }

/* On a settings page the description runs to several lines, and a box centred against all of
   them floats halfway down the paragraph. Top-aligned, the box sits level with the name it
   belongs to and the description reads on from it. */
.setting .choice { align-items: flex-start; }

/* A label over something that is not one control — a radio group, a matrix. Same type
   as .field > label, so the two line up in the same grid row. */
.field__label {
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    color: var(--text-mid);
}

/* A list you pick several from. The height rule for a single select would crush it to
   one row, so it takes its size attribute instead. */
.field select[multiple] {
    height: auto;
    padding: var(--s-1) var(--s-2);
}

/* ---------- segmented control -------------------------------------------

   Two or three mutually exclusive answers, close enough together to be read as one
   question — internal or external. A radio group underneath, so it is one tab stop and
   arrow keys move between the options; the radios themselves are hidden, and the
   segment carries the state. Sized like every other control, 32px on the same edge. */

.segmented {
    display: inline-flex;

    /* A .field stretches its children to the column, which would leave the two options
       sitting in a box several times their own width. This one is as wide as it reads. */
    align-self: start;

    height: var(--control-h);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    background: var(--surface);

    /* The segments square off against this edge rather than poking through it. */
    overflow: hidden;

    /* The anchor for the hidden radios below. Without it they are positioned against the
       nearest positioned ancestor - inside a scrolling dialog that is the dialog, not this
       control - and focusing one on click makes the browser scroll the dialog to wherever it
       thinks the input is, which carries the whole form out of view. */
    position: relative;
}

.segmented__option {
    display: flex;
    align-items: center;
    padding: 0 var(--s-3);
    font-size: var(--t-ui);
    color: var(--text-mid);
    cursor: pointer;
    white-space: nowrap;
}

.segmented__option + .segmented__option { border-left: 1px solid var(--border-control); }

.segmented__option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.segmented__option:hover { background: var(--bg); }

/* The selected state, which --accent-bg is for. The label is the accent too: on a
   two-segment control the fill alone is a weak signal at this size. */
.segmented__option:has(input:checked) {
    background: var(--accent-bg);
    color: var(--accent);
    font-weight: var(--w-medium);
}

/* The ring rides inside: an outline on a hidden radio would draw nothing, and one on
   the segment would be clipped by the control's own overflow. */
.segmented__option:has(input:focus-visible) {
    box-shadow: inset 0 0 0 3px var(--accent-ring);
}

/* ---------- rights matrix ------------------------------------------------

   Forty-odd rights read as a wall in a list, so they are laid out as what they are: a
   resource and a scope down the side, an action across the top, a box where the two
   meet. One table per area, because the columns differ - only imports can be run, only
   clients can be exported. */

.right-matrix + .right-matrix { margin-top: var(--s-4); }

.grid--rights th[scope="row"] {
    font-weight: var(--w-normal);
    text-align: left;
}

.right-matrix__resource { font-weight: var(--w-medium); color: var(--text); }

.right-matrix__scope { color: var(--text-mid); font-size: var(--t-sm); margin-left: var(--s-2); }

/* The row header takes the leftover width; every action column is the same fixed size,
   so the ticks line up down the table and across the four of them. */
.grid--rights .right-matrix__action { width: 96px; text-align: center; }

.grid--rights td { text-align: center; }

/* One button per area to untick its whole table. Plain text beside the area name: it is
   a link-weight action, and the header is not the place for a second raised control. */
.right-matrix__clear {
    margin-left: var(--s-2);
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: var(--t-sm);
    font-weight: var(--w-normal);
    letter-spacing: normal;
    text-transform: none;
    color: var(--accent);
    cursor: pointer;
}

.right-matrix__clear:hover { text-decoration: underline; }

/* The hit area is the cell's padding, not the 13px box itself. */
.right-cell {
    display: inline-flex;
    padding: var(--s-1);
    cursor: pointer;
}

.right-cell input { accent-color: var(--accent); }

/* Held through a role: shown, explained by its title, and not yours to clear here. */
.right-cell input:disabled { cursor: not-allowed; }

.picture-field {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.picture-field input[type="file"] {
    font-size: var(--t-sm);
    font-family: inherit;
    max-width: 100%;
}

/* ---------- lookup admin ------------------------------------------------ */

/* No gap: the two panes share one divider rather than floating apart. */
.lookup-layout {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    gap: 0;
    align-items: stretch;
}

.lookup-layout > .card + .card { border-left-width: 1px; }

@media (max-width: 900px) {
    .lookup-layout { grid-template-columns: 1fr; }
}

.lookup-lists {
    max-height: 60vh;
    overflow-y: auto;
    padding: var(--s-2);
}

.lookup-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--s-2);
    border: 0;
    border-left: 2px solid transparent;
    background: transparent;
    font-family: inherit;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text-mid);
    text-align: left;
    cursor: pointer;
}

.lookup-list-item:hover { background: var(--bg); border-radius: var(--r); color: var(--text); }

.lookup-list-item[aria-current="true"] {
    background: var(--accent-bg);
    border-left-color: var(--accent);
    color: var(--accent);
}

/* ---------- record page ------------------------------------------------- */

/* Five equal columns: four rows of four fields, and the picture holding the
   fifth column down all four. Every field is exactly one column wide, so the
   column edges line up the whole way down the form — the earlier twelve-column
   grid let each row divide the width its own way and nothing below the top row
   aligned with anything above it. */
.record-grid {
    /* --cols is the whole grid; --field-cols is how much of it fields may take.
       They differ only where something else holds a column — the individual
       record's picture holds the fifth. */
    --cols: 5;
    --field-cols: 4;

    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: var(--s-4);
    align-items: start;
}

/* A record with no picture and fewer fields per row. Nothing else changes:
   items still declare width in columns, so they land on the same lines. */
.record-grid--3col { --cols: 3; --field-cols: 3; }

/* No picture, so every column is a field column - the company record. */
.record-grid--4col { --cols: 4; --field-cols: 4; }

.record-grid > * { grid-column: span 1; }

/* Two columns, taking whatever gap is left on the current row. */
.record-grid > .record-grid__pair { grid-column: span 2; }

/* Every field column, and a definite start so it breaks to a row of its own
   rather than tucking itself into the tail of the one above. */
.record-grid > .record-grid__wide { grid-column: 1 / span var(--field-cols); }

/* The long field that leads a row with one short one beside it: every field column but
   the last, which is left for the partner (a title, then its status). A definite start so
   it opens its own row. On three columns that is two and one; on two, one and one. */
.record-grid > .record-grid__lead { grid-column: 1 / span calc(var(--field-cols) - 1); }

/* One column, but opening a row rather than filling the tail of the one above —
   for a run that has to read as a set (the three languages) and would otherwise
   be split across a row boundary. */
.record-grid > .record-grid__break { grid-column-start: 1; }

/* One column, all four rows. Label above the frame, as a field labels its
   input, and the frame takes whatever height the four rows come to. */
.record-photo {
    grid-column: -2 / -1;
    grid-row: 1 / span 4;
    display: flex;
    flex-direction: column;
    gap: var(--s-1);

    /* The grid starts its items; this one has to fill its rows instead. */
    align-self: stretch;
    min-height: 0;
}

/* The individual's picture column, for a group of three rows: the employee's
   photo, shown and not edited. */
.record-photo--three { grid-row: 1 / span 3; }

/* Three rows are shorter than the individual's four, so a full-width column makes the
   frame landscape and cropping cuts the head. A narrower column keeps it portrait,
   and the crop anchors to the top so any trim comes off the shoulders. */
.record-grid--slim-photo { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 0.6fr); }
.record-photo--three .avatar__img { object-position: center top; }

.avatar--static { cursor: default; }

/* The label line: the same type a field puts over its input, and nothing else in
   the flow, so it is exactly as tall as one — which puts the frame's top edge
   level with the row of inputs beside it. */
.record-photo__head {
    position: relative;
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    color: var(--text-mid);
}

/* The picker overhangs that line rather than setting its height, which is what
   pushed the label out of step with the others. 24px keeps a target big enough
   to hit while its hover chip stays inside the 4px gap under the label. */
.record-photo__head .icon-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: var(--s-5);
    height: var(--s-5);
}

/* Fills the column and the rows left under the label: portrait, which is the
   shape a face wants anyway. The img covers, so it fills without stretching. */
.avatar--record {
    width: 100%;
    height: auto;
    flex: 1;
    min-height: 96px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    font-size: var(--t-title);
    cursor: pointer;
}

/* ---------- field groups -------------------------------------------------

   Thirty fields in one run is a wall. A group gathers the ones that answer the
   same question — who this is, what they do here, how to reach them — and is a
   real <fieldset>, so the grouping lives in the document and not only in the
   spacing: assistive tech announces the legend with every control inside it.

   Each group is drawn as a box: a 1px --border edge with the legend sitting in
   the gap it cuts in the top rule. This is the one place the app nests an edge
   inside the page's surface — asked for deliberately, so a section's extent is
   unmistakable and not left to the spacing. It stays an edge and nothing more:
   no fill, no shadow, no radius but the app's own, so the panel still reads as
   one surface with lines drawn on it rather than as a stack of cards.

   The grid inside a group is the record's own, so the column edges still line
   up the whole way down the form. */

.field-group {
    /* The UA's own border is 2px groove and its padding is em-based; both are
       replaced. min-width goes because a fieldset uniquely refuses to shrink
       below its widest control — one long option would push the form wide. */
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin: 0;
    padding: var(--s-4);
    min-width: 0;

    /* The cool neutral, the same face the org chart's nodes take: it separates a
       group from the white panel without carrying any of the accent, and the
       white controls inside it gain an edge they did not have on white. It also
       keeps --text-mid at 7.1:1, so the legend and every label still clear. */
    background: var(--surface-cool);
}

.field-group + .field-group { margin-top: var(--s-4); }

/* The label type a table header wears, so a section name and a column name read
   as the same order of thing. --text-mid rather than --text-dim: this is text
   to be read, not a placeholder.

   No display or width here on purpose. A legend left in its native layout is
   the only thing that breaks the fieldset's top border for its own width, which
   is the whole reason to mark a section with one; the padding sets how much of
   that line it clears, and the margin holds it off the top-left corner. */
.field-group__legend {
    padding: 0 var(--s-2);
    margin-left: var(--s-1);
    font-size: var(--t-label);
    font-weight: var(--w-semi);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-mid);
}

/* ---------- record action rail -------------------------------------------

   A record screen carries no footer: its actions ride a bar down the right edge,
   in view wherever the form is scrolled and never chased to the bottom of a long
   one. Icons only — each says its name in a label that flies out on hover or
   keyboard focus, so the bar costs 48px and still reads. */

.record-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--action-rail-w);

    /* Where the surface starts: under the app bar, and under the tab strip too
       when one is on show. The bar's height and the surface's floor both read it,
       so the two always agree on where the panel ends. */
    --record-top: var(--bar-h);

    /* Fills the panel, so the bar runs the surface's full height on a short
       record rather than stopping where the fields happen to. */
    min-height: calc(100vh - var(--record-top));
}

.tabstrip:not([hidden]) + .tabpanels .record-shell {
    --record-top: calc(var(--bar-h) + var(--s-2) + var(--control-h));
}

/* Without this the grid column takes its width from the widest field. */
.record-shell__main { min-width: 0; }

/*
   The heading a profile carries and no other record does.

   Every other record is named by its tab. A profile is opened with no parent grid behind
   it, and the strip only shows from two tabs up - so on its own it arrived as a form with
   nothing on it saying whose it was. The face and the name do that job.

   A rule under it rather than a band of colour: this is a heading, not a hero.
*/
.record-head {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    border-bottom: 1px solid var(--border);

    /* Room round the face and the name wherever the heading stands - a form's body pads it
       itself (below), but the activity timeline puts it straight in the card, where the
       avatar sat hard against the tab strip. */
    padding: var(--s-3) var(--s-4);

    /* Stays while the form scrolls under it, pinned to the same line the action rail is -
       both read --record-top, so the heading and the actions cannot settle at different
       heights. A page whose only title scrolls away is the blank page again, three
       fieldsets down. */
    position: sticky;
    top: var(--record-top);

    /* Under the action rail, which is 2 and has flyout labels reaching left across this. */
    z-index: 1;

    /* The surface it stands on, or the fields would show through as they pass behind. */
    background: var(--surface);
}

/* The same heading on a record that is not a profile: it scrolls away with the form. The tab
   already names the record, so there is nothing for a pinned copy to keep in view. */
.record-head--static { position: static; }

/* Out to the body's own edges, so the strip it repaints covers the full width and the
   16px above it - otherwise a field scrolling up appears in that gap. Specific enough to
   beat `.card__body > :first-child { margin-top: 0 }`, which this is. */
.card__body > .record-head {
    margin: calc(var(--s-4) * -1) calc(var(--s-4) * -1) var(--s-4);
    padding: var(--s-4);
}

/* The same ring the app bar's avatar wears, for the same reason: a photograph is whatever
   colour sits at its rim and needs an edge that does not depend on the picture. */
.record-head .avatar { border: 1px solid var(--border-control); cursor: default; }

.record-head .page__title { margin: 0; }

.action-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-4) var(--s-2);
    background: var(--bg);

    /* Recessed against the form, with one 1px edge dividing them — the bar is
       chrome, not a card, so it takes no radius and no shadow. */
    border-left: 1px solid var(--border);

    /* Pinned, so a long form scrolls under the actions instead of past them.
       A hair shorter than the panel: the surface's own bottom rule takes the
       last pixel, and matching it exactly would push the page into a scroll. */
    position: sticky;
    top: var(--record-top);
    align-self: start;
    height: calc(100vh - var(--record-top) - 1px);

    /* Above the page's own content. A grid's sticky header carries z-index 1 to
       hold it over its rows, which was enough to cut across the flyout labels
       reaching left out of this bar. */
    z-index: 2;
}

.action-rail__set {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
}

/* The rail carries commands and then sections. The rule says which is which —
   without it the section buttons read as four more things Save might do. */
.action-rail__set--nav {
    align-self: stretch;
    margin-top: var(--s-4);
    padding-top: var(--s-4);
    border-top: 1px solid var(--border);
}

/* An edge on every section button, so the rail reads as a row of controls
   rather than five loose glyphs. --border-control, not --border: a divider
   wants to be quiet, a control's boundary does not. */
.action-rail__section { border-color: var(--border-control); }

/* The section on show. This is an active nav indicator, which is one of the
   four places the accent is allowed — the same pairing the rail's own active
   row takes, so the two navigations agree on what "you are here" looks like.
   The edge goes to --accent rather than --accent-border: against the grey the
   others wear, the light variant would read as less emphasis, not more. */
.action-rail__section[aria-current="true"] {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
}

/* What the bar says rather than does — the record's id — sits at the far end. */
.action-rail__set--foot {
    margin-top: auto;
    min-height: 0;
}

/* A section opens under the form rather than in place of it, so it takes a rule
   of its own to sit below and room to clear the last field. */
.record-section--sub {
    margin-top: var(--s-5);
    padding-top: var(--s-5);
    border-top: 1px solid var(--border);
}

/* ---------- a run of periods --------------------------------------------

   The VAT quarters: four rows of three dates, with the quarter named once down
   the side and From / To / Due named once across the top. Twelve labelled
   fields would say "Qtr 1" three times and "From" four times, which is a lot of
   type for seven facts.

   A grid rather than a table because these are form controls in rows — a table
   would promise a reading order the dates do not have. The first column takes
   the width of its longest label and no more; the three date columns share what
   is left, so their edges line up down the whole run. */
/* Aligned to the top of each cell, not its middle. A cell is a .field, so a refused
   date grows one downwards by the height of its message; centring would then lift
   that cell's input above the two beside it and the row would read as broken. */
.period-grid {
    display: grid;
    grid-template-columns: auto repeat(3, minmax(0, 1fr));
    gap: var(--s-2) var(--s-3);
    align-items: start;
    margin-top: var(--s-4);
}

/* The type a table header wears, because that is what these are. */
.period-grid__head {
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

/* The row's own name. Cell type rather than label type: it names a row of the
   run, the way the first column of a table does, and it must not wrap — the
   column is sized to it.

   Given the control's own height and centred inside it, so the name sits level
   with the three boxes it belongs to even though the grid aligns to the top. */
.period-grid__row {
    display: flex;
    align-items: center;
    min-height: var(--control-h);
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text-mid);
    white-space: nowrap;
    padding-right: var(--s-1);
}

/* Anything the record scrolls to stops clear of the fixed chrome above it.
   --record-top is set on .record-shell and inherited down, so it already knows
   whether a tab strip is on show. */
.record-section--sub {
    scroll-margin-top: calc(var(--record-top) + var(--s-4));
}

/* A category has the section's pinned head above it as well, so it clears that
   too, or a jump would put it straight underneath. --asset-head-h is measured
   by the page script, since the head's height changes when the jump row wraps;
   the arithmetic stays here, where --record-top already lives. */
.asset-group {
    scroll-margin-top: calc(var(--record-top) + var(--asset-head-h, 0px) + var(--s-2));
}

/* The assets head and its jump row hold their place while the categories scroll
   under them. --record-top is what the action rail pins to, so the two agree on
   where the page's chrome ends. The surface behind it is what stops rows showing
   through as they pass. */
.asset-sticky {
    position: sticky;
    top: var(--record-top);
    z-index: 2;
    background: var(--surface);
    padding-top: var(--s-4);
    padding-bottom: var(--s-4);
}

/* Jump list for the asset categories: buttons, so 6px and --border-control from
   .btn, not a row of badges. */
.asset-jump {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    margin-bottom: var(--s-4);
}

/* Inside the sticky head the container supplies that room instead — a margin
   here would collapse out of it and leave the row flush on the rows below. */
.asset-sticky .asset-jump { margin-bottom: 0; }

.asset-jump__count {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* A category's own column headers do not stick: the tables are short, the
   section's head is already pinned, and a second sticky row would only fight
   it for the same strip of screen. */
.asset-group table.grid thead th { position: static; }

/* A section that is navigable but has nothing in it yet. No card and no border:
   it stands on the surface the record already gives it. */
.section-empty {
    padding: var(--s-7) 0;
    max-width: 52ch;
}

.section-empty__title {
    font-size: var(--t-lg);
    font-weight: var(--w-semi);
    margin: 0 0 var(--s-2);
}

.section-empty__text {
    color: var(--text-mid);
    font-size: var(--t-ui);
    margin: 0;
}

/* The toolbar doing duty as a section's head. The card body already supplies
   the inset, so this one keeps only its rule and the room under it. */
.toolbar--section {
    padding: 0 0 var(--s-3);
    margin-bottom: var(--s-4);
}

.toolbar__title {
    font-size: var(--t-lg);
    font-weight: var(--w-semi);
    margin: 0;
}

.toolbar__count {
    font-size: var(--t-ui);
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* ---------- filters popover ----------------------------------------------

   The filters a section is not asked for on most visits, kept off the toolbar
   because the row has no width left for three more selects and because a record
   with four documents needs none of them. Built like the user menu: a button
   with aria-expanded, a panel that shows on data-open, closed by a click
   elsewhere or by Escape. An edge and nothing else — no shadow, no arrow. */

.filters { position: relative; }

.filters__panel {
    position: absolute;
    right: 0;
    top: calc(100% + var(--s-2));

    /* Over the grid's own sticky header, which sits at 1, and the timeline's sticky day
       heading, which sits at 2 - under that one the panel was cut across by "Today". */
    z-index: 3;

    width: 260px;
    max-width: calc(100vw - var(--s-6));
    display: none;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-3);

    /* The same face and the same edge the org chart's nodes take, for the same
       reason: this is an object sitting on a white panel, not part of it, and on
       --surface with a --border edge it dissolved into the card behind it - 1.2:1,
       which reads as the two having merged. The raised treatment that would separate
       them elsewhere is the rail's four buttons and nothing else, so the tint does
       it. The controls inside stay white, so they still read as controls. */
    background: var(--surface-cool);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
}

/* Hover lifts the row to white rather than dimming it to --bg - the opposite way
   round from a table row, and the same way round as an org chart node, because here
   the row is the foreground and the panel behind it is already tinted. */
.filters__panel .choice:hover { background: var(--surface); }

.filters__panel[data-open="true"] { display: flex; }

/* Controls a section hides until it has something to filter. .btn and .filters set their own
   display, which would otherwise beat the browser's own [hidden] rule. */
.btn[hidden],
.filters[hidden] { display: none; }

.filters__foot {
    display: flex;
    justify-content: flex-end;
    padding-top: var(--s-3);
    border-top: 1px solid var(--border);
}

/* How many of the panel's filters are set, so nothing can be narrowing the grid while
   the panel is shut and says nothing. Plain tabular text, not a badge: pill radius is
   for status badges, and this is a number on a label. */
.filters__count { color: var(--text-mid); font-variant-numeric: tabular-nums; }

/* .btn is a flex row with a gap, so an empty span would still push the label 8px off
   centre on every button with no filters set. */
.filters__count:empty { display: none; }

/* Assets are one list per category. Laid out rather than collapsed: six short
   lists read faster all on show than opened one at a time, and every category's
   count then lines up down the same edge. */
.asset-group + .asset-group { margin-top: var(--s-6); }

/* A band, so each category's name reads as the head of the list under it rather
   than as another line of text between two tables. A grid row's height and the
   6px radius, both taken from what the rest of the app already uses. */
.asset-group__head {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    height: var(--row-h);
    padding: 0 var(--s-3);
    margin-bottom: var(--s-1);
    background: var(--bg);
    border-radius: var(--r);
    font-size: var(--t-ui);
    font-weight: var(--w-semi);
}

/* A plain glyph, no tile and no circle behind it, and not from the --nav-*
   palette — that one tints the rail's icons and nothing else. */
.asset-group__icon { flex: none; color: var(--text-mid); }

.asset-group__count {
    font-weight: var(--w-normal);
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* Each category adds its own kind. One "add asset" over the section could not
   know which of six lists it was adding to, and would have to ask. */
.asset-group__add,
.asset-group__action { margin-left: auto; }

/* Section tables. First column takes the leftover width, as the grids do.
   Documents run Details, Type, File, Issued, Expires, Status - File holds two 16px
   glyphs and needs no more than that.

   Details is the one with no width, so it gets everything the others leave: a document's
   description is the long text on the row and the thing that was being cut. Type is the
   short word beside it and gives up a little for it. Status is the wide one of the fixed
   columns: it carries a badge and, on a document another one replaced, the word saying so
   beside it. The two dates give up a point each for it — a date is 10 characters however
   much room it is given. */
.grid--docs col:nth-child(2) { width: 20%; }
.grid--docs col:nth-child(3) { width: 8%; }
.grid--docs col:nth-child(4) { width: 11%; }
.grid--docs col:nth-child(5) { width: 11%; }
.grid--docs col:nth-child(6) { width: 18%; }

.grid--tickets col:nth-child(2) { width: 11%; }
/* Due: a fixed width, enough for a whole date with the cell's padding and no more. It is a
   plain length on purpose - a column width that mixes % and px (max(), calc()) is dropped by
   table layout, and the column then shares the spare room equally with the flexible one. */
.grid--tickets col:nth-child(3) { width: 128px; }
.grid--tickets col:nth-child(4) { width: 18%; }
.grid--tickets col:nth-child(5) { width: 12%; }

/* The process library: Process takes the leftover, and Write-up holds two 16px
   glyphs and needs no more than that. */
.grid--processes col:nth-child(2) { width: 18%; }
.grid--processes col:nth-child(3) { width: 9%; }
.grid--processes col:nth-child(4) { width: 12%; }
.grid--processes col:nth-child(5) { width: 11%; }
.grid--processes td:nth-child(4) { font-variant-numeric: tabular-nums; }

.grid--associates col:nth-child(2) { width: 22%; }
.grid--associates col:nth-child(3) { width: 15%; }
.grid--associates col:nth-child(4) { width: 11%; }
.grid--associates col:nth-child(5) { width: 12%; }

/* The Tickets section above is five columns on a client's record, where the client
   is already known. The full grid is six - it has to name the client too - so it
   gets its own set rather than borrowing one that is a column short. Ticket is the
   column with no width. */
.grid--ticket-list col:nth-child(2) { width: 10%; }
.grid--ticket-list col:nth-child(3) { width: 20%; }
.grid--ticket-list col:nth-child(4) { width: 128px; }
.grid--ticket-list col:nth-child(5) { width: 14%; }
.grid--ticket-list col:nth-child(6) { width: 12%; }

/* Action history: eight columns, and Action taken is the one that gives. The row
   number is barely wider than its digits, and Files holds one icon. */
.grid--ticket-actions col:nth-child(1) { width: 4%; }
.grid--ticket-actions col:nth-child(2) { width: 11%; }
/* The date plus the completion tick beside it. */
.grid--ticket-actions col:nth-child(3) { width: 156px; }
.grid--ticket-actions col:nth-child(5) { width: 12%; }
.grid--ticket-actions col:nth-child(6) { width: 12%; }
.grid--ticket-actions col:nth-child(7) { width: 12%; }
.grid--ticket-actions col:nth-child(8) { width: 10%; }
.grid--ticket-actions col:nth-child(9) { width: 7%; }

/* The ticket's own files, above its action log rather than in a section of their
   own: a file is evidence of something that was done. Ruled off below so the log
   still reads as the main event, and hidden entirely when there are none. */
.doc-strip {
    padding: 0 0 var(--s-4);
    margin-bottom: var(--s-4);
    border-bottom: 1px solid var(--border);
}

/* The same voice as a grid's column heading, because it labels a list the same way. */
.doc-strip__title {
    margin: 0 0 var(--s-2);
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-mid);
}

/* One rule for all six asset grids rather than a width set per category: the name column
   is given a large share outright and the rest split what is left evenly, so the six
   tables line up with each other instead of each finding its own proportions.

   The share is stated, not left over. The old rule gave every other column 17%, which for
   a bank's six fields is 102% - fixed layout then scales them all down together and the
   name ended up exactly as narrow as an account type. A type with fewer fields leaves the
   rest wider, and the name still takes its share first. */
.grid--asset col:first-child { width: 30%; }

/* A list with an address (the two property types): the name takes a share, the dates and the
   short values a width that shows them, and the address - which has no width of its own - is
   left everything that remains, so it is always the widest column. Plain lengths and a
   percentage only: a width that mixes them in one expression is dropped and the column
   falls back to auto. */
.grid--asset-address col:first-child { width: 18%; }
.grid--asset-address col.col-date { width: 140px; }
.grid--asset-address col.col-narrow { width: 96px; }
.grid--asset-address col.col-file { width: 112px; }
.grid--asset-address col.col-address { width: auto; }

/* The last column of a bank list: one icon button that reports on that account alone. Just
   wide enough for it, after the rule above so it is not stretched to a field's share. */
.grid--asset col.col-action { width: calc(var(--control-h) + var(--s-4)); }
.grid--asset td.cell-action { text-align: right; padding-top: 0; padding-bottom: 0; }

/* A value with a copy button beside it. The text is what gives way when the column is
   short - cut with an ellipsis - and the button never does, so it is always within reach.
   Smaller than the 32px icon button: it sits in a 44px row beside a value, not alone. */
.cell-copy { display: flex; align-items: center; gap: var(--s-1); min-width: 0; }
.cell-copy__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-copy__btn { flex: none; width: var(--s-5); height: var(--s-5); }
.grid--asset td:nth-child(n+2) { font-variant-numeric: tabular-nums; }

.grid--docs td:nth-child(4),
.grid--docs td:nth-child(5),
.grid--tickets td:nth-child(2),
.grid--tickets td:nth-child(3),
.grid--ticket-list td:nth-child(2),
.grid--ticket-list td:nth-child(4),
.grid--ticket-actions td:nth-child(1),
.grid--ticket-actions td:nth-child(2),
.grid--ticket-actions td:nth-child(3),
.grid--ticket-actions td:nth-child(8) { font-variant-numeric: tabular-nums; }

/* An action past its due date, on a ticket still open: the date in the danger ink and how far
   past it is said underneath, in words, so it does not rest on the colour alone. */
.grid--ticket-actions td.is-overdue,
.grid--ticket-list td.is-overdue,
.grid--tickets td.is-overdue { color: var(--danger); font-weight: var(--w-medium); }

.grid--ticket-actions .due-over,
.grid--ticket-list .due-over,
.grid--tickets .due-over,
.grid--ticket-actions .due-done {
    display: block;
    font-size: var(--t-sm);
    font-weight: var(--w-normal);
}

/* A finished action: the date steps back to the ordinary ink and the day it was done is said
   underneath, in words, so it does not rest on the colour alone. */
.grid--ticket-actions .due-done { color: var(--ok); }

/* The date and the tick beside it. */
.grid--ticket-actions .due-line {
    display: flex;
    align-items: center;
    gap: var(--s-1);
}

/* Marks an action done, or puts it back. A bare glyph like the file button: the cell is
   already the row's, so a border here would turn every row into a form. */
.act-check {
    display: inline-grid;
    place-items: center;
    width: var(--s-5);
    height: var(--s-5);
    padding: 0;
    border: 0;
    border-radius: var(--r);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
}

.act-check:hover { background: var(--bg); color: var(--text); }
.act-check:disabled { cursor: progress; opacity: .6; }
.act-check[aria-pressed="true"] { color: var(--ok); }
.act-check:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* The action a link brought you to - from My actions in the app bar. Held for a few
   seconds and then let go, so it reads as "here" and not as a state the row is in. */
.grid--ticket-actions tr.is-target td { background: var(--accent-bg); }

.action { position: relative; display: flex; }

/* The button's name, beside it and only while it is hovered or focused. Ink on
   light rather than a bordered white chip: it floats over the form's own surface,
   where a 1px --border would leave it barely separated from what it covers. */
.action__label {
    position: absolute;
    right: calc(100% + var(--s-2));
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    height: var(--control-h);
    padding: 0 var(--s-2);
    border-radius: var(--r);
    background: var(--text);
    color: var(--surface);
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    white-space: nowrap;

    /* Hidden, not display:none — it has to be able to fade. Pointer-transparent
       so it can never sit between the cursor and the button it names. */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .12s ease;
}

/* :focus-visible, not :focus-within — a click leaves focus sitting on the
   button, so focus-within kept the label up after the pointer had gone. This
   still shows it for anyone arriving by keyboard, which is why it is here. */
.action:hover .action__label,
.action:has(:focus-visible) .action__label {
    opacity: 1;
    visibility: visible;
}

/* The record's id, set down the bar's foot: 48px of width has no room for it
   and the bar has height to spare. */
.record-id {
    writing-mode: vertical-rl;
    font-size: var(--t-sm);
    color: var(--text-mid);
    font-variant-numeric: tabular-nums;
    min-height: 0;
    overflow: hidden;
}

/* Still worn by the lookup sheet's footer, which is a dialog and keeps one. */
.record-actions {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

/* A setting's actions sit under its fields, and a form is not a flex column, so nothing
   else puts air between the last field and the buttons. One step above the grid's own gap,
   so the buttons read as a separate row rather than another field. */
.setting .record-actions { margin-top: var(--s-5); }

@media (max-width: 1100px) {
    /* Two columns whatever the record asked for, and no column held back. */
    .record-grid { --cols: 2; --field-cols: 2; }

    /* A pair is "two columns of the row it lands on", which on three columns leaves the
       first for its partner (Type, then the entity picker). On two it would take the whole
       row and push the partner onto a line of its own, so it takes one and the two sit side
       by side. Opt-in, on the grids that want it (the ticket forms): other records lay their
       pairs out for themselves. The one-column rule further down still puts it back to full width. */
    .record-grid--pair-beside > .record-grid__pair { grid-column: span 1; }

    /* Two columns leave none to spare for a picture, so it gives up its column
       and takes a row of its own — label beside a fixed square, as before. */
    .record-grid > .record-photo {
        grid-column: 1 / -1;
        grid-row: auto;
        flex-direction: row;
        align-items: center;
        gap: var(--s-3);
    }

    /* Beside the square rather than over it, so the picker goes back into the
       flow at its right. */
    .record-photo__head { display: flex; align-items: center; gap: var(--s-2); }

    .record-photo__head .icon-btn {
        position: static;
        transform: none;
        width: var(--control-h);
        height: var(--control-h);
    }

    .avatar--record { flex: 0 0 auto; width: 72px; height: 72px; min-height: 0; }
}

/* ---------- switch ------------------------------------------------------ */

.switch {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    align-self: center;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text-mid);
    cursor: pointer;
}

.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

/* The one deliberate exception to "pill radius on status badges only": a switch
   track that is not a stadium reads as a checkbox. Shape here is functional. */
.switch__track {
    position: relative;
    flex: none;
    width: var(--s-6);
    height: 18px;
    border-radius: var(--r-full);
    background: var(--border);
    transition: background .12s;
}

.switch__knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: var(--s-3);
    height: var(--s-3);
    border-radius: 50%;
    background: var(--surface);
    transition: transform .12s;
}

.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track .switch__knob { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Reflects state only — changed by the Deactivate button, never clicked here.
   Outlined so it does not read as something you can flip. */
.switch--readonly { cursor: default; }

.switch--readonly .switch__track {
    background: var(--surface);
    border: 1px solid var(--border);
}

.switch--readonly .switch__knob { background: var(--border); }
.switch--readonly[data-on="true"] .switch__track { background: var(--accent-bg); border-color: var(--accent); }
.switch--readonly[data-on="true"] .switch__knob { background: var(--accent); transform: translateX(14px); }

/* A switch carries its own name, so it has no label above it. Dropped straight
   into a grid row it centres on label-plus-control and rides above the inputs
   beside it. Wrapping it in a field and reserving the label's line puts it in
   the control row instead, where it centres on those inputs.

   The line is reserved by setting a blank one in a label's own type, not by a
   pixel offset: change the label's size and the switch follows it. */
/* The type goes on the span, not on the ::before: a line box is as tall as its
   own element's strut too, so leaving the span at the inherited 14px made the
   reserved line taller than a real label's and left the switch a few pixels
   high. This is exactly the type .field > label carries. */
.field--switch > .field__spacer {
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
}

.field--switch > .field__spacer::before { content: "\00a0"; }

/* Control height, so the switch's box is the input's box and its contents
   centre exactly where an input's text does. align-self is the field's cross
   axis here — start keeps the switch at the left edge, not centred in it. */
.field--switch > .switch {
    align-self: start;
    height: var(--control-h);
    font-size: var(--t-ui);
}

/* ---------- dialog ------------------------------------------------------ */

dialog.sheet {
    border: 1px solid var(--border);
    padding: 0;
    border-radius: var(--r);
    width: min(560px, calc(100vw - var(--s-6)));
    color: var(--text);
    background: var(--surface);

    /* The dialog itself must never scroll — only .sheet__body does. Without this
       the body's own max-height can push head+body+foot past the dialog's height
       and you get two nested scrollbars. */
    max-height: calc(100vh - var(--s-7));
    overflow: hidden;
}

/* Only applies when open, so the closed dialog stays display:none. */
dialog.sheet[open] {
    display: flex;
    flex-direction: column;
}

dialog.sheet > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
}

dialog.sheet--wide { width: min(720px, calc(100vw - var(--s-6))); }

/* One question and its answer. Narrow because that is all it is — a wider box would
   promise more than it asks. */
dialog.sheet--narrow { width: min(440px, calc(100vw - var(--s-6))); }

dialog.sheet::backdrop { background: var(--backdrop); }

.sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-4);
    border-bottom: 1px solid var(--border);
    flex: none;
}

.sheet__title { font-size: var(--t-lg); font-weight: var(--w-semi); margin: 0; }

/* Takes whatever height is left between head and foot, and is the only scroller. */
.sheet__body {
    padding: var(--s-4);
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* A fieldset that is only there to disable what is inside it - the read-only view of a
   dialog. It draws nothing of its own. */
.sheet__fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.sheet__body > :first-child { margin-top: 0; }
.sheet__body > :last-child { margin-bottom: 0; }

.sheet__foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-4);
    border-top: 1px solid var(--border);
    background: var(--bg);
    border-radius: 0 0 var(--r) var(--r);
    flex: none;
}

/* Deactivate / activate lives on the record sheet only — never on a grid row. */
.sheet__foot .record-actions { margin-right: auto; }

/* The one action in a sheet that destroys something, held away from Cancel and Save so
   it cannot be hit on the way to either. Not on .btn--danger itself: the confirmation
   this opens has a danger button of its own, and that one belongs on the right with the
   other answers to the question. */
.sheet__destroy { margin-right: auto; }

/* A titled block inside the sheet body, below the form grid. */
.sheet__section {
    margin-top: var(--s-4);
    padding-top: var(--s-4);
    border-top: 1px solid var(--border);
}

.sheet__subtitle {
    margin: 0 0 var(--s-2);
    font-size: var(--t-ui);
    font-weight: var(--w-semi);
    color: var(--text);
}

/* The sentence a dialog opens with when it is asking something rather than
   collecting a form. */
.sheet__lede {
    margin: 0 0 var(--s-3);
    font-size: var(--t-ui);
    color: var(--text-mid);
}

/* What the answer applies to, listed above the buttons that decide. */
.sheet__lede + .doc-list { margin-bottom: var(--s-4); }

/* A consequence of saving, said beside the fields that cause it rather than after the
   fact — this document is filed under a name the record already holds live. Ruled off on
   the left in --warn rather than filled: it is a heads-up, not a failure, and
   .alert--error is what a failure looks like here.

   It is a grid child in the document dialog rather than being wrapped in a .field, so
   hiding it takes its row and the gap above it with it. */
.sheet__note {
    margin: 0;
    padding: var(--s-2) var(--s-3);
    border-left: 2px solid var(--warn);
    background: var(--warn-bg);
    border-radius: 0 var(--r) var(--r) 0;
    font-size: var(--t-ui);
    color: var(--text-mid);
}

/* The browser's own file input is 32px of grey chrome that ignores every token in this
   stylesheet, so it is hidden and a real button stands in front of it. The name of the
   chosen file sits beside the button, where the native control would have put it. */
.file-pick { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }

.file-pick__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--t-ui);
    color: var(--text-mid);
}

/* ---------- documents on a record ---------------------------------------
   The file list in the associate dialog, and the view/download pair that also
   rides the grid row. Icon-only: the row is already dense, and each carries its
   name on title and aria-label. */

.doc-list { list-style: none; margin: 0; padding: 0; }

.doc-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) 0;
    border-bottom: 1px solid var(--border);
}

.doc-item:last-child { border-bottom: 0; }

.doc-item__text { min-width: 0; flex: 1 1 auto; }

.doc-item__title,
.doc-item__meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.doc-item__title { font-size: var(--t-ui); font-weight: var(--w-medium); color: var(--text); }

.doc-item__meta {
    font-size: var(--t-sm);
    color: var(--text-mid);
    font-variant-numeric: tabular-nums;
}

.doc-list__note {
    padding: var(--s-3) 0;
    font-size: var(--t-ui);
    color: var(--text-mid);
}

.doc-actions { display: inline-flex; align-items: center; gap: var(--s-1); flex: none; }

/* As with .btn, the display above would otherwise beat the hidden attribute — the
   dialog hides this pair on a document that has no file yet. */
.doc-actions[hidden] { display: none; }

/* Square like .icon-btn, but an anchor - the browser does the fetching. */
.doc-btn {
    display: inline-grid;
    place-items: center;
    width: var(--s-5);
    height: var(--s-5);
    border-radius: var(--r);
    color: var(--text-mid);
    text-decoration: none;
}

.doc-btn:hover { background: var(--bg); color: var(--text); }

.doc-count { font-size: var(--t-sm); color: var(--text-mid); font-variant-numeric: tabular-nums; }

.doc-none { color: var(--text-dim); }

/* A row the record no longer holds as a live document — expired, cancelled, retired. Set
   back to secondary ink so the live rows read first; still a full row, in its place in the
   list, because it is still the record. */
.grid tr.is-muted td { color: var(--text-dim); }
.grid tr.is-muted .cell-strong { color: var(--text-mid); font-weight: var(--w-normal); }

/* The expiry date, coloured by the calendar. This is where the warning lives: the
   Status column carries what somebody recorded, and the two are allowed to disagree —
   legacy holds documents marked Active whose date has passed, and marking one Expired
   is a person's decision, not the screen's. */
.cell-expiry.is-near { color: var(--warn); }
.cell-expiry.is-past { color: var(--danger); }
.grid tr.is-muted .cell-expiry { color: inherit; }

/* The empty state for a file list. Matches .grid-empty's voice - a quiet line in
   place of the rows, not a bordered panel announcing that nothing is there. */
.doc-empty {
    padding: var(--s-3) 0;
    color: var(--text-dim);
    font-size: var(--t-sm);
}

/* ---------- alerts / toasts --------------------------------------------- */

.alert {
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r);
    font-size: var(--t-ui);
    margin-bottom: var(--s-4);
    border: 1px solid transparent;
}

.alert--error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.alert--ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }

/* Something to read before acting rather than something that went wrong - the employee's
   objection on a rejected salary slip. Completes the pair the --warn tokens already had. */
.alert--warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.alert:empty { display: none; }

/* Said as a toast instead (site.js), so the copy in the page is put away. */
.alert[data-toasted] { display: none; }

/* Bottom right, out of the way of the form and the tabs, and made impossible to miss by
   size and colour instead of by position: 16px semibold with a 24px glyph on a solid ground
   that says what kind of message it is - green for a confirmation, red for an error, amber
   for a warning, ink for a plain notice. Held for five seconds, eight for a warning or an
   error, or until clicked. */
.toast-host {
    position: fixed;
    width: min(420px, calc(100vw - var(--s-5)));
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    z-index: 1100;
    pointer-events: none;

    /* It is a popover (site.js), and the browser gives a popover a box of its own: centred,
       bordered, padded, clipped. None of it wanted. */
    inset: auto;
    right: var(--s-4);
    bottom: var(--s-4);
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
    height: auto;
}

.toast {
    pointer-events: auto;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    background: var(--text);
    color: var(--surface);
    border: 1px solid var(--text);
    padding: var(--s-4);
    border-radius: var(--r);
    font-size: 16px;
    font-weight: var(--w-semi);
    line-height: 1.35;
    animation: toast-in .2s ease-out;
}

.toast--ok { background: var(--ok); border-color: var(--ok); }
.toast--error { background: var(--danger); border-color: var(--danger); }
.toast--warn { background: var(--warn); border-color: var(--warn); }

.toast__icon { flex: none; width: 24px; height: 24px; }
.toast__text { min-width: 0; overflow-wrap: anywhere; }

@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } }

/* ---------- unsaved changes ---------------------------------------------- */

/* Stays up for as long as the screen on show holds edits that have not been saved. A border
   not a shadow.

   Centred in the app bar, over it: below the bar it sat behind the tab strip, which draws
   at 1010, and was cut off. The bar has room in the middle between the logo and the search
   on a desktop. A phone's bar has none, so there it drops under the bar and above the tabs
   instead. */
.unsaved-note {
    position: fixed;
    top: var(--s-2);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1035;
    max-width: calc(100vw - var(--s-5));
    padding: var(--s-2) var(--s-4);
    background: var(--warn-bg);
    color: var(--warn);
    border: 1px solid var(--warn);
    border-radius: var(--r);
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    pointer-events: none;
}

.unsaved-note[hidden] { display: none; }

@media (max-width: 900px) {
    .unsaved-note { top: calc(var(--bar-h) + var(--s-2)); }
}

/* ---------- notice (access denied, error) ------------------------------- */

.notice {
    max-width: 520px;
    margin: var(--s-7) auto;
    text-align: center;
}

.notice .card__body { padding: var(--s-6) var(--s-5); }
.notice .btn { margin-top: var(--s-4); }
.notice code {
    font-size: var(--t-sm);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 2px var(--s-1);
}

/* ---------- sign-in -----------------------------------------------------
   One card, centred, on a tinted page. The reference for this carries a teal
   gradient, a glow around the card, underline-only fields with icons standing
   in for labels, and a decorative circle over the title — a gradient, a shadow,
   a control with no visible boundary and a circle behind an icon, so none of
   them come across. What does: the centred composition, the identity mark over
   a centred title, and one full-width action closing the card.

   The tint on the page is the colour asked for, and it lands here rather than
   on a panel: the card keeps --surface, so every control still sits on the
   ground the whole app gives controls. */

.signin {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--s-5);
    background: var(--accent-bg);
}

/* The frame's two edges and its band take 26px off this before the card's own
   padding starts, which is what the card actually gets. */
.signin__stack { width: min(400px, 100%); }

/* The frame the reference draws around its card, in this palette: a band of
   surface with the accent's edge on the outside, holding the card inside it. */
.signin__frame {
    background: var(--surface);
    border: 1px solid var(--accent-border);
    border-radius: var(--r);
    padding: var(--s-3);
}

/* --bg rather than --surface: the card sits a shade off the white band around
   it, which is what separates the two. It also puts the fields back in the
   relationship they have everywhere else in the app — a --surface control on
   a --bg ground. */
.signin__panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: var(--s-6);
}

/* The card's head is the wordmark alone — the h1 is still there, carried
   visually-hidden, so the page keeps a heading for anyone not looking at it. */
.signin__head {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: var(--s-5);
}

/* align-items above stops the stretch a flex item takes on the cross axis —
   width:auto alone let the column blow the wordmark up to full width. */
.signin__logo {
    height: 20px;
    width: auto;
}

/* One column, one rhythm: the fields 16px apart, the button a step further out
   at 24px so the action reads as separate from what it acts on. Narrower than
   the card and centred in it, so the card's padding is not the only thing
   holding the form off its edges. */
.signin__form {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    width: min(280px, 100%);
    margin-inline: auto;
}

.signin__submit { width: 100%; margin-top: var(--s-2); }

.signin__note {
    width: min(280px, 100%);
    margin: 0 auto var(--s-4);
    color: var(--text-mid);
    font-size: var(--t-sm);
}

.signin__legal {
    color: var(--text-dim);
    font-size: var(--t-sm);
    text-align: center;
    margin: var(--s-5) 0 0;
}

/* An input with something parked at its edges — a mark on the left, the reveal
   on the right. Each covers padding the input reserves for it, so typed text
   never runs underneath. */
.input-affix { position: relative; display: flex; }

/* The [type] is there to win: `.field input[type="email"]` sets padding for
   every input in a field, and without matching that weight the reserved space
   never lands and the text runs straight under the icon. */
.field .input-affix > input[type] { padding-left: var(--s-6); }

/* Only where there is actually a button to clear — an email input should not
   give up 32px of its width for nothing. */
.field .input-affix:has(.input-affix__btn) > input[type] {
    padding-right: var(--s-6);
}

/* The field's mark: shown, not operated. It takes no pointer, so a click on it
   lands in the input behind it, which is what someone aiming there wants. */
.input-affix__icon {
    position: absolute;
    left: 0;
    top: 0;
    display: grid;
    place-items: center;
    width: var(--control-h);
    height: var(--control-h);
    color: var(--text-dim);
    pointer-events: none;
}

.input-affix__btn {
    position: absolute;
    right: 0;
    top: 0;
    display: grid;
    place-items: center;
    width: var(--control-h);
    height: var(--control-h);
    padding: 0;
    border: 0;
    border-radius: var(--r);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
}

.input-affix__btn:hover { color: var(--text-mid); }

/* Inset: the ring belongs inside the input's own border, not around it. */
.input-affix__btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Browsers repaint an autofilled field in their own yellow, dropping both the
   surface and the text colour. An inset fill is the only thing that overrides
   it — a spread of colour inside the border, not a shadow anyone can see. */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    box-shadow: 0 0 0 100px var(--surface) inset;
}

/* ---------- the audit trail ----------------------------------------------
 *
 * Two screens: a grid of people, and one person's timeline.
 *
 * The timeline is the only component in the app with a vertical rule running through it,
 * and that rule is doing the work a card or a coloured chip would otherwise be asked to
 * do. Three parts make an event legible without any of them: a fixed-width time column, so
 * every entry's text begins on the same line; the 1px rule beside it, which is what turns
 * a list into a sequence; and a 7px marker on the rule, whose fill says what sort of act
 * it was. Everything else is type.
 *
 * No colour carries meaning on its own here. The verb is a word on every row, and the one
 * place a hue appears - a refused attempt - is paired with that word, so the entry still
 * reads in a screenshot, in print, and to somebody who cannot tell the two apart.
 */

/* The dot beside a name on the grid: this person is signed in now. Hollow rather than
   filled so it reads as a state and not as an unread badge, and --ok because "here" is
   the one thing on this screen that is simply good news. */
.tl-live {
    display: inline-block;
    width: 7px;
    height: 7px;
    border: 1.5px solid var(--ok);
    border-radius: var(--r-full);
    vertical-align: middle;
    margin-left: var(--s-1);
}

.tl-when { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* An account with no history at all. --text-dim is permitted here: it is the placeholder
   case, which is where WCAG exempts it. */
.tl-never { color: var(--text-dim); }

.grid--activity col:nth-child(2) { width: 22%; }
.grid--activity col:nth-child(3) { width: 10%; }
.grid--activity col:nth-child(4) { width: 10%; }

.grid--activity td.num,
.grid--activity th.num { text-align: right; font-variant-numeric: tabular-nums; }

/*
 * The timeline runs the full height of its content and the page scrolls, rather than the
 * list scrolling inside a box of its own.
 *
 * It had a max-height and its own scrollbar, which was wrong twice over: it showed two
 * entries on a laptop, and a pane that scrolls inside a page that also scrolls gives the
 * reader two scrollbars and no idea which one they are using. The day heading below stays
 * useful through a long scroll by sticking to the viewport instead.
 */
.timeline-wrap { border-top: 1px solid var(--border); }

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline__empty,
.timeline__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    padding: var(--s-6);
    color: var(--text-mid);
    font-size: var(--t-ui);
}

/*
 * The date. Sticky, so it names the day while that day's entries scroll past - the one
 * thing a reader loses first in a long trail.
 *
 * --tl-sticky-top is measured and set by the page script: the app bar is fixed and the tab
 * strip is sticky under it, so a heading pinned at 0 would slide beneath both, and neither
 * height is knowable here - the strip is not even present on a lone tab. The fallback is
 * the bar alone, which is correct for exactly that case.
 */
.timeline__day {
    position: sticky;
    top: var(--tl-sticky-top, var(--bar-h));
    z-index: 2;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: var(--s-4) var(--s-4) var(--s-2);
}

/* The first day heading sits against the toolbar's own rule, so it does not need a second
   one above it. */
.timeline > .timeline__day:first-child { padding-top: var(--s-3); }

.timeline__day h2 {
    margin: 0;
    font-size: var(--t-ui);
    font-weight: var(--w-semi);
    color: var(--text);
    letter-spacing: var(--tracking-tight);
}

/*
 * The visit band - the login-to-logout bracket.
 *
 * On --bg rather than in a box: it is a caption over the entries beneath it, not an object
 * of its own, and a bordered card here would compete with the rule the entries hang on.
 */
.tl-visit {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-4);
    background: var(--bg);

    /* Closed on both edges. With the rows carrying no borders of their own, this is what
       separates one visit's entries from the next - and the rule down the middle stops
       here too, which is the break being said twice in agreement. */
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-size: var(--t-sm);
    color: var(--text-mid);
}

/* Against the day heading above it there is already a rule; a second would double it. */
.timeline__day + .tl-visit { border-top: 0; }

.tl-visit__text { font-variant-numeric: tabular-nums; }

/* Events belonging to no recorded visit. Italic rather than dimmer: it is a caveat about
   the data, and it still has to be readable. */
.tl-visit--none .tl-visit__text { font-style: italic; }

/* "Only this visit". A quiet text button - no border, no background, because the band it
   sits in is already quiet and a second control there would shout. */
.tl-visit__only {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--accent);
    cursor: pointer;
}

.tl-visit__only:hover { text-decoration: underline; }

.tl-visit__only:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r);
}

/* The browser string, available on hover and otherwise out of the way. */
.tl-visit__agent {
    margin-left: auto;
    color: var(--text-dim);
    cursor: help;
    border-bottom: 1px dotted var(--border-control);
}

/*
 * One act.
 *
 * Three columns: the time, the rule with its marker, and the body.
 *
 * The time column is wide enough for a 12-hour clock with its meridiem - "06:27 PM" - and
 * right-aligned so the times stack digit under digit. It was 56px, which a locale rendering
 * AM/PM overflowed straight into the marker beside it.
 *
 * No row borders. A timeline is not a table: the rule down the middle and the spacing
 * between entries already separate them, and a divider per row would cut that rule into
 * forty pieces.
 */
.tl {
    position: relative;
    display: grid;
    grid-template-columns: 72px 16px 1fr;
    align-items: start;
    gap: 0 var(--s-2);
    padding: var(--s-3) var(--s-4);
}

.tl:hover { background: var(--bg); }

.tl__time {
    text-align: right;
    padding-right: var(--s-1);
    font-size: var(--t-sm);
    font-variant-numeric: tabular-nums;
    color: var(--text-mid);
    white-space: nowrap;

    /* Sits on the first line of the body beside it, whose line-height is the UI size. */
    line-height: 1.5;
}

.tl__mark { position: relative; }

/*
 * The rule.
 *
 * Drawn as a pseudo-element stretched past the row's own padding, rather than as a border
 * on the marker column. A border would stop at the grid area's edges and leave a gap at
 * every row boundary, so the "line" would be a dashed column of stubs.
 */
.tl__mark::before {
    content: "";
    position: absolute;
    left: 0;
    top: calc(-1 * var(--s-3));
    bottom: calc(-1 * var(--s-3));
    border-left: 1px solid var(--border);
}

/* The marker, centred on that rule. 7px, on --surface so the rule does not show through. */
.tl__mark::after {
    content: "";
    position: absolute;
    left: -4px;
    top: 5px;
    width: 7px;
    height: 7px;
    border-radius: var(--r-full);
    background: var(--surface);
    border: 1.5px solid var(--text-dim);
}

/* A change: solid, because it is the act that altered something. */
.tl[data-kind="change"] .tl__mark::after {
    background: var(--text-mid);
    border-color: var(--text-mid);
}

/* A read leaves the marker hollow - nothing was altered - but darkens its ring so it is
   not mistaken for the default. */
.tl[data-kind="read"] .tl__mark::after,
.tl[data-kind="attachment"] .tl__mark::after,
.tl[data-kind="password"] .tl__mark::after { border-color: var(--text-mid); }

/* Arriving and leaving. The darkest marker on the list: these are the two events that
   bracket everything else. */
.tl[data-kind="session"] .tl__mark::after {
    background: var(--text);
    border-color: var(--text);
}

/* A refused or failed attempt. The one hue on the timeline, and it never travels alone -
   the verb beside it says "Refused" in words. */
.tl[data-outcome="refused"] .tl__mark::after {
    background: var(--danger);
    border-color: var(--danger);
}

.tl__body { min-width: 0; }

/*
 * The record the event names, made reachable.
 *
 * A link, in the one colour that means it - this is one of the four places the accent is
 * allowed. Only the record's name carries it, not the whole sentence, so the line still
 * reads as prose and the part that leads somewhere is the part that looks as though it
 * does.
 */
.tl__target { color: var(--accent); text-decoration: none; }
.tl__target:hover { text-decoration: underline; }

.tl__target:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r);
}

/* "History" beside an entry's sentence: a quiet text button in the link colour, like "Only
   this visit" - it opens something rather than going somewhere, so it is not a link. */
.tl__history {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    margin-left: var(--s-1);
    font: inherit;
    font-size: var(--t-sm);
    color: var(--accent);
    cursor: pointer;
}

.tl__history:hover { text-decoration: underline; }

.tl__history:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r);
}

/* Leaves the workspace - a file opens in a browser tab, because the workspace cannot hold
   a PDF. Dim and small: it qualifies the link without competing with it. */
.tl__out { font-size: var(--t-label); color: var(--text-dim); }

.tl__line {
    margin: 0;
    font-size: var(--t-ui);
    color: var(--text);
    line-height: 1.5;
}

/* The verb. Not a badge: a pill per row would put forty pills on the screen and make the
   list read as a wall of chips. Caps and letter-spacing at the label size do the same job
   with none of the furniture. */
.tl__verb {
    font-size: var(--t-label);
    font-weight: var(--w-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    margin-right: var(--s-1);
}

.tl[data-outcome="refused"] .tl__verb { color: var(--danger); }

.tl__detail,
.tl__meta {
    margin: var(--s-1) 0 0;
    font-size: var(--t-sm);
    color: var(--text-mid);
}

/* The request behind the act. Dim and small: it is there to be found, not read. */
.tl__meta {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

/*
 * What the fields used to say, and what they say now.
 *
 * A two-column grid rather than a table: it is a handful of pairs under one event, and a
 * table would bring a header nobody needs and borders that fight the timeline's own rule.
 * The label column is fixed so several events' diffs line up as the eye runs down them.
 */
.tl__diff {
    display: grid;
    grid-template-columns: minmax(0, 140px) minmax(0, 1fr);
    gap: var(--s-1) var(--s-3);
    margin: var(--s-2) 0 0;
    padding: var(--s-2) var(--s-3);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-size: var(--t-sm);
}

/* Each pair is a div wrapping its dt/dd - the only way to keep a dl valid while laying it
   out as a grid, so the two halves of the grid are addressed through it. */
.tl__diff > div { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; }

.tl__diff dt {
    color: var(--text-mid);
    overflow-wrap: anywhere;
}

.tl__diff dd {
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: var(--s-2);
    flex-wrap: wrap;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

/* The old value is dimmed and the new one is not, so the eye lands on what the field says
   now and reads what it said before second - the order the question is asked in. Not
   struck through: a strikethrough on a passport number makes it unreadable, and the value
   is the thing somebody came here for. */
.tl__was { color: var(--text-mid); overflow-wrap: anywhere; }
.tl__now { color: var(--text); font-weight: var(--w-medium); overflow-wrap: anywhere; }
.tl__to { color: var(--text-dim); flex: none; }

/* An em dash for a field that was empty, or has been cleared. Dim, and labelled for a
   screen reader by the markup that writes it. */
.tl-empty { color: var(--text-dim); }

@media (max-width: 900px) {
    /* The time moves above the body and the rule goes: at this width the three columns
       leave the diff too narrow to read, and the day heading is already carrying the
       chronology. */
    .tl {
        grid-template-columns: 1fr;
        gap: var(--s-1);
    }

    .tl__time { text-align: left; padding-right: 0; }
    .tl__mark { display: none; }

    .tl__diff { grid-template-columns: 1fr; }
    .tl__diff > div { grid-template-columns: 1fr; }
    .tl__diff dt { font-weight: var(--w-medium); }
}

/* ---------- a record's history ------------------------------------------
   The audit trail read the other way round: every act on one record, in a sheet. It draws the
   same rows the per-person timeline does (.tl above) - the difference is that each one has to
   say who did it, which on a person's own timeline would be repeated on every line. */

.history__heading { display: flex; align-items: baseline; gap: var(--s-2); min-width: 0; }

.history__heading .sheet__title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history__count { flex: none; color: var(--text-mid); font-size: var(--t-sm); }

.history__filter { padding: var(--s-2) var(--s-4); border-bottom: 1px solid var(--border); }

/* The rows run edge to edge, as they do on the timeline; the sheet's own padding would
   inset them from the day headings. */
.history__body { padding: 0; }

.history__body .alert { margin: var(--s-3) var(--s-4); }

.history__list { list-style: none; margin: 0; padding: 0; }

/* A day, held at the top of the scroller while its events pass under it - the same device
   the person's timeline uses, for the same reason: a long list is read by day. */
.history__day {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: var(--s-2) var(--s-4);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: var(--t-label);
    font-weight: var(--w-medium);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-mid);
}

/* Who did it. Not dimmed to --text-dim the way the timeline's request line is: on this list it
   is the answer to the question, not a footnote. */
.history__who { margin: var(--s-1) 0 0; font-size: var(--t-sm); color: var(--text-mid); }

.history__empty { margin: 0; padding: var(--s-5) var(--s-4); text-align: center; color: var(--text-mid); }

.history__more { margin-right: auto; }

/* ---------- responsive shell -------------------------------------------- */

/* Below 1280px the rail collapses off-canvas rather than eating grid width. */
@media (max-width: 900px) {
    .rail { transform: translateX(-100%); border-right: 1px solid var(--border); }
    body[data-rail="open"] .rail { transform: none; width: var(--rail-w); }
    body[data-rail="open"] .rail__label { display: block; }
    .app-content { margin-left: 0 !important; }
    /* With the search gone, the avatar has to hold the right edge itself. */
    .app-bar__search { display: none; }
    .app-bar__right { margin-left: auto; }

    /* minmax(0, ...) and not 1fr: a bare 1fr is "at least as wide as the widest thing in it",
       so one date box or file picker pushed the whole column - and every field with it -
       past the dialog's right edge. */
    .form-grid { grid-template-columns: minmax(0, 1fr); }

    /* A grid that fits a desktop does not fit a phone: its columns were being squeezed to
       "Mohamm..." and the last column - the buttons - was cut off the edge with nothing to
       reach it by. On a phone the table keeps a readable width and the box around it scrolls
       sideways. */
    .grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .grid-wrap > table.grid { min-width: 720px; }

    /* The rights matrix is up to six 96px columns beside a resource name - wider than a
       phone, with Delete and Export falling off the right edge. It scrolls inside its own
       box instead, with the columns a little narrower. */
    .right-matrix { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .grid--rights { min-width: 480px; }
    .grid--rights .right-matrix__action { width: 72px; }

    /* The scope ("All records", "Granted companies") under the resource name rather than
       wrapped beside it, where it ran into the tick box. */
    .right-matrix__scope { display: block; margin-left: 0; }

    /* A search box that insists on 260px is wider than a phone's toolbar; let it take the
       row instead. */
    .field-search { min-width: 0; flex: 1 1 100%; }

    /* A field that asked for the second column of a two-column form must not pull one into
       existence here: it drew a second, squeezed track beside the first, so the labels broke
       a letter to a line and the file pickers read "Choose F". One field to a row. */
    .field--col1,
    .field--col2,
    .asset-flags,
    .asset-flags--start { grid-column: 1 / -1; }

    /* One column, and nothing may claim two — a span of 2 here would spill into
       an implicit column the grid never drew. */
    .record-grid { --cols: 1; --field-cols: 1; }
    .record-grid > .record-grid__pair { grid-column: 1 / -1; }
    .record-grid > .record-grid__lead { grid-column: 1 / -1; }
    .lookup-layout > .card + .card { border-left-width: 0; border-top-width: 1px; }

    /* Off-canvas: there is no shared edge left to drag. */
    .rail__resizer { display: none; }
}

.scrim {
    display: none;
    position: fixed;
    inset: var(--bar-h) 0 0 0;
    background: var(--scrim);
    z-index: 1010;
}

@media (max-width: 900px) {
    body[data-rail="open"] .scrim { display: block; }
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---- System: the unlinked administration index (/System) ------------------- */

.rail__link[hidden] { display: none; }

/* The heading the tab strip would give it, if there were more than one tab: the strip hides
   for a single tab, so the page names itself. */
.system-head {
    padding: var(--s-5) var(--s-5) var(--s-4);
    border-bottom: 1px solid var(--border);
}

.system-head__title {
    margin: 0;
    font-size: var(--t-title);
    font-weight: var(--w-semi);
    letter-spacing: -0.011em;
    color: var(--text);
}

.system-head__sub {
    margin: var(--s-1) 0 0;
    font-size: var(--t-ui);
    color: var(--text-mid);
}

.system-list { list-style: none; margin: 0; padding: 0; }

/* A row is a glyph, a title over its description, and a mark on the right saying it goes
   somewhere. The glyph carries the destination's hue from the navigation palette and
   nothing sits behind it; the row itself only changes on hover, as a table row does. */
.system-list__row {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: 56px;
    padding: var(--s-3) var(--s-5);
    border-bottom: 1px solid var(--border);
}

.system-list__row:last-child { border-bottom: 0; }

.system-list__row:hover { background: var(--bg); }

/* The keyboard ring rides on the row, since the link inside it covers the whole row. */
.system-list__row:has(.system-list__link:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.system-list__icon { flex: none; color: var(--nav-accent, var(--text-dim)); }

.system-list__text {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    min-width: 0;
    flex: 1;
}

.system-list__link {
    font-size: var(--t-body);
    font-weight: var(--w-medium);
    color: var(--text);
    text-decoration: none;
}

.system-list__link:hover { text-decoration: underline; }

/* Stretched over the row, so the whole row is the target and not only its title. */
.system-list__link::after { content: ""; position: absolute; inset: 0; }

.system-list__link:focus-visible { outline: none; }

.system-list__note { font-size: var(--t-ui); color: var(--text-mid); }

.system-list__go { flex: none; color: var(--text-dim); }

/* ---- App bar: my tickets and my actions --------------------------------------- */

.work-menu { position: relative; }

.work-menu__btn { position: relative; }

/* The count, sitting on the icon's corner. A status badge, so it is the one pill-shaped
   thing here: --text-mid with white while all is well, --danger when anything is overdue. */
.work-menu__badge {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 var(--s-1);
    border-radius: var(--r-full);
    background: var(--text-mid);
    color: var(--surface);
    font-size: var(--t-label);
    font-weight: var(--w-medium);
    line-height: 16px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.work-menu__badge[hidden] { display: none; }

.work-menu__badge--alert { background: var(--danger); }

/* An object standing over the page, like the user menu: the cool face and the heavier edge. */
.work-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + var(--s-2));
    width: 400px;
    max-width: calc(100vw - var(--s-4));
    background: var(--surface-cool);
    color: var(--text);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    display: none;
    z-index: 30;
}

.work-menu__panel[data-open="true"] { display: block; }

/* The panels hang off their own icon, which is mid-bar on a phone - so a 400px panel anchored
   to its right edge ran off the left of the screen. Pinned to the screen instead, edge to edge
   under the bar, and as tall as the screen leaves, scrolling inside.

   Here, after the panel's own rule, and not in the responsive block further up: equal
   specificity goes to whichever comes last, and from up there this lost to it. */
@media (max-width: 900px) {
    .work-menu__panel {
        position: fixed;
        left: var(--s-2);
        right: var(--s-2);
        top: calc(var(--bar-h) + var(--s-1));
        width: auto;
        max-width: none;
        max-height: calc(100vh - var(--bar-h) - var(--s-4));
        overflow-y: auto;
    }
}

.work-menu__head {
    display: flex;
    align-items: baseline;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border);
}

.work-menu__title { font-size: var(--t-body); font-weight: var(--w-semi); }

.work-menu__total { font-size: var(--t-sm); color: var(--text-mid); }

.work-menu__more { margin-left: auto; font-size: var(--t-ui); }

.work-menu__tally {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-4);
    border-bottom: 1px solid var(--border);
}

.work-menu__quiet { font-size: var(--t-ui); color: var(--text-mid); }

.work-menu__list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }

.work-menu__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--s-1) var(--s-3);
    padding: var(--s-2) var(--s-4);
    color: var(--text);
    text-decoration: none;
    font-size: var(--t-ui);
}

.work-menu__row:hover { background: var(--bg); }

.work-menu__what {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.work-menu__who {
    grid-column: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-mid);
    font-size: var(--t-sm);
}

/* The due pill takes the right-hand column across both lines of its row. */
.work-menu__row .pill { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

.work-menu__empty { padding: var(--s-3) var(--s-4); font-size: var(--t-ui); color: var(--text-mid); }

/* A notification is a sentence, not a ticket title: let it wrap rather than cut it off. */
[data-notify-menu] .work-menu__who { white-space: normal; overflow: visible; }

/* ---- Home: the team's work ------------------------------------------------------ */

/* The ticket stats and the rose, beside the people they draw. */
.team-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-3);
    align-items: stretch;
}

/* Each chart sits in a tinted panel of its own: a cool grey that reads against the white
   card, one border, no title (a hidden heading names it for a screen reader). Flat - no shadow, no
   gradient. The panels stretch to the taller of the two, so the pair is always one height. */
.team-chart {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    min-width: 0;
    padding: var(--s-3);
    background: var(--panel);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
}

/* The title is the first line of the panel, flush left. */
.team-chart__title {
    margin: 0;
    text-align: left;
    font-size: var(--t-body);
    font-weight: var(--w-semi);
    letter-spacing: -0.011em;
    color: var(--text);
}

/* A fixed height, so both charts are the same size and start at the top of their panels;
   whatever height the taller panel leaves over is left empty rather than given to a chart. */
.team-rose { flex: none; height: 260px; min-width: 0; }

.team-rose[hidden] { display: none; }

/* The legend and the people list sit inside the chart area, in its bottom-right corner,
   right-aligned and small: they name the slices without taking a row of their own. */
.team-chart { position: relative; }

.team-chart .team-legend,
.team-chart .team-load {
    position: absolute;
    right: var(--s-3);
    bottom: var(--s-3);
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--s-1);
    font-size: var(--t-label);
    font-variant-numeric: tabular-nums;
}

.team-legend li,
.team-person {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    color: var(--text-mid);
    line-height: 1.3;
}

.team-legend strong,
.team-person__open { color: var(--text); font-weight: var(--w-semi); }

/* The slice's colour: a short bar beside its words. */
.team-swatch { flex: none; width: var(--s-1); height: var(--s-3); border-radius: var(--r); background: var(--swatch, var(--border-control)); }

.team-person__name { font-weight: var(--w-medium); color: var(--text); white-space: nowrap; }

.team-person__over.is-late { color: var(--danger); font-weight: var(--w-medium); }

.team-empty { font-size: var(--t-ui); color: var(--text-mid); }
@media (max-width: 900px) {
    /* The rose stacks over the list rather than being squeezed beside it. */
    .team-body { grid-template-columns: minmax(0, 1fr); }
}

/* The work panels sit above the renewals, in the same two-column grid. */
.dash--work { margin-bottom: var(--s-4); }

/* What is overdue, due today and coming, as pills in a row above the rows they count. */
.dash__tally {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2);
    min-height: 44px;
    padding: var(--s-2) var(--s-4);
    border-bottom: 1px solid var(--border);
}


.system-list__row:hover .system-list__go { color: var(--text-mid); }

/* ---------- search results page (/Search) ----------------------------------

   One surface: a search row across the top, the kinds that matched down the left with
   their counts, and the results beside them. Each result is a row - a glyph in its kind's
   navigation hue, the title, what else identifies it, and then the columns that held the
   search, one per line, so the reader sees why it was found. The match is marked, not
   coloured: --warn-bg behind the text, the text itself left alone. */

.finder { display: flex; flex-direction: column; min-height: 100%; background: var(--surface); }

.finder__bar {
    position: relative;
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--border);
}

.finder__icon {
    position: absolute;
    top: 50%;
    left: calc(var(--s-5) + var(--s-3));
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

.finder__input {
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--s-3) 0 calc(var(--s-3) + 16px + var(--s-2));
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    background: var(--surface);
    font: inherit;
    font-size: var(--t-ui);
    color: var(--text);
}

.finder__input::placeholder { color: var(--text-dim); }

.finder__body { display: flex; flex: 1; align-items: flex-start; }

.finder__kinds {
    flex: 0 0 220px;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    padding: var(--s-4) var(--s-3);
    border-right: 1px solid var(--border);
}

.finder__kind {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
    height: var(--control-h);
    padding: 0 var(--s-2);
    border: 0;
    border-radius: var(--r);
    background: none;
    font: inherit;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--text-mid);
    text-align: left;
    cursor: pointer;
}

.finder__kind:hover { background: var(--bg); }
.finder__kind:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.finder__kind[aria-current="true"] {
    background: var(--accent-bg);
    color: var(--accent);
}

.finder__count {
    font-weight: var(--w-normal);
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
}

.finder__kind[aria-current="true"] .finder__count { color: inherit; }

.finder__main { flex: 1; min-width: 0; padding: var(--s-4) var(--s-5) var(--s-5); }

.finder__summary {
    margin: 0 0 var(--s-3);
    font-size: var(--t-ui);
    color: var(--text-mid);
}

.finder__summary strong { color: var(--text); font-weight: var(--w-semi); }

.finder__group + .finder__group { margin-top: var(--s-5); }

.finder__head {
    display: flex;
    align-items: baseline;
    gap: var(--s-2);
    padding-bottom: var(--s-2);
    border-bottom: 1px solid var(--border);
}

.finder__head h2 {
    margin: 0;
    font-size: var(--t-label);
    font-weight: var(--w-medium);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.finder__sub {
    font-size: var(--t-sm);
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
}

.finder__more {
    margin-left: auto;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: var(--t-ui);
    font-weight: var(--w-medium);
    color: var(--accent);
    cursor: pointer;
}

.finder__more:hover { text-decoration: underline; }

.finder__empty { margin: var(--s-5) 0; font-size: var(--t-body); color: var(--text-mid); }
.finder__empty strong { color: var(--text); }

.finder__pager {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    margin-top: var(--s-4);
}

.finder__page { font-size: var(--t-ui); color: var(--text-mid); font-variant-numeric: tabular-nums; }

/* A result. The whole row is the link. */
.hit {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-2);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.hit:hover { background: var(--bg); }
.hit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* The glyph takes its kind's hue and nothing else does: no tile, no circle behind it. */
.hit__icon { flex: 0 0 16px; margin-top: 2px; color: var(--nav-accent, var(--text-dim)); }

.hit__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s-1); }

.hit__head { display: flex; align-items: baseline; gap: var(--s-2); }

.hit__title {
    font-size: var(--t-body);
    font-weight: var(--w-semi);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hit__kind {
    margin-left: auto;
    padding-left: var(--s-3);
    font-size: var(--t-label);
    font-weight: var(--w-medium);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
    white-space: nowrap;
}

.hit__sub { font-size: var(--t-ui); color: var(--text-mid); }

.hit__matches { list-style: none; margin: var(--s-1) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }

.hit__match { display: flex; gap: var(--s-3); font-size: var(--t-ui); }

.hit__label {
    flex: 0 0 132px;
    font-size: var(--t-sm);
    color: var(--text-dim);
}

.hit__text { min-width: 0; color: var(--text-mid); overflow-wrap: anywhere; }

.finder mark {
    padding: 0 1px;
    background: var(--warn-bg);
    color: var(--text);
    font-weight: var(--w-medium);
}

@media (max-width: 900px) {
    .finder__body { flex-direction: column; }

    .finder__kinds {
        position: static;
        flex: none;
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
        padding: var(--s-2) var(--s-4);
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .finder__kind { flex: none; }
    .finder__main { width: 100%; padding: var(--s-3) var(--s-4) var(--s-4); }
    .hit__match { flex-direction: column; gap: 0; }
    .hit__label { flex-basis: auto; }
}

/* ---------- all-assets list (/Assets) ---------------------------------------

   The advanced filters sit in a panel under the toolbar, grouped: the asset's own columns,
   then the chosen type's fields. What is set shows as a row of removable chips whether the
   panel is open or not, so the list never filters silently. */

.afilters {
    padding: var(--s-4);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.afilters__group + .afilters__group { margin-top: var(--s-4); }

.afilters__title {
    margin: 0 0 var(--s-2);
    font-size: var(--t-label);
    font-weight: var(--w-medium);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.afilters__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--s-3) var(--s-4);
}

.afilters__grid .field--span2 { grid-column: span 2; }

.afilters__pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }

.afilters__foot { display: flex; justify-content: flex-end; margin-top: var(--s-3); }

.chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-4);
    border-bottom: 1px solid var(--border);
}

.chips[hidden] { display: none; }

/* A chip is a state, not an action: a bordered label with its own remove button. Square
   radius like every control - pill radius is for status badges only. */
.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    height: 24px;
    padding: 0 var(--s-1) 0 var(--s-2);
    border: 1px solid var(--border-control);
    border-radius: var(--r);
    background: var(--surface);
    font-size: var(--t-sm);
    color: var(--text);
}

.chip__x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: 0;
    border-radius: var(--r);
    background: none;
    color: var(--text-mid);
    cursor: pointer;
}

.chip__x:hover { background: var(--bg); color: var(--text); }
.chip__x:focus-visible { outline: 2px solid var(--accent); }

.chips__clear {
    padding: 0 var(--s-1);
    border: 0;
    background: none;
    font: inherit;
    font-size: var(--t-sm);
    color: var(--accent);
    cursor: pointer;
}

.chips__clear:hover { text-decoration: underline; }

.grid--assets-all tbody tr[data-url] { cursor: pointer; }

.cell-asset__name { font-weight: var(--w-medium); }

.cell-asset__owner { display: block; }

.cell-asset__kind {
    display: block;
    font-size: var(--t-sm);
    color: var(--text-dim);
}
