/* Root
---------------- */

:root {
    /* Colors  */
    --white: #fff;
    --dark: #151d27;

    --text-lt: #a9aeb4;
    --text-lt-2: #8e949c;

    --blue: #3f8dee;
    --blue-lt: #a7d0ef;

    --gray: #ced4da;
    --gray-2: #dde1e5;
    --gray-3: #eff1f6;
    --gray-4: #e6e8ee;
    --gray-5: #c0c5cf;
    --gray-6: #a3acbd;
    --gray-7: #8591a8;
    --gray-8: #f7f8fa;

    --warning: #f59d59;
    --danger: #ee493f;
    --primary: #1a477f;
    --success: #6ac567;

    --danger-lt: #f6a29c;
    --success-lt: #b2e1b0;

    /* Edges

    The page is drawn edge to edge, so it owns its own margins. --gutter is
    the ordinary side margin, and --clear is what sits between the camera
    housing and the first thing in the page, on top of the band iOS already
    reserves - measured on the notch, where the logo lands closest */
    --gutter: 12px;
    --clear: 2px;

    /* Roles

    Each hue exists at two stops: a fill stop (above), which is what the hue
    looks like as a ground, and an ink stop (below), which is the same hue
    darkened until it carries as text or as an icon. Nothing that has to be
    read uses a fill stop */

    /* Surfaces */
    --surface: var(--white);
    --surface-2: var(--gray-3);
    --surface-3: var(--gray-4);
    --surface-4: var(--gray-8);

    /* Text, in three tiers - the third is the floor, and nothing goes under */
    --text: var(--dark);
    --text-2: #475166;
    --text-3: #626d83;

    /* A minor control, e.g., the edit pencil at the end of a row */
    --control: #7c8495;
    --control-hover: #515b71;

    /* What can be followed or acted on */
    --action: #196cca;
    --action-fill: var(--blue);

    /* What a record's state is - each has an ink stop and a fill stop, and
       neither is ever spent on something that is not reporting state */
    --overdue: #d02925;
    --overdue-fill: color-mix(in srgb, var(--danger) 90%, black);
    --soon: #a85700;
    --soon-fill: color-mix(in srgb, var(--warning) 75%, black);
    --settled: var(--success);

    /* The quiet fill, i.e., a call to action that only opens a form */
    --quiet-fill: #6a758c;

    /* Borders, softest to firmest */
    --border-soft: var(--gray-2);
    --border: var(--gray);
    --border-firm: var(--gray-5);

    /* Sizes
    ---------

    --tablet (max): 991.98px;
    --small-tablet (max): 767.98px;
    --mobile (max): 575.98px;

    */
}

html, body {
    font-family: 'Inter', sans-serif;
    caret-color: var(--action);
    accent-color: var(--action);
    scrollbar-color: var(--border-firm) transparent;
    font-feature-settings: 'calt', 'dlig', 'ss01', 'ss02', 'ss03';
    -webkit-font-smoothing: antialiased;
    background: var(--white);

    @supports (font-variation-settings: normal) {
        font-family: InterVariable, sans-serif;
    }
}

/* The page is at least as tall as the window, with the content taking up
   whatever is left over, so that the footer sits at the bottom of a short
   page, rather than partway up it. This is a wrapper rather than the body,
   since jQuery's show() reads an element's default display from a copy of
   it added to the body - a flex body turns that into "block", e.g., for a
   table row, which then drops out of its table's columns */
.page {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;

    > .content {
        flex: 1 0 auto;
    }
}

/* Motion
---------------- */

/* A mark being made - it arrives slightly small and settles to size, once,
   with no bounce, which is as much as a ledger should ever move */
@keyframes settle {
    from {
        transform: scale(0.82);
        opacity: 0.4;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Focus
---------------- */

/* Bootstrap rings every control in its own blue, which is the one thing this
   interface is not allowed to look like - so the ring is restated here, in the
   colour that already means "you can act on this" */
:root {
    --bs-focus-ring-color: color-mix(in srgb, var(--action) 25%, transparent);
    --bs-focus-ring-width: 3px;
}

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

.btn:focus-visible,
.form-control:focus,
.form-check-input:focus {
    border-color: var(--action);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--action) 25%, transparent);
}

.form-control:focus {
    outline: none;
}

/* Utils
---------------- */

.clearfix::after {
    content: '';
    clear: both;
    display: table;
}

.none {
    display: none;
}

/* A label that is there to be read out, rather than seen, e.g., the name of a
   column whose heading is an icon */
.sr {
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    position: absolute;
    overflow: hidden;
    white-space: nowrap;
    clip-path: inset(50%);
}

/* Choices
---------------- */

.choices {
    margin-bottom: 0;

    /* An open dropdown is raised over the page, since it is drawn where the
       fields under it are - the file rows put their own filename over their
       input, and that would otherwise show through the list */
    &.is-open {
        z-index: 8;
    }

    .choices__inner {
        min-height: 0;
        padding: 4px 0px 0px 4px !important;

        .choices__list--multiple {
            .choices__item {
                border: 1px color-mix(in srgb, var(--blue) 90%, black) solid;
                line-height: inherit;
                color: var(--white);
                background: var(--blue);
                margin: 0 4px 2px 0;
            }

            .choices__button {
                margin: 0 0 0 6px;
                padding: 0 10px 0 12px;
                border-left: 1px color-mix(in srgb, var(--blue) 80%, black) dotted;
            }
        }

        .choices__list--single {
            /* As tall with nothing chosen as with something, so that an
               empty single select stands level with the inputs around it
               rather than shrinking to its padding */
            min-height: calc(1.5em + 8px);

            .choices__item {
                margin: 0 0 2px 0;
            }
        }
    }

    /* Option group headings stand apart from the options under them */
    .choices__heading {
        font-size: 13px;
        font-weight: 700;
        color: var(--dark);
        background: var(--gray-8);
        border-bottom: 1px var(--gray-2) solid;
    }

    select.choices__input {
        display: block !important;
        left: 0 !important;
        bottom: 0 !important;
        position: absolute !important;
        opacity: 0;
        pointer-events: none;
    }
}

/* Pagination
---------------- */

.pagination {
    --bs-pagination-color: var(--dark);
    --bs-pagination-hover-color: var(--dark);
    --bs-pagination-focus-color: var(--dark);
    --bs-pagination-active-bg: color-mix(in srgb, var(--blue) 90%, black);
    --bs-pagination-active-border-color: color-mix(in srgb, var(--blue) 90%, black);
}

/* Forms
---------------- */

form {
    /* A dropdown, which is only half as wide as the form - its options are
       listed as wide as the longest, whatever its own width. Not one Choices
       enhances, since its list is only as wide as the control, and the
       select is moved into the control's own markup */
    .field-group > .form-select:not([multiple]) {
        width: 50%;
        min-width: min(200px, 100%);
    }

    /* A control for a short value, e.g., a tax year or a postal code, which
       reads oddly stretched across the whole form */
    .form-control.short,
    .form-select.short:not([multiple]) {
        width: 130px;
        max-width: 100%;
    }

    /* A date or a phone number is always about as wide, so it is only as
       wide as one, wherever it is */
    .form-control[type="date"],
    .form-control[type="tel"] {
        width: 200px;
        max-width: 100%;
    }

    .field-group,
    .form-check {
        margin: 0 0 15px 0;

        .readonly {
            font-size: 0.9375rem;
        }
    }

    .invalid-feedback,
    .valid-feedback {
        margin: 0px 0 12px 0px;
        color: var(--overdue);

        .field-group & {
            margin-top: 3px;
        }

        .form-check & {
            margin-top: 7px;
        }
    }

    /* Said of a control that is right, e.g., a password confirmation that
       matches, as it is typed */
    .valid-feedback {
        color: var(--settled);
    }

    /* A set of checkboxes in groups, e.g., the permissions a role grants,
       by feature - the widget's own markup, which is a box per group with
       its name as a label over its options, each an option with its line
       of help under it */
    .checks {
        > div {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 18px 28px;

            > div {
                > label {
                    display: block;
                    margin: 0 0 6px 0;
                    padding: 0 0 4px 0;
                    border-bottom: 1px solid var(--border-soft);
                    font-size: 0.8125rem;
                    font-weight: 600;
                    letter-spacing: 0.02em;
                    text-transform: uppercase;
                }

                > div {
                    margin: 0 0 8px 0;

                    > label {
                        display: flex;
                        align-items: center;
                        gap: 8px;
                        margin: 0;
                        cursor: pointer;

                        .form-check-input {
                            flex: 0 0 auto;
                            margin: 0;
                        }
                    }

                    > .form-text {
                        margin: 1px 0 0 calc(1em + 8px);
                        line-height: 1.3;
                    }
                }
            }
        }
    }

    .form-control {
        border-radius: 4px;

        &::placeholder {
            color: var(--text);
            opacity: .35;
        }
    }

    .file-row-container {
        &:has(+ .file-row-container) {
            margin: 0 0 10px 0;
        }

        /* The native control is kept for what only it can do - take the
           click, the keyboard and the picker - and is otherwise unseen. It
           cannot be dressed: iOS draws a thumbnail of a chosen photo inside
           it, and nothing in CSS reaches that. So the face of the control
           is the filename, drawn over it below */
        [data-file] {
            opacity: 0;
            cursor: pointer;
        }

        /* Under the input in stacking terms, since the input is clear and
           shows it through - which leaves the remove button, and the input
           while it has focus, where Bootstrap's input group puts them. The
           corners and the margin are forced, because the group squares off
           and overlaps anything that is not its first child */
        .filename {
            position: absolute;
            inset: 0;
            margin: 0 !important;
            padding: 6px 12px 6px 121px;
            border: 1px var(--bs-border-color) solid;
            border-radius: 4px !important;
            overflow: hidden;
            line-height: 1.5;
            text-overflow: ellipsis;
            text-wrap: nowrap;
            background: var(--white);
            pointer-events: none;

            /* The button, which is drawn rather than the native one - the
               name is the browser's own wording for it. Placed rather than
               floated, so that it spans the whole height whatever padding
               centres the name beside it, and as wide as the name's room */
            &::before {
                content: 'Choose File';
                position: absolute;
                top: 0;
                bottom: 0;
                left: 0;
                width: 109px;
                display: flex;
                align-items: center;
                justify-content: center;
                border-right: 1px var(--bs-border-color) solid;
                background: var(--bs-tertiary-bg);
            }

            /* Once a file is in, the button only replaces it, so it shrinks
               to an icon, and gives its room to the name */
            [data-file-container]:not([data-empty]) & {
                padding-left: 52px;

                &::before {
                    content: '\f2f1';
                    width: 40px;
                    font: var(--fa-font-solid);
                }
            }

            /* The ring the covered input would have shown, see Focus */
            [data-file]:focus-visible + & {
                border-color: var(--action);
                box-shadow: 0 0 0 3px color-mix(
                    in srgb, var(--action) 25%, transparent
                );
            }

            [data-file].invalid + & {
                border-color: var(--danger);
                background: var(--danger-lt);
            }

            [data-has-verified-file] & {
                border-color: var(--success);
                background: var(--success-lt);
            }

            /* Short of the remove button, once there is one, so that a long
               name is cut off before it rather than under it */
            .file-row:has([data-remove]:not(.none)) & {
                padding-right: 50px;
            }
        }
    }

    .formset {
        margin: 0 0 15px 0;

        /* Dragging only means something where the order is read, so the
           handles are offered on a formset that says it is sorted and on no
           other - see the sortable option of jquery.formsy.js */
        &:not(.sortable) .handle {
            display: none;
        }

        .headline {
            margin: 0 0 10px 0;
            font-size: 1.2rem;
            font-weight: 500;
        }

        .inlines {
            .inline {
                margin: 0 0 15px 0;
                padding: 15px;
                border-radius: 3px;
                background: var(--gray-4);
                position: relative;

                label strong {
                    font-weight: 600;
                }

                .controls {
                    .control {
                        float: right;
                    }
                }
            }

            /* What an inline is dragged by - the rest of it is left alone,
               so its inputs still take a cursor and select text. It fills
               the corner out to both edges, taking the inline's own radius
               where it meets them, so it reads as part of the box rather
               than as something sitting on top of it */
            .handle {
                position: absolute;
                top: 0;
                right: 0;
                padding: 8px;
                color: var(--text-2);
                background: var(--gray-5);
                border-radius: 0 3px 0 8px;
                cursor: grab;
                line-height: 1;

                &:hover {
                    color: var(--text);
                    background: var(--gray-6);
                }

                &:active {
                    cursor: grabbing;
                }
            }

            /* One inline has nowhere to go, so it is not offered a handle */
            &:has(.inline:only-child) .handle {
                display: none;
            }

            /* The inline being dragged, which is left in place and faded,
               so that the list does not reflow under the cursor */
            .inline.dragging {
                opacity: .4;
            }

            /* Somewhere the dragged inline can go. Every gap but the two it
               already sits between opens one, so what is offered is only
               ever a move */
            .drop {
                height: 42px;
                margin: 0 0 15px 0;
                border-radius: 4px;
                background: color-mix(in srgb, var(--action) 14%, white);
                transition: background 120ms ease-out;

                /* Under the cursor, and so the one a release would take */
                &.over {
                    background: color-mix(in srgb, var(--action) 30%, white);
                }
            }
        }

        > .controls {
            float: right;

            .control {
                float: left;

                &:not(:last-child) {
                    margin: 0 10px 0 0;
                }

                .btn.secondary {
                    opacity: .75;
                }
            }
        }
    }
}

/* Rich
---------------- */

/* A textarea written in the rich text editor, e.g., a message - a row of
   formatting buttons over the editor, which gives way to the textarea itself
   while the Markdown is showing (see common.js) */
.rich {
    /* The space under the toolbar, and over the note - named, since the
       Markdown button reaches down across both to join the note */
    --under-toolbar: 6px;
    --over-note: 5px;

    .toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 2px;
        margin: 0 0 var(--under-toolbar) 0;

        /* Important, since .btn's own padding is */
        .btn {
            padding: 6px 16px !important;

            /* Tighter below lg, where the row has less room */
            @media (max-width: 991.98px) {
                padding: 6px 13px !important;
            }
            border: 0;
            border-radius: 3px;
            font-size: 0.875rem;
            line-height: 1;
            color: var(--text-2);

            &:hover {
                background: var(--surface-2);
            }

            /* Darkened, so that what applies stands out from what does not */
            &.active,
            &.active:hover {
                background: var(--gray-5);
                color: var(--dark);
            }
        }

        .formats {
            display: flex;
            flex-wrap: wrap;
            gap: 2px;
        }

        /* The switch to the Markdown, apart from the formats, at the end */
        .raw {
            margin: 0 0 0 auto;

            /* Quieter than the formats, since it is seldom wanted - until it
               is pointed at, or showing the Markdown */
            opacity: 0.5;

            &:hover,
            &.active {
                opacity: 1;
            }

            /* On, it joins the note under it, as a tab does its panel - its
               bottom corners squared, and its shade carried down across the
               space between them */
            &.active {
                position: relative;
                border-bottom-left-radius: 0;
                border-bottom-right-radius: 0;

                &::after {
                    content: '';
                    position: absolute;
                    top: 100%;
                    right: 0;
                    left: 0;
                    height: calc(var(--under-toolbar) + var(--over-note));
                    background: inherit;
                }
            }
        }
    }

    .surface {
        min-height: 160px;

        /* The editable area Tiptap makes inside the surface */
        .tiptap {
            min-height: 140px;
            outline: none;
        }

        &:focus-within {
            border-color: var(--action);
            box-shadow: 0 0 0 3px color-mix(in srgb, var(--action) 25%, transparent);
        }
    }

    /* What the Markdown is, over it while it shows - in the Markdown
       button's own shade while it is on, so that the two read as one */
    .note {
        display: none;
        margin: var(--over-note) 0 6px 0;
        padding: 5px 10px;
        border-radius: 4px;

        /* Square where the Markdown button joins it */
        border-top-right-radius: 0;
        font-size: 0.8125rem;
        background: var(--gray-5);
        color: var(--dark);

        .term {
            text-decoration: underline dotted;
            cursor: help;
        }
    }

    &.markdown .surface {
        display: none;
    }

    &.markdown .note {
        display: block;
    }
}

/* The textarea shows only while the Markdown does */
.rich-raw {
    display: none;
    min-height: 160px;

    .rich.markdown ~ & {
        display: block;
    }
}

/* Formatted text, e.g., a message, as written in the editor and as shown -
   the spacing is kept tight, since it is a message rather than a document */
.rich .tiptap,
.formatted {
    p,
    ul,
    ol,
    blockquote {
        margin: 0 0 0.75em 0;

        &:last-child {
            margin-bottom: 0;
        }
    }

    ul,
    ol {
        padding: 0 0 0 1.5em;

        p {
            margin: 0;
        }
    }

    blockquote {
        padding: 0 0 0 12px;
        border-left: 3px solid var(--border);
        color: var(--text-2);
    }

    a {
        color: var(--action);
        text-decoration: underline;
    }

    /* The site a link goes to, said after it, e.g., "(example.com)" */
    small {
        color: var(--text-2);
    }
}

/* Container
---------------- */

/* The page covers the display edge to edge (viewport-fit=cover), so the
   gutter, not iOS, decides where the side edge is - the band iOS reserves
   around the camera housing lands a hair tight against the logo, so --clear
   is added to it, and the result is floored at --gutter, which is what
   portrait and every desktop width keep using */
.container {
    max-width: 1170px;
    padding-left: max(
        var(--gutter), calc(env(safe-area-inset-left) + var(--clear))
    );
    padding-right: max(
        var(--gutter), calc(env(safe-area-inset-right) + var(--clear))
    );
}

/* Header
---------------- */

header.main {
    background: var(--dark);
    padding-top: env(safe-area-inset-top);

    .logo {
        float: left;

        a {
            width: 126px;
            height: 22px;
            margin: 13px 0;
            float: left;
            text-indent: -9000px;
            background: transparent url("../svg/logo.d45215abc8fe.svg") left top no-repeat;
            opacity: 0.85;

            &:hover {
                opacity: 1;
            }
        }
    }

    > .container > menu {
        margin: 0;
        padding: 0;
        float: right;

        > li {
            margin: 7px 0;
            float: left;
            font-size: 0.875rem;
            line-height: 1;
            list-style: none;

            &:not(:last-child) {
                margin-right: 10px;
            }

            > a {
                padding: 10px;
                border-radius: 4px;
                float: left;
                text-decoration: none;
                color: var(--gray-3);

                &:hover {
                    background: rgba(255, 255, 255, .05);
                }

                @media (max-width: 767.98px) {
                    padding: 10px 15px;
                }

                .active & {
                    color: var(--white);
                    background: rgba(255, 255, 255, .15);
                }

                &:not(.dropdown-trigger) > .icon {
                    margin: 0 7px 0 0;

                    @media (max-width: 767.98px) {
                        margin: 0;
                    }
                }

                > strong {
                    font-weight: normal;

                    @media (max-width: 767.98px) {
                        display: none;
                    }
                }
            }
        }
    }
}

/* Main Menu
---------------- */

nav.main {
    background: var(--primary);

    > .container > menu {
        margin: 0;
        padding: 0;
        float: left;

        &:empty {
            height: 5px;
        }

        > li {
            margin: 7px 0 0 0;
            float: left;
            font-size: 0.875rem;
            line-height: 1;
            list-style: none;

            &:not(:last-child) {
                margin-right: 5px;
            }

            > a {
                padding: 11px 10px 10px 10px;
                border-top-right-radius: 4px;
                border-top-left-radius: 4px;
                float: left;
                text-decoration: none;
                color: var(--white);
                background: rgba(255, 255, 255, .04);

                &:hover {
                    background: rgba(255, 255, 255, .10);
                }

                .active & {
                    color: var(--dark);
                    background: var(--white);

                    .extra & {
                        border-left: 4px var(--gray) solid;
                    }
                }

                /* An item collapses to its icon on a phone where the menu has
                   an extra item, e.g., the client open, and on the smallest
                   phones unless it is the active one - the extra item never
                   does */
                @media (max-width: 767.98px) {
                    &:not(.extra &):is(:has(.extra) &) {
                        padding: 11px 13px 10px 13px;
                    }
                }

                @media (max-width: 575.98px) {
                    &:not(.extra &):not(.active &) {
                        padding: 11px 13px 10px 13px;
                    }
                }

                .icon {
                    + strong {
                        margin: 0 0 0 7px;
                        font-weight: normal;

                        &:not(.extra &):is(:has(.extra) &) {
                            @media (max-width: 767.98px) {
                                display: none;
                            }
                        }

                        &:not(.extra &):not(.active &) {
                            @media (max-width: 575.98px) {
                                display: none;
                            }
                        }

                        /* The thing open, e.g., the client, cut short so
                           that the rest of the menu keeps its place - the
                           trail and its title say it in full */
                        .extra & {
                            display: inline-block;
                            max-width: 20ch;
                            overflow: hidden;
                            white-space: nowrap;
                            text-overflow: ellipsis;
                            vertical-align: bottom;
                        }
                    }

                    /* On the navy bar, state takes its fill stop rather
                       than its ink stop - the ink stops are cut to carry on
                       white, and would go to mud here */
                    &.success {
                        color: var(--success);
                    }
                }
            }
        }
    }
}

/* Submenu
---------------- */

nav.sub {
    background: linear-gradient(var(--white), var(--gray-3));
    border-bottom: 1px var(--gray) solid;

    > .container > menu {
        margin: 0;
        padding: 0;
        float: left;

        &:empty {
            height: 5px;
        }

        > li {
            margin: 7px 0;
            float: left;
            font-size: 0.875rem;
            line-height: 1;
            list-style: none;

            &:not(:last-child) {
                margin-right: 5px;
            }

            > a {
                padding: 7px 10px;
                border-radius: 3px;
                float: left;
                text-decoration: none;
                color: var(--dark);

                &:hover {
                    background: color-mix(in srgb, var(--dark) 5%, transparent);
                }

                .active & {
                    background: color-mix(in srgb, var(--dark) 15%, transparent);
                }

                /* An item's icon stands in for its label on a phone, where
                   the labels would not fit on one line */
                &:not(.dropdown-trigger) > .icon {
                    display: none;

                    @media (max-width: 767.98px) {
                        display: inline-block;
                    }
                }

                > strong {
                    font-weight: normal;

                    @media (max-width: 767.98px) {
                        display: none;
                    }
                }
            }
        }
    }
}

/* Dropdowns
---------------- */

menu.dropdown-menu > li {
    font-size: 0.875rem;

    .dropdown-item {
        padding: 7px 16px;

        /* An item that archives, removes, or calls something off is in the
           danger colour, as such a control is - one that restores is not */
        &:has(> .fa-box-archive, > .fa-trash, > .fa-ban) {
            color: var(--danger);
        }

        /* An item that cannot be acted on, which says why on hover - its
           item is what holds the tooltip, since it takes no pointer */
        &.disabled {
            opacity: 0.5;
        }
    }

    /* Cut short, rather than widening the menu, e.g., a long account name */
    .dropdown-header {
        max-width: 28rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .dropdown-header .icon,
    .dropdown-item > .icon {
        display: inline-block;
        margin: 0 7px 0 0;

        /* Matches the same item in the main menu, e.g., "Add Client" */
        &.success {
            color: var(--success);
        }
    }
}

/* A dropdown for adding to a list, which makes something new, or else
   finds something there already, e.g., a contact for a client */
menu.dropdown-menu.adding {
    /* As wide as the select and its button, and no wider, since nothing
       above them needs the room */
    width: max-content;
    max-width: calc(100vw - 32px);

    .existing p {
        margin: 0 0 8px 0;
        padding: 0 16px;
        color: var(--text-2);
    }

    .adder {
        padding: 0 16px 8px 16px;

        /* Wide enough for a full name, and gives way on a phone */
        .choices {
            flex: 0 1 auto;
            width: 256px;
            min-width: 0;
        }

        /* The select's "Press to select" hint, which takes room the names
           need in a list this narrow, where clicking one is obvious anyway */
        .choices__list--dropdown .choices__item--selectable {
            padding-right: 10px;

            &::after {
                display: none;
            }
        }
    }
}

/* Tooltips
---------------- */

/* Wider than Bootstrap's 200px, so that a long tooltip, e.g., a file's notes,
   wraps onto fewer lines */
.tooltip {
    --bs-tooltip-max-width: 240px;
}

/* Confirmation
---------------- */

.popover.confirmation {
    border-color: var(--gray-5);
    box-shadow: 1px 1px 3px 0 rgba(0, 0, 0, 0.1);

    .popover-header {
        padding: 9px 14px;
        border-bottom-color: var(--gray-4);
        font-size: 0.8125rem;
        font-weight: 500;
        background: var(--gray-3);

        /* The people a reminder would reach, each with when they were last
           written to */
        ul {
            margin: 6px 0 0 0;
            padding: 0 0 0 16px;
            font-weight: normal;

            small {
                margin: 0 0 0 3px;
                color: var(--text-3);
            }
        }
    }

    .popover-body {
        padding: 10px 14px;
        text-align: right;
        white-space: nowrap;

        .btn {
            padding: 3px 14px !important;
            font-size: 0.8125rem;

            &.cancel {
                margin: 0 0 0 5px;
            }
        }
    }
}

/* Modal
---------------- */

/* A form shown over the page, e.g., a row's labels - at the system's radius,
   with the far float shadow, since nothing sits further off the page. It
   lives outside the content, so it carries the few content styles its
   forms use */
.modal {
    .modal-content {
        border: 0;
        border-radius: 4px;
        box-shadow: 1px 1px 6px 0 rgba(0, 0, 0, 0.15);
    }

    .modal-header {
        padding: 14px 20px;
        border-bottom: 1px var(--border-soft) solid;

        /* On one line, cut short where a name it says is long, e.g., the
           thing being labelled - the close button keeps its place */
        .modal-title {
            min-width: 0;
            overflow: hidden;
            font-size: 1rem;
            font-weight: 400;
            white-space: nowrap;
            text-overflow: ellipsis;

            > .icon {
                margin: 0 8px 0 0;
                color: var(--text-3);
            }
        }
    }

    .modal-body {
        padding: 17px 20px 4px 20px;

        .message {
            margin: 0 0 15px 0;
        }

        .field-group {
            margin: 0 0 16px 0;
        }

        .form-label {
            margin: 0 0 5px 0;
            font-size: 0.875rem;
            font-weight: 600;
        }

        .form-text {
            margin: 6px 0 0 0;
            color: var(--text-3);
            font-size: 0.8125rem;
            font-weight: 300;
        }
    }

    .modal-footer {
        padding: 10px 20px;
        border-top: 1px var(--border-soft) solid;
        background: var(--surface-4);

        .btn {
            margin: 0;
        }
    }

    .minor {
        margin: 0 0 12px 0;
        color: var(--text-2);
        font-size: 0.8125rem;
        font-weight: 300;
    }

    .subtle {
        color: var(--text-3);
        font-weight: 300;
    }
}

/* Behind the modal, which dims the page rather than blacking it out */
.modal-backdrop {
    --bs-backdrop-bg: var(--dark);
    --bs-backdrop-opacity: 0.3;
}

/* A modal's form drawn as a page of its own, where it was not asked for in
   place - in a panel, without the modal's own edges */
.shell.modeless {
    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 0;
        padding-right: 0;
        background: none;
    }

    .modal-header {
        padding-top: 0;

        .btn-close {
            display: none;
        }
    }

    .modal-footer {
        padding-bottom: 0;
        justify-content: flex-start;
    }
}

/* Message
---------------- */

.message {
    /* The hue the message is drawn in, named once so that the edge and the
       control that dismisses it cannot drift apart. The fallback is what a
       message with no level of its own gets */
    --edge: var(--gray);

    position: relative;
    margin: 20px 0;

    /* Room on the right for the control that dismisses it, which is a
       fixed-width icon in 15px of padding either side */
    padding: 15px 48px 15px 20px;
    border: 1px solid var(--edge);
    border-radius: 4px;

    &.secondary {
        background: color-mix(in srgb, var(--gray) 25%, transparent);
    }

    &.success {
        --edge: var(--success);

        background: color-mix(in srgb, var(--success) 25%, transparent);
    }

    &.info {
        --edge: var(--blue);

        background: color-mix(in srgb, var(--blue) 10%, transparent);
    }

    &.warning {
        --edge: var(--warning);

        background: color-mix(in srgb, var(--warning) 10%, transparent);
    }

    &.danger {
        --edge: var(--danger);

        background: color-mix(in srgb, var(--danger) 10%, transparent);
    }

    /* Drawn in the message's own hue, in the corner, out of the flow of the
       words so that a long message reads the same as a short one */
    .dismiss {
        position: absolute;
        top: 0;
        right: 0;
        padding: 13px 15px;
        border: 0;
        background: none;
        color: var(--edge);
        line-height: 1;
        opacity: 0.7;

        &:hover,
        &:focus {
            opacity: 1;
        }
    }
}

/* Noted
---------------- */

/* A message noted by an action, e.g., an Ajax response - it floats, since the
   action that raised it can be taken anywhere down the page */
.message.noted {
    position: fixed;
    top: calc(20px + env(safe-area-inset-top));
    right: calc(20px + env(safe-area-inset-right));
    z-index: 1090;
    max-width: 360px;
    margin: 0;
    cursor: pointer;
    background: var(--white);
    box-shadow: 1px 1px 6px 0 rgba(0, 0, 0, 0.15);

    &.success {
        background: color-mix(in srgb, var(--success) 25%, white);
    }

    &.danger {
        background: color-mix(in srgb, var(--danger) 10%, white);
    }

    @media (max-width: 575.98px) {
        top: calc(10px + env(safe-area-inset-top));
        right: calc(10px + env(safe-area-inset-right));
        left: calc(10px + env(safe-area-inset-left));
        max-width: none;
    }
}

/* HR
---------------- */

hr {
    border-color: var(--gray-5);
    color: var(--gray-5);
}

/* Button
---------------- */

.btn {
    padding: 6px 18px !important;
    border-radius: 3px;
    font-size: 0.875rem;

    .icon.inline {
        margin: 5px;
    }

    &.small {
        padding: 3px 12px !important;
        font-size: 0.8125rem;
    }

    /* As wide as what it sits in, e.g., the one way in a sign-in step
       offers, or the other way in, under a login form */
    &.block {
        width: 100%;
        text-align: center;

        .icon {
            margin-right: 5px;
        }
    }

    &[type="submit"] {
        margin: 5px 0 0 0;
    }

    /* Beside the button before it, on a line of its own in the template -
       the line break between them renders as a space, which is most of the
       gap */
    &.adjacent {
        margin: 5px 0 0 1px;
    }

    /* Built by common.js right against the button before it, so the gap is
       all margin */
    &.cancel {
        margin: 5px 0 0 5px;
    }

    &.primary {
        border-color: var(--primary);
        color: var(--white);
        font-weight: 500;
        background: color-mix(in srgb, var(--primary) 90%, white);

        &:hover {
            border-color: color-mix(in srgb, var(--primary) 95%, black);
            background: color-mix(in srgb, var(--primary) 95%, white);
        }

        &:active {
            color: var(--white);
            border-color: color-mix(in srgb, var(--primary) 90%, black);
            background: var(--primary);
        }
    }

    &.secondary {
        border-color: color-mix(in srgb, var(--quiet-fill) 90%, black);
        color: var(--white);
        font-weight: 500;
        background: var(--quiet-fill);

        &:hover {
            border-color: color-mix(in srgb, var(--quiet-fill) 85%, black);
            background: color-mix(in srgb, var(--quiet-fill) 90%, black);
        }

        &:active {
            border-color: color-mix(in srgb, var(--quiet-fill) 80%, black);
            color: var(--white);
            background: color-mix(in srgb, var(--quiet-fill) 85%, black);
        }
    }

    /* Adds a row to a form in place, e.g., another signer, rather than
       submitting it, so it goes without the border of one that does */
    &.add {
        border-color: transparent;
        color: var(--white);
        font-weight: 500;
        background: var(--quiet-fill);

        .icon:first-child {
            margin: 0 6px 0 0;
        }

        &:hover {
            border-color: transparent;
            background: color-mix(in srgb, var(--quiet-fill) 90%, black);
        }

        &:active {
            border-color: transparent;
            color: var(--white);
            background: color-mix(in srgb, var(--quiet-fill) 85%, black);
        }
    }

    &.success {
        border-color: color-mix(in srgb, var(--success) 90%, black);
        color: var(--white);
        font-weight: 500;
        background: var(--success);

        &:hover {
            border-color: color-mix(in srgb, var(--success) 85%, black);
            background: color-mix(in srgb, var(--success) 90%, black);
        }

        &:active {
            border-color: color-mix(in srgb, var(--success) 80%, black);
            color: var(--white);
            background: color-mix(in srgb, var(--success) 85%, black);
        }
    }

    &.danger {
        border-color: color-mix(in srgb, var(--overdue-fill) 90%, black);
        color: var(--white);
        font-weight: 500;
        background: var(--overdue-fill);

        &:hover {
            border-color: color-mix(in srgb, var(--overdue-fill) 85%, black);
            background: color-mix(in srgb, var(--overdue-fill) 90%, black);
        }

        &:active {
            border-color: color-mix(in srgb, var(--overdue-fill) 80%, black);
            color: var(--white);
            background: color-mix(in srgb, var(--overdue-fill) 85%, black);
        }
    }

    &.link {
        color: var(--text-3);
        text-decoration: none;
        font-weight: 300;

        &:hover {
            color: var(--text);
            text-decoration: underline;
        }
    }
}

/* Footer
---------------- */

/* The foot of every page, in the header's color - who the app belongs to,
   and the documents it is used under. It runs under the home indicator, and
   pads itself clear of it, so the blue reaches the bottom edge */
footer {
    min-height: 96px;
    padding: 30px 0 calc(30px + env(safe-area-inset-bottom)) 0;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, .6);
    background: var(--dark);

    .copyright {
        margin: 0;
        float: left;
    }

    menu {
        margin: 0;
        padding: 0;
        float: right;

        li {
            display: inline;
            list-style: none;

            &:not(:last-child) {
                margin-right: 20px;
            }
        }
    }

    a {
        text-decoration: none;
        color: rgba(255, 255, 255, .85);

        &:hover {
            text-decoration: underline;
            color: var(--white);
        }
    }

    /* Stacked on a phone, rather than squeezed onto one line */
    @media (max-width: 575.98px) {
        .copyright,
        menu {
            float: none;
        }

        menu {
            margin: 12px 0 0 0;
        }
    }
}

/* Section
---------------- */

.section {
    margin: 15px 0 0 0;
}

/* Content
---------------- */

.content {
    font-size: 0.9375rem;

    /* Room under the last thing on the page, so that a button at the foot
       of a form is never left pressed against the bottom edge - on a phone,
       that edge is the browser's own toolbar, drawn over the page */
    padding: 0 0 60px 0;

    ::selection {
        color: var(--dark);
        background: var(--blue-lt);
    }

    a {
        text-decoration: none;

        &:hover:not(.btn):not(.dropdown-item):not(.list-toggle):not(.chip) {
            text-decoration: underline;
        }
    }

    /* A minor control, e.g., edit, archive, etc., as a link or a submit */
    .control {
        color: var(--control);

        &:hover {
            color: var(--control-hover);
        }

        /* A control that archives, removes, or calls something off is in the
           danger colour, since it takes the thing out of use - one that
           restores it is not */
        &:has(> .fa-box-archive, > .fa-trash, > .fa-ban, > .fa-xmark) {
            color: var(--danger);

            &:hover {
                color: color-mix(in srgb, var(--danger) 80%, black);
            }
        }

        &:not(:last-child) {
            margin: 0 10px 0 0;
        }
    }

    button.control {
        padding: 0;
        border: 0;
        line-height: 1;
        cursor: pointer;
        background: none;
    }

    h1, h2, h3, h4, h5, h6 {
        margin: 0;
    }

    h1 {
        font-size: 1.375rem;
        font-weight: 400;

        @media (max-width: 767.98px) {
            font-size: 1.25rem;
        }
    }

    /* A page's title, after the way back up to it - the pages above as
       lighter links, and the page itself last, in bold, on the same line,
       e.g., Client > Tasks > Edit Task */
    header.trail {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        font-size: 1rem;

        nav {
            color: var(--text-3);

            a {
                font-weight: 300;
                color: var(--text-2);
                text-decoration: none;

                &:hover {
                    color: var(--text);
                    text-decoration: underline;
                }

                /* A section's icon, which stands in for its name on the
                   smallest phones, as its tab's does - only where there is
                   more than one link, since one alone always fits */
                > .icon:has(+ strong) {
                    display: none;
                }

                > strong {
                    font-weight: inherit;
                }
            }

            &:has(> a ~ a) a {
                @media (max-width: 575.98px) {
                    > .icon:has(+ strong) {
                        display: inline-block;
                    }

                    > strong {
                        display: none;
                    }
                }
            }

            /* The main page of the current thing, e.g., the client, cut short
               on the smallest phones - its tab says it in full */
            a.root {
                @media (max-width: 575.98px) {
                    display: inline-block;
                    max-width: 45vw;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                    vertical-align: bottom;
                }
            }

            > .icon {
                margin: 0 4px;
                font-size: 0.75rem;
            }
        }

        /* As tall as the links' line, so that a title alone sits where it
           would after them */
        h1 {
            font-size: 1rem;
            font-weight: 600;
            line-height: 1.5;
            color: var(--text);
        }

        /* The subtext under the trail, a little apart from it, with the
           thing it names as heavy as the title */
        + .subinfo {
            margin-top: 10px;

            /* A long subject, e.g., of the message being replied to, cut
               short, so that who sent it stays on the line */
            strong.subject {
                display: inline-block;
                max-width: min(48ch, 60vw);
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                vertical-align: bottom;
            }

            strong {
                font-weight: 600;
            }
        }
    }

    /* A section of a page, e.g., the invitations under the users - a small
       label, rather than a title, so that it never outweighs the page's own
       title in the trail */
    h2 {
        margin: 24px 0 0 0;
        font-size: 0.8125rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--text-3);
    }

    h3 {
        margin: 2px 0 10px 0;
        font-size: 0.9375rem;
        font-weight: 700;
    }

    .headings {
        .info {
            float: left;

            @media (max-width: 575.98px) {
                float: none;
            }
        }

        .ctas {
            float: right;

            @media (max-width: 575.98px) {
                margin: 15px 0 5px 0;
                float: none;
            }

            /* A cta that acts, rather than links, comes wrapped in its form,
               which floats in its place, leaving the cta itself to shrink the
               form around it */
            form {
                float: left;

                &:not(:last-child) {
                    margin: 0 10px 0 0;
                }

                .cta {
                    float: none;
                }
            }

            .cta {
                float: left;

                @media (max-width: 575.98px) {
                    padding: 4px 16px !important;
                }

                &:not(:last-child) {
                    margin: 0 10px 0 0;
                }

                .icon:first-child {
                    margin: 0 7px 0 -2px;
                }

                .icon.closing {
                    margin: 0 -2px 0 7px;
                }
            }
        }
    }

    .text-success {
        color: var(--settled) !important;
    }

    .text-danger {
        color: var(--overdue) !important;
    }

    .subinfo {
        margin: 5px 0 0 0;

        /* The record a line names, set apart from the words around it - at a
           weight of its own, since the browser's bold would shout it */
        strong {
            font-weight: 500;
        }

        &.deep {
            margin: 15px 0 0 0;
        }
    }

    .subtle {
        color: var(--text-3);

        &:not(.icon) {
            font-weight: 300;
        }

        &.smaller {
            font-size: 0.8125rem;
        }
    }

    .before {
        margin: 0 7px 0 0;
    }

    .after {
        margin: 0 0 0 5px;
    }

    .lighter {
        color: var(--text-3);
    }

    .datum {
        margin: 0 0 10px 0;

        .icon:first-child {
            margin: 0 5px 0 0;
        }
    }

    address {
        margin: 10px 0 0 0;
        line-height: 1.214;

        .line {
            margin: 5px 0 0 0;
        }
    }
}

/* Shell
---------------- */

.shell {
    margin-top: 15px;
    padding: 17px 20px 20px 20px;
    border-radius: 4px;
    background: var(--gray-3);
    box-shadow: 1px 1px 0 0 rgba(0, 0, 0, 0.08);

    &.invalid {
        border-top: 5px var(--danger) solid;
    }

    &.kard {
        .action {
            margin: 0 0 0 10px;
            float: right;
            font-size: 0.8125rem;
            text-decoration: none;
            font-weight: 200;
            color: var(--text-3);

            &:hover {
                color: var(--text);
                text-decoration: underline;
            }
        }

        /* A record's notes, e.g., a client's, which are for the users rather
           than the card, so they stay folded behind an icon until it is
           clicked, which is common.js's doing */
        .datum.notes blockquote {
            display: none;
            margin: 8px 0 0 0;
            padding: 0 0 0 12px;
            border-left: 3px var(--gray-4) solid;
            font-size: 0.875rem;
            color: var(--text-2);
        }
    }

    &.less {
        background: color-mix(in srgb, var(--gray-3) 50%, white);
    }

    /* A shell folded down to its title, e.g., the password change form,
       opened by clicking the title */
    &.fold {
        padding-bottom: 17px;

        summary {
            display: flex;
            align-items: center;
            justify-content: space-between;
            cursor: pointer;
            list-style: none;

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

            h3 {
                margin: 0;
            }

            .icon {
                color: var(--text-3);
                transition: transform 0.15s;
            }
        }

        &[open] {
            padding-bottom: 20px;

            summary .icon {
                transform: rotate(180deg);
            }

            form {
                margin: 12px 0 0 0;
            }
        }
    }

    .minor {
        font-size: 0.875rem;

        .icon {
            font-size: 0.75rem;
        }
    }

    /* What a button unfolds under itself, e.g., how to close the account -
       hidden until the button is pressed */
    .unfolds {
        display: none;
        margin: 12px 0 0 0;
    }

    .last {
        margin-bottom: 0;
    }
}

/* Leave
---------------- */

/* The leaving page, which says where a link to another site goes - the
   address is shown in full, however long, so it breaks anywhere */
.shell.leave {
    .host {
        font-size: 1.25rem;
        font-weight: 600;
    }

    .url {
        overflow-wrap: anywhere;
        color: var(--text-2);
    }

    /* How long is left before the page goes on, in tabular numerals, so
       that the line does not shift as the digits change - the weight is
       set, since "bolder" than subtle text is only regular */
    [data-countdown] strong {
        font-weight: 600;
        font-variant-numeric: tabular-nums;
    }
}

/* Sheet
---------------- */

/* A form laid out as panels, e.g., an invitation's who and access side by
   side - a faint wrap standing off the panels, with the buttons under them
   and inside it, so that they belong to the whole and to neither panel */
.sheet {
    margin-top: 15px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;

    &.invalid {
        border-color: var(--danger);
    }

    .row {
        row-gap: 12px;
    }

    .shell {
        height: 100%;
        margin-top: 0;
    }

    .actions {
        margin: 12px 0 0 0;
        padding: 0 8px 0 8px;
    }
}

/* Standing
---------------- */

/* What is outstanding under a record, said in the line under its name, so that
   the first thing read is the answer to why the page was opened */
.subinfo.standing {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    font-size: 0.8125rem;

    > a,
    > span {
        color: var(--text-3);
        text-decoration: none;

        .icon {
            margin: 0 5px 0 0;
            font-size: 0.75rem;
        }
    }

    > a:hover {
        color: var(--text);
        text-decoration: underline;
    }

    /* The two segments that report state take their state's ink */
    > .due {
        color: var(--soon);
    }

    > .waiting {
        color: var(--soon);
    }

    > .clear .icon {
        color: var(--settled);
    }
}

/* A panel of what is standing, e.g., the contacts who can be messaged under
   a client - each row is one thing, and nothing else */
.standing-panel {
    /* On one line, with the name cut short where it is long, so that how long
       it has stood keeps its place at the far end */
    .standing-row {
        display: flex;
        align-items: baseline;
        margin: 0 0 7px 0;
        font-size: 0.875rem;
        line-height: 1.3;

        &:last-child {
            margin: 0;
        }

        > a {
            min-width: 0;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        > .icon {
            flex: none;
            margin: 0 6px 0 0;
            color: var(--control);

            /* How a recently finished one ended, in the same colours as the
               e-sign list */
            &.settled {
                color: var(--settled);
            }

            &.stopped {
                color: var(--text-3);
            }

            &.failed {
                color: var(--overdue);
            }
        }

        /* How long it has stood, pushed to the far end so that it reads as
           its own column rather than as the tail of the name next to it */
        .since {
            flex: none;
            margin: 0 0 0 auto;
            padding: 0 0 0 8px;
            color: var(--text-3);
            font-size: 0.8125rem;
            font-weight: 300;
        }
    }

    .datum.last {
        font-size: 0.875rem;
    }
}

/* The heading over the column beside the main list, which names the column as
   a region of its own rather than leaving it under the last heading */
h2.rail {
    margin-top: 0;
}

/* Who a message is about to go to, said above the button that sends it */
.recipients {
    margin: 20px 0 15px 0;
    padding: 10px 14px;
    border-left: 3px var(--action) solid;
    border-radius: 3px;
    font-size: 0.875rem;
    background: color-mix(in srgb, var(--action) 8%, white);

    .icon {
        margin: 0 8px 0 0;
        color: var(--action);

        &.failed {
            color: var(--overdue);
        }
    }
}

/* Nobody to reach, e.g., a message form for a client with no active contacts */
.recipients.none-to-reach {
    border-left-color: var(--overdue);
    background: color-mix(in srgb, var(--danger) 8%, white);

    .icon {
        color: var(--overdue);
    }
}

/* Preview
---------------- */

/* A preview of what a form's input amounts to, e.g., when a schedule is next
   due - hidden until there is enough filled in to tell */
.preview {
    display: none;
    margin: 20px 0 5px 0;
    padding: 12px 15px;
    border-left: 3px var(--action) solid;
    border-radius: 3px;
    background: color-mix(in srgb, var(--action) 8%, white);

    .schedule {
        font-weight: 500;

        .icon {
            margin: 0 8px 0 0;
            color: var(--action);
        }
    }

    .next {
        margin: 6px 0 0 0;
        font-size: 0.875rem;
        color: var(--text-3);
    }
}

/* Cleared
---------------- */

/* A record with nothing outstanding under it - the state the work is aimed
   at, so it is marked as reached rather than reported as missing */
.subinfo.cleared {
    font-size: 0.9375rem;
    color: var(--text-2);

    .icon {
        margin: 0 8px 0 0;
        color: var(--settled);
    }
}

/* Figures
---------------- */

/* Wherever figures are stacked - a column of due dates, the timestamps beside
   them, the details on a record - they are set in tabular numerals, so the
   digits align down the column instead of shuffling by glyph width. Only the
   figures: proportional text keeps its own spacing, since tabular digits pad
   the characters between them, e.g., the hyphen in "1099-NEC" */
.listable td.due,
.listable .subtle,
.subinfo.standing,
.standing-panel .since,
.content .datum,
.content address {
    font-variant-numeric: tabular-nums;
}

/* Listable
---------------- */

.list-buttons {
    float: right;

    @media (max-width: 575.98px) {
        margin: 15px 0 5px 0;
        float: none;
    }
}

/* A switch that stands for what the page is showing, e.g., a list that
   includes what has been completed - it takes no input of its own, so that it
   only ever reads as on as the page it arrived with, and is a link, so that
   the page it means is the one that turns it */
.list-toggle {
    margin: 20px 0 -10px 0;
    display: inline-block;

    /* A second switch beside the first, e.g., a list of tasks that widens to
       what was completed, and to what was put away */
    & + .list-toggle {
        margin-left: 20px;
    }

    .form-check {
        margin: 0;

        /* The switch is inert, since the link around it does the turning, so
           it is kept from reading as the disabled control that it is */
        .form-check-input:disabled {
            opacity: 1;
            filter: none;
            cursor: pointer;

            &:checked {
                border-color: var(--quiet-fill);
                background-color: var(--quiet-fill);
            }

            ~ .form-check-label {
                opacity: 1;
                color: var(--text-3);
                font-size: 0.875rem;
                font-weight: 300;
                cursor: pointer;
            }
        }
    }
}

.listable {
    margin: 20px 0 0 0;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-firm) transparent;

    > table:not(:has(tbody tr)) {
        display: none;
    }

    > table {
        min-width: 480px;
    }

    /* On a phone the summary row has already dropped two of its columns,
       so there is no longer 480px of anything to hold apart - and what a
       row expands into is a stack of blocks that would rather have the
       width than scroll sideways for it */
    @media (max-width: 575px) {
        > table {
            min-width: 0;
        }
    }

    /* What a row expands into - a task's description, a signature request's
       signers and history. Hidden until the row above it is clicked, which is
       common.js's doing, so it starts closed rather than opening on load */
    tr.details {
        display: none;

        .wrap {
            padding: 15px 20px;
            border-radius: 3px;
            color: var(--text-2);
            background: var(--surface-2);
        }

        /* What each block below is. A list of names, a list of things that
           happened and a list of files look alike without one - and a rule
           above each keeps them from running into one another */
        h4 {
            margin: 18px 0 8px 0;
            padding-top: 14px;
            border-top: 1px solid var(--gray-4);
            font-size: 0.6875rem;
            font-weight: 600;
            letter-spacing: 0.06em;
            text-transform: uppercase;
            color: var(--text-3);

            &:first-child {
                margin-top: 0;
                padding-top: 0;
                border-top: 0;
            }
        }
    }

    .cs-box {
        display: block;
        margin-top: -5px;

        .cs {
            float: left;
            margin-top: 5px;
            padding: 2px 7px;
            border-radius: 2px;
            cursor: default;

            &:not(:last-child) {
                margin-right: 5px;
            }

            &.primary {
                color: var(--white);
                background: var(--primary);
            }

            &.secondary {
                color: var(--dark);
                background: var(--gray-3);
            }
        }
    }

    tr.inactive > td {
        color: var(--text-2);
        background: var(--surface-4);
    }

    /* A cell of controls, e.g., edit, archive, deactivate, etc. */
    td.controls {
        white-space: nowrap;

        /* A control that submits is wrapped in its own form, which makes it
           the only child of that form and therefore always :last-child - so
           the gap that .control keeps between itself and the next one never
           applies to it. The form keeps the gap on its behalf */
        form {
            display: inline-block;

            &:not(:last-child) {
                margin: 0 10px 0 0;
            }
        }

        /* A mark that stands among the controls without being one, e.g., a
           lock, or an invitation's expiry, keeps the same gap they do */
        > .icon:not(:last-child) {
            margin: 0 10px 0 0;
        }

        /* A row's menu, e.g., the tabs of a client, which reads from the
           left, like any other menu, rather than from the cell's right - its
           forms, e.g., archiving, take the menu's width, as its links do */
        .dropdown-menu {
            text-align: left;

            form {
                display: block;
                margin: 0;
            }
        }
    }

    /* A row's main text, e.g., a file's name - it takes whatever width the
       other columns leave, and is cut short where that is not enough, rather
       than running the row onto a second line */
    td.main {
        --icon: calc(1.25em + 8px);
        width: 100%;
        max-width: 0;
        overflow: hidden;
        white-space: nowrap;

        > a,
        > span {
            display: inline-block;
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            vertical-align: bottom;
        }

        /* Room for the marks beside it, e.g., an archived task's box, so that
           they are never the part that is cut */
        &:has(> .icon) > :is(a, span) {
            max-width: calc(100% - var(--icon));
        }

        &:has(> .icon ~ .icon) > :is(a, span) {
            max-width: calc(100% - 2 * var(--icon));
        }

        /* The control that expands the row, e.g., into a task's description,
           trailing the name - the name, a link, expands it too, and the
           control darkens while the row is open */
        > .expander {
            margin: 0 0 0 5px;
            vertical-align: baseline;

            .icon {
                font-size: 0.875rem;
            }

            &.expanded {
                color: var(--control-hover);
            }
        }

        /* Room for it too, alone, or along with a mark */
        &:has(> .expander) > :is(a, span) {
            max-width: calc(100% - var(--icon));
        }

        &:has(> .icon):has(> .expander) > :is(a, span) {
            max-width: calc(100% - 2 * var(--icon));
        }
    }

    /* Every other cell in its table keeps to one line, so that the main one
       is the only one that gives way - what a row expands into, and a band
       across the list, span the row, and wrap as they always have */
    > table:has(td.main) > * > tr > :is(th, td):not([colspan]) {
        white-space: nowrap;

        .chips {
            flex-wrap: nowrap;
        }
    }

    /* Controls that only apply while the row is not inactive, e.g., editing
       a task that has since been completed */
    tr.inactive .editable {
        display: none;
    }

    /* A row the URL's fragment names, e.g., a message that was linked to from
       a dashboard, which is marked, so that it can be picked out */
    tr:target > td {
        background: color-mix(in srgb, var(--action) 10%, white);
    }
}

/* A list whose rows can be ticked, to act on several at once, e.g., to label
   them - the box heads each row, as the state column would */
.listable {
    th.pick,
    td.pick {
        width: 1%;
        padding-right: 0;

        .form-check-input {
            margin: 0;
            vertical-align: middle;
            cursor: pointer;
        }
    }

    tr.picked > td {
        background: color-mix(in srgb, var(--action) 6%, white);
    }
}

/* The bar for acting on the rows ticked, which follows the bottom of the
   window while the list scrolls under it - floating, so it takes the near
   float shadow */
.picking {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    margin: 15px 0 0 0;
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    border: 1px var(--border-firm) solid;
    border-radius: 4px;
    background: var(--surface);
    box-shadow: 1px 1px 3px 0 rgba(0, 0, 0, 0.1);

    .count {
        margin: 0 5px 0 0;
        color: var(--text-2);
        font-size: 0.875rem;
        font-variant-numeric: tabular-nums;
    }

    .btn {
        margin: 0;

        .icon {
            margin: 0 6px 0 0;
        }
    }
}

/* A list under a heading of its own, e.g., the tasks due under one client, on
   a dashboard that covers them all */
.grouping {
    margin: 20px 0 0 0;

    h3 {
        margin: 0;

        /* The client the group is under reads as the heading it is, rather
           than as one more link among the list beneath it */
        a {
            color: var(--dark);
        }

        .icon {
            font-size: 0.8125rem;
        }
    }

    .listable {
        margin: 10px 0 0 0;
    }
}

/* A link out of a shortened list, e.g., to all that is due under a client,
   where a dashboard shows only the next few - it is kept quiet, so that it
   trails the list without competing with anything in it */
.trailing {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 300;

    a {
        color: var(--text-3);

        &:hover {
            color: var(--text);
        }
    }
}

/* A form for adding to a list, e.g., a contact to a client, by choosing
   from a select, with the button that adds beside it */
.adder {
    display: flex;
    gap: 10px;

    .choices {
        flex: 1;
    }

    /* Level with the select, rather than pushed down by the gap a submit
       button keeps under the field above it */
    .btn[type="submit"] {
        margin: 0;
    }
}

/* Grants
---------------- */

/* What a role grants an account user under one client, said as a mark per
   permission, e.g., "Tasks Complete", in the list of their clients */
.grants {
    .grant {
        display: inline-block;
        margin: 0 6px 4px 0;
        padding: 1px 7px;
        border-radius: 4px;
        background: var(--gray-2);
        font-size: 0.8125rem;
        white-space: nowrap;
    }
}

/* Users
---------------- */

/* The users list and the invitations under it share column widths, so that
   the clients of each line up - an invitation has no phone, so its email
   takes the width of both */
.listable.admins,
.listable.invites {
    th.name {
        width: 35%;
    }

    th.email {
        width: 25%;
    }

    th.phone,
    th.clients {
        width: 15%;
    }

    /* Where the access is said by an icon, it and the controls keep only the
       room an icon needs, at the same width in both lists, so that, set
       against the right edge, they still line up */
    @media (max-width: 991.98px) {
        th.clients,
        th:last-child {
            width: 44px;
        }
    }

    /* And where the phone is too, the name takes whatever is left, rather
       than leaving it to columns that hold an icon */
    @media (max-width: 767.98px) {
        th.name {
            width: auto;
        }

        th.phone {
            width: 44px;
        }
    }
}

.listable.invites {
    th.email {
        width: 40%;
    }

    /* The control that renews an invitation says, by its colour, that the
       invitation has lapsed, or is about to */
    tr.expiring .renew {
        color: var(--warning);
    }

    tr.inactive .renew {
        color: var(--danger);
    }
}

/* Dashboard
---------------- */

/* The account dashboard is the one page that reports across every client at
   once, so its two sections are bounded rather than running together as one
   unbroken column of rows - each heading takes a rule, and more air above it
   than below, so that the page reads as two regions before it reads as rows */
.dash {
    h2 {
        margin: 32px 0 0 0;
        padding: 0 0 6px 0;
        border-bottom: 1px var(--border-soft) solid;
    }

    .listable,
    .comms-grouped {
        margin: 12px 0 0 0;
    }

    > .subinfo {
        margin: 12px 0 0 0;
    }
}

/* One client's tasks, requests, etc. within the list that covers them all,
   e.g., on the dashboard - the client is said as a band across the list,
   rather than as a heading over a table of its own, so that the columns stay
   aligned the whole way down the page and the header is stated once instead
   of once per client */
.listable.grouped {
    /* Each client after the first is parted from the one before it by air,
       rather than by a fill */
    tbody:not(:first-of-type) tr.group > td {
        padding-top: 24px;
    }

    tr.group {
        /* The one firmer rule in the list, under the client, which is what
           marks the row as the heading of the rows beneath it */
        &> td {
            padding: 10px 8px 7px 8px;
            border-bottom: 1px var(--border-firm) solid;

            /* The client's mark sits in the column its tasks are checked off
               in, so that its name starts where theirs do - centred, since
               the checks beneath it are larger than it is */
            &.check {
                text-align: center;

                .icon {
                    color: var(--text-3);
                }
            }

            /* The client keeps the ink of a link, so that it reads as somewhere
               to go, and takes the weight of the heading it is */
            .client {
                font-weight: 600;
            }

            /* How much is due under the client, trailing the name it belongs to -
               it is a link only when there is more than the list is showing */
            .count {
                float: right;
                margin: 2px 0 0 0;
                font-size: 0.8125rem;
                font-weight: 300;
                color: var(--text-3);
                font-variant-numeric: tabular-nums;
            }

            a.count:hover {
                color: var(--text);
            }
        }
    }
}

/* Tasks
---------------- */

.tasks {
    td.check {
        width: 1%;

        .check:hover {
            color: var(--settled);
        }

        /* Larger than the other controls, since it is what a task is acted
           on by, and is tapped rather than clicked on a phone */
        .check .icon {
            font-size: 1.25rem;
            vertical-align: middle;

            @media (max-width: 575.98px) {
                font-size: 1.5rem;
            }
        }
    }

    /* A task that has been completed reads as settled, rather than staying
       the same grey as the control that completed it */
    tr.inactive td.check .check {
        color: var(--settled);
    }

    /* Releasing a due date from its state, and marking a task done, are the
       two things worth seeing happen rather than finding already done - so
       the colour eases out, and the mark settles in. The completed list is
       excluded, since its rows arrive already done */
    td.due,
    td.check .icon {
        transition: color 240ms cubic-bezier(0.16, 1, 0.3, 1);
    }

    @media (prefers-reduced-motion: no-preference) {
        .listable.tasks:not(.completed) tr.inactive td.check .icon {
            animation: settle 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
        }
    }

    /* Marks a task that a routine scheduled, so it is left narrow, and only
       filled in for the tasks that came from one */
    .origin {
        width: 1%;
        color: var(--control);
    }

    /* What is late, and what is about to be - a routine's whole point is that
       the next one is seen before it is missed, so the week ahead is coloured
       too, one step short of overdue */
    td.due {
        white-space: nowrap;
    }

    /* How far off the date is, said in words beside it, so that lateness is
       read rather than worked out - it keeps whichever state ink the date is
       in, and drops to the light weight everything secondary takes. It is the
       first thing the column sheds when the page narrows */
    td.due .lateness {
        margin: 0 0 0 10px;
        font-size: 0.8125rem;
        font-weight: 300;
        font-variant-numeric: normal;

        @media (max-width: 991.98px) {
            display: none;
        }
    }

    tr.overdue td.due {
        color: var(--overdue);
        font-weight: 500;

        .icon {
            font-size: 0.8125rem;
        }
    }

    /* A completed task keeps whichever state its due date was in, so that
       the colour has something to ease out of - this is what it eases to */
    tr.inactive.overdue td.due,
    tr.inactive.soon td.due {
        color: var(--text-2);
        font-weight: normal;
    }

    tr.soon td.due {
        color: var(--soon);

        .icon {
            font-size: 0.8125rem;
        }
    }

    /* The date said as a calendar on a phone, in whichever state ink the
       date would be in, with the date itself in its tooltip - full size,
       rather than the small mark that sits beside a date */
    tr td.due .icon.when {
        font-size: 1rem;
    }

    /* On a phone the name is cut short, so it no longer fills the row, and
       the table hands what is left over to every column - the calendar and
       the controls are kept to their marks, so the name takes the rest */
    @media (max-width: 575.98px) {
        td.due,
        td.controls {
            width: 1%;
        }
    }

}

/* Comms
---------------- */

/* A list of messages, as an inbox reads it - each takes three lines, of who
   said it to whom, what it was about, and how it starts, so that it reads at
   a glance at any width, rather than dropping columns as the window narrows */
.comms {
    margin: 20px 0 0 0;
    padding: 0;
    list-style: none;
    border-top: 1px var(--border-soft) solid;

    /* An empty list says nothing, not even its rule */
    &:not(:has(> li)) {
        display: none;
    }

    > li {
        border-bottom: 1px var(--border-soft) solid;

        /* The whole message is what expands it, as in an inbox */
        > article {
            padding: 10px 8px;
            cursor: pointer;

            &:hover {
                background: var(--surface-4);
            }
        }

        /* The message the URL's fragment names, e.g., one linked to from a
           dashboard or a notification, so that it can be picked out */
        &:target > article {
            background: color-mix(in srgb, var(--action) 10%, white);
        }

        /* What it expands into sits under the summary, with the summary's
           own gutters */
        > .communication {
            padding: 0 8px 10px 8px;
        }
    }

    /* Who said it to whom, on the left, and what is marked on it, on the
       right - the names give way, since the marks are what line up down the
       list */
    .line {
        display: flex;
        align-items: baseline;
        gap: 10px;
        font-size: 0.875rem;

        .people {
            flex: 1;
            min-width: 0;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            color: var(--text-2);

            /* Whoever leads the row - the sender, or, for a sent message,
               whom it went to */
            .sender,
            strong.recipient {
                font-weight: 550;
                color: var(--text);
            }

            /* Said of a message sent out, which leads with whom it went to,
               rather than with who sent it */
            .sent {
                font-size: 0.75rem;
                color: var(--text-3);
            }

            /* Which of the account sent it, where it was not the viewer -
               last, so that it is the first thing a narrow row cuts */
            .by {
                margin: 0 0 0 2px;
                color: var(--text-3);
            }

            /* What each person is - the owner, a user, or a contact */
            .kind {
                font-size: 0.75rem;
                color: var(--text-3);
            }

            /* Spaced by the line breaks between the names in the template,
               which render as spaces */
            .to {
                color: var(--text-3);
            }

            .more {
                color: var(--text-3);
                font-variant-numeric: tabular-nums;
            }
        }

        .marks {
            display: flex;
            flex: none;
            align-items: baseline;
            gap: 8px;
            font-size: 0.8125rem;
            color: var(--text-3);
            font-variant-numeric: tabular-nums;

            /* Only filled in for the inbound ones owed nothing further */
            .answered {
                color: var(--settled);
            }

            .attached {
                cursor: pointer;
            }

            /* The client the message is under, which the contact's list
               says, where they may write under more than one - it gives way
               on a phone, where the names need the room */
            .client {
                max-width: 160px;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;

                @media (max-width: 575.98px) {
                    display: none;
                }
            }

            /* A row's menu reads from the left, like any other menu */
            .dropdown-menu {
                text-align: left;
            }
        }
    }

    /* What it was about and how it starts - each takes a line, and is cut
       where the line ends */
    .summary {
        margin: 3px 0 0 0;
        color: var(--text);

        .subject,
        .opening {
            display: block;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        .subject {
            font-weight: 350;

            /* Said of a message that answers an earlier one */
            .replying {
                margin: 0 4px 0 0;
                font-size: 0.75rem;
                color: var(--text-3);
            }
        }

        .opening {
            margin: 1px 0 0 0;
            font-size: 0.8125rem;
            font-weight: 300;
            color: var(--text-3);
        }
    }
}

/* The recent messages across every client, e.g., on the dashboard - the
   client is said as a band over its own, so that the list reads as one */
.comms-grouped {
    margin: 20px 0 0 0;

    section:not(:first-child) {
        margin: 24px 0 0 0;
    }

    /* Parted by air and one firmer rule, as the grouped tasks' clients are */
    .band {
        margin: 0;
        padding: 10px 8px 7px 8px;
        border-bottom: 1px var(--border-firm) solid;
        font-size: 1rem;

        /* The client keeps the ink of a link, so that it reads as somewhere
           to go, and takes the weight of the heading it is */
        .client {
            font-weight: 600;
        }

        /* How many there are under the client, trailing its name - it is a
           link only when there is more than the list is showing */
        .count {
            float: right;
            margin: 2px 0 0 0;
            font-size: 0.8125rem;
            font-weight: 300;
            color: var(--text-3);
            font-variant-numeric: tabular-nums;
        }

        a.count:hover {
            color: var(--text);
        }
    }

    .comms {
        margin: 0;
        border-top: 0;
    }
}

.communication {
    display: none;

    .wrap {
        padding: 20px;
        border-radius: 3px;
        background: var(--surface-2);

        .sender {
            color: var(--text-2);
        }

        blockquote.contents {
            margin: 15px 0 0 0;
            padding: 0 0 0 20px;
            border-left: 5px var(--gray) solid;

            .subject {
                margin: 0 0 10px 0;
                font-weight: 700;
            }

            .body {
                margin: 10px 0 0 0;
            }

            .attachments {
                margin: 20px 0 0 0;

                h4 {
                    margin: 2px 0 10px 0;
                    font-size: 0.875rem;
                    color: var(--text-2);
                    font-weight: 600;
                }

                ul {
                    margin: 0;
                    padding: 0;
                    list-style: inside square;

                    li {
                        margin: 0 0 5px 0;

                        &:last-child {
                            margin: 0;
                        }
                    }
                }
            }
        }

        .controls {
            margin: 15px 0 0 0;
            padding: 0;

            li {
                float: left;
                font-size: 0.875rem;
                list-style: none;

                a {
                    float: left;
                    padding: 6px 14px;
                    border-radius: 2px;
                    color: var(--dark);
                    background: var(--gray-2);

                    &:not(:last-child) {
                        border-top-right-radius: 0;
                        border-bottom-right-radius: 0;
                    }

                    &:hover {
                        text-decoration: none;
                        background: var(--gray);
                    }

                    .icon {
                        margin: 0 7px 0 0;
                    }
                }
            }
        }
    }
}

/* Envelopes
---------------- */

/* A whole block's worth of guidance, which sits under the controls it is
   about the way a field's own help text does - but with room to breathe,
   since it follows a group rather than a single input. Its own class
   because .field-group > .form-text is every field's help text in the app */
.form-text.guide {
    margin-top: 10px;
}

/* A control shown so that its absence is not mistaken for an oversight - it
   says, on hover, why it is not offering anything */
.control.inert {
    opacity: 0.3;
    cursor: default;
}

/* The button standing in for "Sign" while a signature just given is being
   recorded - it does nothing, and says so on hover. See sign.js */
.btn.recording {
    opacity: 0.7;
    cursor: default;
}

/* The dashboard's own list of what is standing, which is flatter than the
   Client's - no expanding row, so no pointer on a row and no controls */
.dash-envelopes {
    margin: 0 0 30px 0;

    td.waiting-on small {
        display: block;
    }
}

/* A list of signature requests, each expanding into who was asked, where each
   of them has got to, and what happened when */
.envelopes {

    /* Signing, beside the menu, where the request is waiting on the Admin -
       the line break after it renders as a space, which is the rest of the
       gap the menu's other controls keep */
    td.controls .sign {
        margin: 0 6px 0 0;
    }

    /* What a request's status amounts to, said in colour in the first column,
       so that a glance down the list finds what is wanted of the Admin
       without reading a single label */
    td.state,
    th.state {
        width: 1%;
        white-space: nowrap;

        &.settled .icon {
            color: var(--settled);
        }

        &.waiting .icon {
            color: var(--control);
        }

        &.stopped .icon {
            color: var(--text-3);
        }

        &.failed .icon {
            color: var(--overdue);
        }
    }

    /* How many people were asked, which is a count rather than a list at this
       width - the list is in the row below */
    td.signers,
    th.signers {
        width: 1%;
        text-align: center;
        color: var(--text-3);
    }

    /* What the signers were told, which is the request's note - quoted, since
       it is somebody's words rather than ours */
    blockquote.note {
        margin: 0 0 12px 0;
        padding: 0 0 0 12px;
        border-left: 3px var(--gray-3) solid;
        font-size: 0.875rem;
        color: var(--text-3);
    }

    /* Who was asked, and where each of them has got to. A list of rows
       that wrap rather than a table, because a table cannot give way on a
       phone - an address of thirty characters beside a status and a button
       made the whole page scroll sideways */
    ul.signers {
        margin: 0 0 12px 0;
        padding: 0;
        list-style: none;
        font-size: 0.875rem;

        li {
            display: flex;
            flex-wrap: wrap;
            align-items: baseline;
            gap: 2px 10px;
            padding: 5px 0;
        }

        /* Where there is no order, every signer stands equal, so this holds
           a dash rather than a number */
        .order {
            flex: 0 0 auto;
            width: 1rem;
            color: var(--text-3);
            text-align: center;
        }

        .who {
            /* Takes what it needs and no more, so that what is said about a
               signer sits beside their name rather than against the far
               edge - and gives way before the row has to scroll */
            flex: 0 1 auto;
            min-width: 0;
            color: var(--dark);

            .icon {
                margin: 0 5px 0 0;
                color: var(--text-3);
            }

            .icon.after {
                margin: 0 0 0 5px;
                color: var(--control);
            }

            small {
                display: block;
                font-size: 0.8125rem;
                font-weight: 300;

                /* An address has nowhere to break, so it is told it may */
                overflow-wrap: anywhere;
            }
        }

        /* Where one signer has got to, coloured by the same four readings
           the request itself uses */
        .state {
            flex: 0 1 auto;

            &.settled {
                color: var(--settled);
            }

            &.waiting {
                color: var(--text-3);
            }

            &.stopped {
                color: var(--text-3);
            }

            &.failed {
                color: var(--overdue);
                font-weight: 500;
            }
        }

        /* Pushed to the end of whatever line it lands on */
        .act {
            flex: 0 0 auto;
            margin-left: auto;
        }
    }

    /* What happened, in order. A list rather than a table, because it is
       read top to bottom and nothing in it lines up with anything else */
    ol.timeline {
        margin: 0;
        padding: 0;
        list-style: none;
        font-size: 0.8125rem;
        color: var(--text-3);

        li {
            display: flex;
            flex-wrap: wrap;
            align-items: baseline;
            gap: 0 8px;
            padding: 2px 0;

            /* What happened, which is a shape with its words in a tooltip -
               a column of the same six words reads as noise */
            > .icon {
                flex: 0 0 auto;
            }

            /* Both take what they need, so the time sits beside the name
               instead of against the far edge, and drops below it when
               there is no room for the two together */
            .who {
                flex: 0 1 auto;
                min-width: 0;
                color: var(--dark);

                .icon {
                    margin: 0 5px 0 0;
                    color: var(--text-3);
                }
            }

            .when {
                flex: 0 1 auto;
            }

            /* The plumbing of a request, which the control below asks for */
            &.quiet {
                display: none;
                color: var(--gray-7);

                .who {
                    color: var(--gray-7);
                }
            }
        }
    }

    /* Asks for the rows that are held back. Quiet itself, since it is an
       offer rather than something to do */
    a.more {
        display: inline-block;
        margin: 8px 0 0 0;
        font-size: 0.8125rem;
        color: var(--text-3);
        text-decoration: underline;

        &:hover,
        &:focus {
            color: var(--dark);
        }
    }

    /* The files that were sent, which are downloadable as they went rather
       than only as they came back */
    ul.files {
        margin: 0;
        padding: 0;
        list-style: none;
        font-size: 0.875rem;

        li {
            padding: 5px 0;

            + li {
                border-top: 1px solid var(--gray-4);
            }
        }

        /* Drawn as the document it is rather than as a link somewhere: the
           name is the thing, and the icon says what kind of thing */
        a {
            color: var(--dark);

            .icon {
                margin: 0 8px 0 0;
                color: var(--gray-7);
            }

            small {
                display: block;
                margin: 1px 0 0 26px;
                font-size: 0.75rem;
            }

            &:hover,
            &:focus {
                color: var(--primary);

                .icon {
                    color: var(--primary);
                }
            }
        }
    }
}

/* Files
---------------- */

/* What a list of files is narrowed by - a search, and a dropdown each for
   where the files came from, the client, and the tax year. The dropdowns are
   lists of links rather than selects, so that the page they narrow to is the
   one that says what it was narrowed by */
.narrowing {
    margin: 20px 0 0 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;

    .search {
        flex: 1 1 240px;
        max-width: 360px;

        .btn[type="submit"] {
            margin: 0;
        }

        /* The browser's own clear button only empties the box, leaving the
           list as it was searched - the one beside it reloads without it */
        input[type="search"]::-webkit-search-cancel-button {
            display: none;
        }

        .btn.clear {
            border: 1px var(--border) solid;
            border-left: 0;
            color: var(--control);
            background: var(--surface);

            &:hover {
                color: var(--control-hover);
            }
        }
    }

    /* Clears the search and every dropdown at once, beside the last of them,
       where it is seen along with what it clears */
    .reset {
        color: var(--text-3);
        font-size: 0.875rem;
        text-decoration: none;

        &:hover {
            color: var(--action);
        }

        .icon {
            margin: 0 4px 0 0;
        }
    }

    /* As tall as the search box, whose text is larger, so that their tops
       and bottoms line up - what the box's line and padding come to, less
       the button's own line */
    .dropdown-trigger {
        padding-top: calc((2.25rem - 1.5em) / 2) !important;
        padding-bottom: calc((2.25rem - 1.5em) / 2) !important;
        border: 1px var(--border) solid;
        color: var(--text-2);
        background: var(--surface);

        &:hover,
        &.show {
            border-color: var(--border-firm);
            color: var(--text);
        }

        /* A dropdown narrowed to anything but all of it, so that a list
           missing what was expected says why at a glance */
        &.narrowed {
            border-color: var(--action);
            color: var(--action);
        }

        .icon {
            margin: 0 6px 0 0;

            &.closing {
                margin: 0 0 0 6px;
            }
        }

        /* What it is narrowed to, e.g., a client, cut short where it is
           long, with its caret kept after it */
        > span {
            display: inline-block;
            max-width: 12rem;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            vertical-align: bottom;
        }
    }

    .dropdown-menu .hint {
        margin: 0;
        padding: 0 16px 4px 16px;
        max-width: 280px;
        color: var(--text-3);
        font-size: 0.8125rem;
        white-space: normal;
    }

    /* On a phone, the search takes a line of its own, and the dropdowns
       share the next one, two to a line, whatever each is narrowed to - and
       the reset, wrapped under them, is a button of the same height and edge
       as them, rather than a stray link on a line of its own */
    @media (max-width: 575.98px) {
        .search {
            flex-basis: 100%;
            max-width: none;
        }

        .dropdown {
            flex: 1 1 45%;
            min-width: 0;
        }

        /* Cut short, rather than pushing its neighbour onto another line,
           e.g., a long source or client narrowed to */
        .dropdown-trigger {
            width: 100%;
            padding-left: 10px !important;
            padding-right: 10px !important;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;

            /* What it is narrowed to gives way to its icon and caret */
            > span {
                max-width: calc(100% - 1.875em - 12px);
            }
        }

        .reset {
            padding: calc((2.25rem - 1.5em) / 2) 12px;
            border: 1px var(--border) solid;
            border-radius: 3px;
            color: var(--text-2);
            background: var(--surface);

            &:hover {
                border-color: var(--border-firm);
            }
        }
    }
}

.listable.files {
    td.name {
        /* An upload's notes, read on hover, since they are for the users
           rather than the list */
        .notes {
            margin: 0 0 0 4px;
            color: var(--text-3);
            cursor: help;
        }
    }

    /* The client a file is under, where a list covers more than one - cut
       short, since the file's name is what takes the row's spare width */
    td.client > span {
        display: inline-block;
        max-width: 16rem;
        overflow: hidden;
        text-overflow: ellipsis;
        vertical-align: bottom;
    }

    /* Where a file came from, on one line */
    td.source {
        white-space: nowrap;

        /* How a file came here - uploaded, sent, or e-signed - said by its
           icon alone, with the specifics in its tooltip */
        .how {
            color: var(--text-2);

            &:hover {
                color: var(--text);
            }
        }

        /* How many Messages an upload was sent with */
        .messages {
            margin: 0 0 0 8px;
            color: var(--text-3);
            font-size: 0.8125rem;
            text-decoration: none;

            .icon {
                margin: 0 2px 0 0;
            }
        }

        .cs-box {
            display: inline-block;
            margin-top: 0;
            vertical-align: middle;

            .cs {
                margin-top: 0;
            }
        }
    }
}

/* An upload that names and dates each of its files - the file and its tax
   year on one line, and its name under them, said rather than asked, since
   it starts out as the file's own. A Message's form carries the same rows */
form.uploading {
    /* The column heading over the tax years, only once there is a year
       under it - before a file is up, there is only the file */
    .file-heads {
        margin: 0 0 6px 0;
        display: none;
        justify-content: flex-end;
        color: var(--text-3);
        font-size: 0.8125rem;

        .year {
            flex: 0 0 100px;
        }
    }

    &:has(.file-line .year:not([hidden])) .file-heads {
        display: flex;
    }

    /* Each file is set off from the one before it, since a name under one
       file otherwise reads as belonging to the next */
    .file-row-container:has(+ .file-row-container) {
        margin: 0 0 14px 0;
    }

    .file-row-container + .file-row-container {
        padding: 14px 0 0 0;
        border-top: 1px var(--border-soft) solid;
    }

    .file-line {
        display: flex;
        gap: 10px;

        .file-row {
            flex: 1 1 auto;
            min-width: 0;
        }

        .year {
            flex: 0 0 100px;

            &[hidden] {
                display: none;
            }
        }
    }

    .naming {
        margin: 6px 0 0 0;

        &[hidden] {
            display: none;
        }

        .named {
            color: var(--text-3);
            font-size: 0.875rem;

            strong {
                color: var(--text-2);
                font-weight: 500;
            }

            /* Spaced by margin rather than by the space in the markup, which
               does not survive between two tags */
            [data-rename] {
                margin: 0 0 0 8px;
            }
        }

        .field-group {
            margin: 0;
        }
    }
}

/* Labels
---------------- */

/* A choice or a label on a thing - a quiet chip, with a choice's custom field
   before it on a darker shade of its own, so that "Entity Type S Corp" reads
   as one chip of two parts, and a label a pill in a tint of the brand blue,
   so that the two are told apart at a glance */
.chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 6px;
    color: var(--text);
    background: var(--surface-2);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
    cursor: default;

    /* The custom field - its own shade, out to the chip's edge, the change
       of shade being what parts it from the choice */
    .field {
        display: inline-block;
        margin: -2px 8px -2px -9px;
        padding: 2px 8px 2px 9px;
        border-radius: 6px 0 0 6px;
        color: var(--text-2);
        background: var(--gray-2);
    }

    /* A label */
    &.tag {
        border-radius: 999px;
        color: var(--primary);
        background: color-mix(in srgb, var(--blue) 14%, white);

        > .icon {
            color: inherit;
        }
    }

    > .icon {
        margin: 0 4px 0 0;
        color: var(--text-3);
        font-size: 0.6875rem;
    }

    /* Archived - it stays on what has it, stepped back behind a dashed
       edge, drawn inside, so that it stands as tall as the rest */
    &.archived {
        color: var(--text-2);
        background: var(--surface);
        box-shadow: inset 0 0 0 1px var(--border);
        cursor: help;

        .field {
            margin: 0 6px 0 0;
            padding: 0 6px 0 0;
            border-right: 1px var(--border) solid;
            border-radius: 0;
            background: none;
        }
    }
}

/* What a thing is labelled with, in a row or on a page of its own */
.chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    vertical-align: middle;
}

/* How many chips a row has, where it is too narrow to show them, with them
   in its tooltip */
.tally {
    color: var(--text-3);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    cursor: help;

    .icon {
        margin: 0 2px 0 0;
    }
}

/* The control that opens the labeler, after a thing's chips - small and
   quiet, as a row's controls are */
.labeler {
    margin: 0 0 0 4px;
    padding: 0 2px;
    border: 0;
    color: var(--gray-6);
    background: none;
    font-size: 0.75rem;
    vertical-align: middle;

    &:hover {
        color: var(--control-hover);
    }

    /* Alone, where there is nothing yet, it starts the cell */
    &:first-child {
        margin-left: 0;
    }

    /* On a page of its own, where there is nothing yet - an outline of a
       label, saying what it adds, in place of the chips it will make */
    &.chip {
        margin: 0;
        padding: 1px 9px;
        border: 1px var(--gray-5) dashed;
        border-radius: 999px;
        color: var(--text-3);
        font-size: 0.75rem;
        cursor: pointer;

        .icon {
            margin: 0 3px 0 0;
            font-size: 0.6875rem;
        }

        &:hover {
            border-color: var(--control-hover);
            color: var(--control-hover);
        }
    }
}

/* A list's labels column - the icon heads it, and its cells wrap their chips
   rather than stretching the row */
.listable {
    th.labels {
        color: var(--text-3);
    }

    td.labels {
        min-width: 40px;

        @media (min-width: 1200px) {
            min-width: 140px;
        }
    }

    tr:hover .labeler {
        color: var(--control);

        &:hover {
            color: var(--control-hover);
        }
    }
}

/* What a thing is labelled with on a page of its own, under its name */
.labelline {
    margin: 10px 0 0 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;

    .unlabelled {
        color: var(--text-3);
        font-size: 0.8125rem;
        font-weight: 300;
    }

    /* As a field on a form, e.g., editing a file */
    &.field {
        margin: 0;
        padding: 6px 0;
    }
}

/* What a list is filtered by - the dropdown, which finds a label or a choice
   as it is typed in, and scrolls, since an account can have many */
.labelfilter .dropdown-menu {
    width: 280px;
    max-width: calc(100vw - 32px);
    max-height: min(60vh, 480px);
    overflow-y: auto;

    .finder {
        padding: 2px 12px 8px 12px;
    }

    .set ul {
        margin: 0 0 4px 0;
        padding: 0;
        list-style: none;
    }

    .dropdown-header {
        padding: 6px 16px 2px 16px;
        color: var(--text-3);
        font-size: 0.75rem;
        font-weight: 600;
    }

    .dropdown-item {
        padding: 5px 16px;

        > .icon {
            margin: 0 7px 0 0;
            color: var(--gray-6);
        }

        /* On, which is said by the box rather than by Bootstrap's blue */
        &.active,
        &:active {
            color: var(--text);
            background: none;
            font-weight: 500;

            > .icon {
                color: var(--action);
            }
        }

        &.active:hover {
            background: var(--bs-dropdown-link-hover-bg);
        }

        /* Any choice of a custom field, or none, which are about the field
           rather than choices of it */
        &.general {
            color: var(--text-2);
            font-style: italic;
        }
    }

    .hint {
        padding-top: 6px;
        border-top: 1px var(--border-soft) solid;
    }
}

/* What is filtered by, a line of its own under the rest of what the list is
   narrowed by, last, whatever comes after it in the page - each turns itself
   off, and is in the action ink, as a narrowed dropdown is */
.labelchosen {
    order: 1;
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;

    .chip.chosen {
        border: 1px var(--action) solid;
        color: var(--action);
        background: var(--surface);
        text-decoration: none;
        cursor: pointer;

        .field {
            border-radius: 5px 0 0 5px;
            color: var(--action);
            background: color-mix(in srgb, var(--action) 12%, white);
        }

        .icon {
            margin: 0 0 0 4px;
            font-size: 0.6875rem;
        }

        /* Every part a step darker, together, so that the chip reads as
           pressed as one */
        &:hover {
            border-color: color-mix(in srgb, var(--action) 80%, black);
            color: color-mix(in srgb, var(--action) 80%, black);
            background: color-mix(in srgb, var(--action) 8%, white);

            .field {
                color: inherit;
                background: color-mix(in srgb, var(--action) 20%, white);
            }
        }
    }
}

/* The finder over the custom fields and labels, and the two columns of them */
.labeltools {
    margin: 20px 0 0 0;

    /* The finder, and the kinds to narrow to, side by side, the kinds
       dropping under the finder where there is not the room */
    .filters {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px 20px;
    }

    /* The kinds of thing to narrow both panels to what applies to - a box
       per kind, as on the forms, only smaller, which takes the action ink
       once ticked */
    .kindfilter {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;

        > span {
            margin: 0 4px 0 0;
            color: var(--text-3);
            font-size: 0.8125rem;
            font-weight: 300;
        }

        label {
            display: flex;
            align-items: center;
            gap: 6px;
            margin: 0;
            padding: 5px 10px;
            border: 1px var(--border) solid;
            border-radius: 4px;
            background: var(--surface);
            font-size: 0.8125rem;
            cursor: pointer;

            /* As tall as its name's line makes it, padding, and edge, even
               where the name is not shown */
            min-height: calc(1.5em + 12px);

            /* On a phone, the icon stands in for the name, as a tab's does,
               so that all of them fit on one line */
            > span {
                @media (max-width: 575.98px) {
                    display: none;
                }
            }

            .form-check-input {
                flex: none;
                margin: 0;
                cursor: pointer;
            }

            .icon {
                color: var(--text-3);
            }

            &:hover {
                border-color: var(--border-firm);
            }

            &:has(:checked) {
                border-color: var(--action);
                background: color-mix(in srgb, var(--action) 6%, white);

                .icon {
                    color: var(--action);
                }
            }
        }
    }

    .finder {
        position: relative;
        flex: 1 1 260px;
        max-width: 360px;

        > .icon {
            position: absolute;
            top: 50%;
            left: 11px;
            transform: translateY(-50%);
            color: var(--text-3);
            pointer-events: none;
        }

        input {
            padding-left: 34px;
        }

        input[type="search"]::-webkit-search-cancel-button {
            cursor: pointer;
        }
    }

    .list-toggle {
        margin-top: 15px;
    }


    > .message {
        margin: 20px 0 0 0;
    }

    /* How much of each kind has one, as the kind's icon and its count */
    .uses {
        display: inline-flex;
        gap: 10px;
        color: var(--text-3);
        font-size: 0.8125rem;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
        cursor: default;

        .icon {
            margin: 0 3px 0 0;
        }

        .none {
            font-weight: 300;
        }

        /* A count that opens a list, or unfolds into the clients that have
           them - drawn as the rest are, until hovered */
        a,
        button {
            padding: 0;
            border: 0;
            color: inherit;
            background: none;
            text-decoration: none;
            cursor: pointer;

            &:hover {
                color: var(--action);
            }
        }
    }

    /* A count of files or e-sign requests, unfolded into the clients that
       have them, on a line of its own under its row, each client opening its
       own list, filtered by it */
    .spread {
        order: 1;
        flex-basis: 100%;
        margin: 0;
        padding: 2px 0 0 0;
        list-style: none;
        font-size: 0.8125rem;

        li {
            display: flex;
            gap: 12px;
            padding: 3px 0;
            border-top: 0;

            a {
                text-decoration: none;

                .icon {
                    margin: 0 4px 0 0;
                    color: var(--text-3);
                }

                &:hover {
                    text-decoration: underline;
                }
            }

            .n {
                margin-left: auto;
                color: var(--text-3);
                font-variant-numeric: tabular-nums;
            }
        }
    }

    /* What a custom field or a label applies to, as the kinds' icons */
    .kinds {
        display: inline-flex;
        gap: 6px;
        color: var(--text-3);
        font-size: 0.8125rem;
        cursor: default;
    }

    /* The menu at the end of each, as at the end of a row */
    .controls {
        .control {
            color: var(--gray-6);

            &:hover {
                color: var(--control-hover);
            }
        }

        .dropdown-menu form {
            margin: 0;
        }
    }

    li.archived > .chip {
        color: var(--text-2);
        background: var(--surface);
        box-shadow: inset 0 0 0 1px var(--border);
    }
}

/* The custom fields, and the labels, each in a panel of its own - capped by
   what it holds, how many, the way to add one, and what one is, with an
   example, in a band a step darker than the panel under it */
.labelpanel {
    margin: 15px 0 0 0;
    border-radius: 4px;
    background: var(--gray-3);
    box-shadow: 1px 1px 0 0 rgba(0, 0, 0, 0.08);

    > header {
        padding: 12px 20px 13px 20px;
        border-radius: 4px 4px 0 0;
        background: var(--surface-3);

        .heading {
            display: flex;
            align-items: center;
            gap: 12px;

            h2 {
                flex: 1 1 auto;
                margin: 0;

                small {
                    margin: 0 0 0 4px;
                    font-size: 0.8125rem;
                    font-weight: 400;
                    font-variant-numeric: tabular-nums;
                }
            }

            .btn {
                margin: 0;

                .icon {
                    margin: 0 6px 0 0;
                }
            }
        }

        p {
            margin: 9px 0 0 0;
            color: var(--text-2);
            font-size: 0.8125rem;
            font-weight: 300;
            line-height: 1.6;
        }

        /* What one looks like, said to be an example, and drawn as an
           outline of a chip rather than as one, so that it is not taken
           for something the account has */
        .example {
            margin: 6px 0 0 0;
            color: var(--text-3);
            font-size: 0.6875rem;
            font-weight: 600;
            letter-spacing: 0.04em;
            text-transform: uppercase;

            .chip {
                margin: 0 0 0 8px;
                padding: 0 6px;
                border: 1px var(--gray-5) dashed;
                color: var(--text-2);
                background: none;
                font-size: 0.8125rem;
                font-weight: 400;
                letter-spacing: 0;
                text-transform: none;

                .field {
                    margin: 0 6px 0 0;
                    padding: 0 6px 0 0;
                    border-right: 1px var(--gray-5) dashed;
                    border-radius: 0;
                    background: none;
                }
            }
        }
    }

    /* Said in place of the rows, where there are none */
    .empty {
        margin: 0;
        padding: 14px 20px 16px 20px;
        color: var(--text-3);
        font-size: 0.8125rem;
        font-weight: 300;
    }
}

/* A custom field - a line of the custom fields' panel, ruled off from the
   one above it, which opens on its choices. What it applies to, and its
   menu, sit at the end of the line, outside what opens it, so that using
   them does not */
.attribute {
    position: relative;
    padding: 11px 20px 11px 20px;
    border-top: 1px var(--gray-4) solid;

    header + & {
        border-top: 0;
    }

    .tools {
        position: absolute;
        top: 11px;
        right: 20px;
        display: flex;
        align-items: center;
        gap: 12px;
        line-height: 1.5rem;
    }

    /* The line itself - an angle, which points down once it is open, its
       name, how many choices it has, and its mode, where anybody may type
       a choice in */
    summary {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0 120px 0 0;
        line-height: 1.5rem;
        list-style: none;
        cursor: pointer;

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

        > .icon {
            margin: 0 0 0 -4px;
            color: var(--text-3);
            font-size: 0.75rem;
        }

        h3 {
            margin: 0;
            font-size: 0.9375rem;
            font-weight: 700;

            .icon {
                margin: 0 5px 0 0;
                color: var(--text-3);
            }
        }

        small {
            color: var(--text-3);
            font-size: 0.8125rem;
            font-weight: 300;
            font-variant-numeric: tabular-nums;
        }

        .mode {
            padding: 0 6px;
            border: 1px var(--border-firm) solid;
            border-radius: 2px;
            color: var(--text-2);
            font-size: 0.6875rem;
            font-weight: 600;
            letter-spacing: 0.04em;
            line-height: 1.5;
            text-transform: uppercase;
            cursor: help;
        }

        &:hover h3 {
            color: var(--action);
        }
    }

    details[open] > summary > .icon {
        transform: rotate(90deg);
    }

    /* What has the custom field's choices, said in a line under its name */
    .usage {
        margin: 3px 0 0 0;
        color: var(--text-3);
        font-size: 0.8125rem;
        font-weight: 300;
    }

    /* A choice that was typed in, rather than defined, said after it */
    .typed {
        color: var(--text-3);
        font-size: 0.75rem;
        font-weight: 300;
        font-style: italic;
        cursor: help;
    }

    /* The way to add choices, under the ones there are */
    .more {
        display: inline-block;
        margin: 6px 0 0 0;
        font-size: 0.8125rem;
        text-decoration: none;

        .icon {
            margin: 0 4px 0 0;
            font-size: 0.6875rem;
        }

        &:hover {
            text-decoration: underline;
        }
    }

    .choices {
        margin: 7px 0 0 0;
        padding: 0;
        list-style: none;

        li {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 12px;
            padding: 4px 0;

            .chip {
                background: var(--surface);
            }

            .uses {
                margin-left: auto;
            }
        }
    }

    .empty {
        padding: 5px 0 2px 0;
    }

    &.archived h3 {
        color: var(--text-2);
        font-weight: 400;
    }
}

/* The labels, one to a line of the labels' panel */
.labellist {
    margin: 0;
    padding: 6px 20px 8px 20px;
    list-style: none;

    li {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 12px;
        padding: 7px 0;
        border-top: 1px var(--gray-4) solid;

        &:first-child {
            border-top: 0;
        }

        .chip {
            background: var(--surface);
        }

        .uses {
            margin-left: auto;
        }
    }
}

/* What a custom field or a label applies to, on its form - a box per kind,
   each with the kind's icon, two to a line, which takes the action ink once
   ticked, as anything chosen does */
.applies {
    .options {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;

        > label {
            display: flex;
            align-items: center;
            gap: 8px;
            margin: 0;
            padding: 9px 12px;
            border: 1px var(--border) solid;
            border-radius: 4px;
            font-size: 0.875rem;
            cursor: pointer;

            .form-check-input {
                flex: none;
                margin: 0;
                cursor: pointer;
            }

            .icon {
                color: var(--text-3);
            }

            &:hover {
                border-color: var(--border-firm);
            }

            &:has(:checked) {
                border-color: var(--action);
                background: color-mix(in srgb, var(--action) 6%, white);

                .icon {
                    color: var(--action);
                }
            }
        }

        @media (max-width: 479.98px) {
            grid-template-columns: 1fr;
        }
    }
}

/* Whether a custom field's choices are defined - a switch, with what it
   does said beside it, heading a panel that opens under it with the
   choices, while it is on */
.defining {
    border: 1px var(--border) solid;
    border-radius: 4px;

    .toggle {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        margin: 0;
        padding: 10px 12px;
        cursor: pointer;

        .form-check-input {
            flex: none;
            margin: 2px 0 0 0;
            cursor: pointer;
        }

        span {
            color: var(--text-2);
            font-size: 0.8125rem;
            font-weight: 300;
            line-height: 1.5;

            strong {
                display: block;
                color: var(--text);
                font-size: 0.875rem;
                font-weight: 600;
            }
        }
    }

    > .invalid-feedback {
        margin: 0 12px 10px 12px;
    }

    /* What the switch opens - set into the box, a step darker, so that it
       reads as belonging to the switch over it */
    .panel {
        padding: 12px 12px 12px 12px;
        border-top: 1px var(--border-soft) solid;
        border-radius: 0 0 4px 4px;
        background: var(--surface-4);

        .message {
            margin: 0 0 12px 0;
            font-size: 0.8125rem;
        }

        /* The choices there are already, over the ones being added */
        .chips {
            display: flex;
            margin: 0 0 12px 0;

            .chip {
                background: var(--surface);
                box-shadow: inset 0 0 0 1px var(--border-soft);
            }
        }

        .form-text {
            margin: 6px 0 0 0;
        }
    }
}

/* What becomes of the things that have a choice or a label being deleted -
   one outcome to a box, as what something applies to is, with what each
   does said under it */
.outcomes {
    display: grid;
    gap: 8px;
    margin: 0 0 16px 0;

    .outcome {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        margin: 0;
        padding: 10px 12px;
        border: 1px var(--border) solid;
        border-radius: 4px;
        cursor: pointer;

        .form-check-input {
            flex: none;
            margin: 2px 0 0 0;
            cursor: pointer;
        }

        span {
            color: var(--text-2);
            font-size: 0.8125rem;
            font-weight: 300;
            line-height: 1.5;

            strong {
                display: block;
                color: var(--text);
                font-size: 0.875rem;
                font-weight: 600;
            }
        }

        &:hover {
            border-color: var(--border-firm);
        }

        &:has(:checked) {
            border-color: var(--action);
            background: color-mix(in srgb, var(--action) 6%, white);
        }
    }

    /* What they are moved to, under the outcome that moves them */
    .into {
        margin: -2px 0 2px 0;
    }
}

/* What still has a custom field or a label whose kind was being unticked,
   each linked, so that it can be cleared first - in the attention colours, as
   a warning is */
.blocked {
    margin: 15px 0 5px 0;
    padding: 12px 15px;
    border: 1px var(--warning) solid;
    border-radius: 4px;
    background: color-mix(in srgb, var(--warning) 10%, white);
    font-size: 0.875rem;

    h4 {
        margin: 0 0 8px 0;
        font-size: 0.8125rem;
        font-weight: 600;
    }

    ul {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    > ul > li {
        margin: 0 0 6px 0;

        > .icon {
            margin: 0 6px 0 0;
            color: var(--text-3);
        }
    }

    .places {
        margin: 4px 0 0 26px;
    }
}

/* The labeler's selects, which carry labels as the pills a row shows them
   as, rather than as the select control's blue items */
form.labeling {
    /* What a multiple select has picked already, which the select control
       lists again while searching, where picking it again does nothing */
    .choices[data-type="select-multiple"] .choices__list--dropdown .choices__item.is-selected {
        display: none;
    }

    .choices__inner .choices__list--multiple .choices__item {
        border: 0;
        color: var(--primary);
        background: color-mix(in srgb, var(--blue) 14%, white);
        border-radius: 999px;
        font-weight: 500;

        /* The way to take one off, with no rule between it and the name,
           which the chip's own edge is enough for */
        .choices__button {
            margin: 0 0 0 2px;
            padding-left: 10px;
            border-left: 0;
            filter: invert(0.6);
        }
    }

    .hint {
        margin: 4px 0 0 0;
        color: var(--text-3);

        .icon {
            margin: 0 5px 0 0;
        }
    }
}

/* Signers
---------------- */

/* The signers of a request being created, each a row that can be dragged into
   the order they are asked in */
.signer-rows {

    /* Set a little further from the last row than the rows are from each
       other, so that it reads as under the list rather than as part of it */
    [data-signer-add] {
        margin: 5px 0 0 0;
    }

    .signer-row {
        display: flex;
        gap: 8px;
        align-items: start;
        padding: 8px;
        border: 1px var(--gray-2) solid;
        border-radius: 4px;
        margin: 0 0 8px 0;
        background: var(--surface-3);

        /* The row being dragged, lifted just enough to be obviously the one
           that is moving */
        &.dragging {
            border-color: var(--action);
            box-shadow: 0 2px 8px rgb(0 0 0 / 12%);
        }

        /* Only shown where the order means something - see below */
        .handle {
            display: none;
            padding: 6px 0 0 0;
            color: var(--control);
            cursor: grab;
        }

        /* The person, which is the row's main control and takes the room left
           over */
        .who {
            flex: 1 1 auto;
            min-width: 0;

            .field-group {
                margin: 0;
            }

            .form-label {
                display: none;
            }
        }

        .verify {
            flex: 0 1 16rem;
            margin: 0 0 0 5px;

            .form-text {
                font-size: 0.75rem;
            }
        }

        .control {
            padding: 6px 0 0 0;
            border: 0;
            background: none;
        }
    }

    /* The handle, shown where the signers are asked in order, and there is
       more than one of them to order - never on a touch screen, where a drag
       scrolls the page rather than moving the row */
    @media (hover: hover) {
        .ordered:not(.single) .signer-row .handle {
            display: block;
        }
    }

    /* A lone signer cannot be removed, since a request needs somebody to sign
       it */
    .single .signer-row .control {
        display: none;
    }
}

/* At phone width the checkbox drops to a line of its own, since a dropdown
   and a checkbox side by side leave neither enough room to read - the handle,
   order, and remove stay on the dropdown's line, which gives them its room */
@media (max-width: 767px) {
    .signer-rows .signer-row {
        flex-wrap: wrap;

        .who {
            flex: 1 1 0;
        }

        .verify {
            flex: 1 1 100%;
            order: 1;
            margin: 0;
        }
    }
}

/* Editor
---------------- */

/* The provider's document editor and signing ceremony, framed on our own
   page. Their own guidance is that it wants 1360 x 768, so it is given the
   full width available and a tall frame rather than being boxed in */
.editor,
.ceremony {
    position: relative;

    /* Clear of whatever names the document above it, rather than against it */
    margin: 15px 0 20px 0;
    border: 1px var(--gray-3) solid;
    border-radius: 4px;
    overflow: hidden;
    background: var(--surface);

    iframe {
        display: block;
        width: 100%;
        height: min(82vh, 1100px);
        min-height: 620px;
        border: 0;
    }

    /* Sized by common.js to fit the window, which can be shorter than the
       floor above - a frame taller than the window hides the provider's
       first control, pinned to the frame's foot */
    &.fitted iframe {
        height: var(--fit);
        min-height: 0;
    }

    /* Shown until the frame says it has loaded, so the Admin is not looking
       at an empty rectangle wondering whether it is broken */
    .loading {
        padding: 4rem 1rem;
        text-align: center;

        .icon {
            color: var(--control);
            font-size: 2rem;
        }

        .note {
            margin: 1.5rem 0 0;
            color: var(--text-3);
        }
    }
}

/* The way back up from a fitted frame, which takes the scroll wherever the
   pointer is over it - placed by common.js in the margin beside the frame */
button.up {
    position: fixed;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px var(--border-soft) solid;
    border-radius: 50%;
    background: var(--surface);
    color: var(--control);
    box-shadow: 0 2px 8px rgb(0 0 0 / 12%);
    transition: color 120ms ease-out, box-shadow 120ms ease-out;

    &:hover,
    &:focus-visible {
        color: var(--control-hover);
        box-shadow: 0 4px 14px rgb(0 0 0 / 18%);
    }

    /* Too little margin beside the frame to hold it, e.g., on a phone, or
       the page moved up from the frame */
    &.cramped,
    &.away {
        display: none;
    }

    @media (prefers-reduced-motion: no-preference) {
        animation: rise 200ms cubic-bezier(0.16, 1, 0.3, 1) both;
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

/* The page an Admin waits on while a task prepares a request. It stands alone,
   so it is centred and given room.

   Named for what it is rather than for what it is doing: "waiting" is also one
   of the four readings a row can have, and a rule by that name would reach
   into every list that uses them */
.preparation {
    padding: 4rem 1rem;
    text-align: center;

    .icon {
        color: var(--control);
        font-size: 3rem;
    }

    .note {
        margin: 1.5rem 0 0.5rem;
        color: var(--text-3);
    }

    .btn {
        margin-top: 1.5rem;
    }

    /* The one that went wrong, which is the only state worth colouring */
    .failed .icon {
        color: var(--overdue);
    }
}

/* Alternative
---------------- */

/* A second way to do what the form above does, e.g., signing in with Google
   rather than with a password - ruled off, so that it reads as another way
   in rather than as another step */
.alternative {
    margin: 25px 0 0 0;

    .rule {
        display: block;
        margin: 0 0 15px 0;
        font-size: 0.8125rem;
        color: var(--text-3);
        text-align: center;
        overflow: hidden;

        /* The rule is drawn either side of the word, rather than behind it */
        &::before,
        &::after {
            content: '';
            display: inline-block;
            width: 50%;
            height: 1px;
            position: relative;
            vertical-align: middle;
            background: var(--border);
        }

        &::before {
            right: 12px;
            margin: 0 0 0 -50%;
        }

        &::after {
            left: 12px;
            margin: 0 -50% 0 0;
        }
    }
}

/* Sign-in
---------------- */

/* The steps of signing in - a passkey, a password, an emailed code - each a
   shell of its own, with one obvious thing to press */
.signin {
    /* A link-like control in a line of text, e.g., "use your password
       instead", which sits on the line rather than as a button beside it */
    .btn.link.inline {
        margin: 0;
        padding: 0 !important;
        border: 0;
        vertical-align: baseline;
        font-size: inherit;
        color: var(--action);
        font-weight: 400;

        &:hover {
            text-decoration: underline;
        }
    }

    /* An emailed code - larger than the text around it, and in figures that
       line up, so that each digit can be checked against the email */
    input.code {
        max-width: 12rem;
        font-size: 1.375rem;
        font-variant-numeric: tabular-nums;
    }

    /* Sending another code, and when the last one went */
    .resend {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        margin: 0 0 15px 0;

        .btn[type="submit"] {
            margin: 0;
        }
    }

    /* A choice between two ways in, e.g., a passkey or a password, drawn the
       way the context bar draws its links */
    .tabs {
        menu {
            display: flex;
            flex-wrap: wrap;
            gap: 5px;
            margin: 0 0 15px 0;
            padding: 0;
            list-style: none;

            /* Hidden until common.js knows passkeys can be used, which the
               flex above would otherwise outrank */
            &.none {
                display: none;
            }

            /* Big enough to find and to tap on a phone, and outlined, so
               that the one not chosen still reads as a button */
            button {
                padding: 10px 14px;
                border: 1px solid color-mix(in srgb, var(--text) 15%, transparent);
                border-radius: 3px;
                font-size: 0.875rem;
                line-height: 1.25;
                color: var(--text);
                background: transparent;

                &:hover {
                    background: color-mix(in srgb, var(--text) 5%, transparent);
                }

                &.active {
                    background: color-mix(in srgb, var(--text) 15%, transparent);
                }

                .icon {
                    margin-right: 5px;
                }
            }
        }
    }
}

/* Agreements
-------------------------------------------------------------------------- */

/* The agreements a person has to accept before going on, and the page that
   shows one of them on its own - a single centred column, since there is
   nothing beside it to read */
.agreements {
    margin: 10px auto 40px auto;

    /* What the page is asking, said once above the documents */
    .intro {
        margin: 0 0 25px 0;

        .eyebrow {
            margin: 0 0 6px 0;
            font-size: 0.75rem;
            font-weight: 500;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--text-3);
        }

        h1 {
            font-size: 1.75rem;
            font-weight: 500;
            letter-spacing: -0.01em;

            @media (max-width: 767.98px) {
                font-size: 1.375rem;
            }
        }

        .lede {
            margin: 8px 0 0 0;
            max-width: 40rem;
            font-size: 1rem;
            line-height: 1.55;
            color: var(--text-2);
        }
    }

    /* The buttons under the documents */
    .actions {
        display: flex;
        margin: 5px 0 0 0;
        gap: 4px;
        align-items: center;
        flex-wrap: wrap;

        .btn.primary {
            padding: 10px 24px !important;
            font-size: 0.9375rem;
        }

        @media (max-width: 575.98px) {
            .btn {
                width: 100%;
                text-align: center;
            }
        }
    }
}

/* An agreement document, e.g., the EULA - a card, with the text under a
   heading that names and dates it */
.agreement {
    margin: 0 0 25px 0;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(21, 29, 39, 0.04), 0 8px 24px rgba(21, 29, 39, 0.05);

    &.invalid {
        border-color: var(--danger);
    }

    /* Not a header element, since the page header is styled by that name */
    .heading {
        display: flex;
        padding: 18px 22px;
        gap: 15px;
        align-items: flex-start;
        justify-content: space-between;
        border-bottom: 1px solid var(--border-soft);

        h1,
        h2 {
            margin: 0;
            font-size: 1.125rem;
            font-weight: 600;
            letter-spacing: -0.005em;
            text-transform: none;
            color: var(--text);
        }

        /* Which version, and since when */
        .meta {
            display: flex;
            margin: 5px 0 0 0;
            gap: 8px;
            align-items: center;
            font-size: 0.8125rem;
            color: var(--text-3);

            .version {
                padding: 1px 8px;
                border: 1px solid var(--border);
                border-radius: 999px;
                font-size: 0.6875rem;
                font-weight: 500;
                font-variant-numeric: tabular-nums;
                color: var(--text-2);
            }
        }

        /* The link to the document on its own page */
        .open {
            flex: none;
            padding: 5px 10px;
            border: 1px solid var(--border-soft);
            border-radius: 6px;
            font-size: 0.8125rem;
            font-weight: 500;
            color: var(--text-2);
            white-space: nowrap;

            .icon {
                margin: 0 4px 0 0;
                font-size: 0.75rem;
            }

            &:hover {
                border-color: var(--border);
                color: var(--text);
                text-decoration: none;
                background: var(--surface-4);
            }
        }
    }

    /* That it changed since it was last agreed to, said before the text */
    .changed {
        margin: 0;
        padding: 10px 22px;
        border-bottom: 1px solid var(--border-soft);
        font-size: 0.875rem;
        color: var(--action);
        background: color-mix(in srgb, var(--action) 6%, white);

        .icon {
            margin: 0 6px 0 0;
        }
    }

    /* The rendered markdown */
    .body {
        padding: 20px 22px;
        font-size: 0.9375rem;

        h1,
        h2,
        h3,
        h4 {
            margin: 1.75rem 0 0.625rem 0;
            font-size: 1rem;
            font-weight: 600;
            letter-spacing: -0.005em;
            text-transform: none;
            color: var(--text);

            &:first-child {
                margin-top: 0;
            }
        }

        h2 {
            font-size: 1.0625rem;
        }

        h3 {
            font-size: 0.9375rem;
            color: var(--text-2);
        }

        p,
        li {
            line-height: 1.65;
            color: var(--text);
        }

        ol,
        ul {
            padding-left: 1.5rem;
        }

        li {
            margin: 0 0 0.5rem 0;
        }

        strong {
            font-weight: 600;
        }

        table {
            width: 100%;
            margin: 0 0 1rem 0;
            font-size: 0.875rem;

            th,
            td {
                padding: 0.5rem 0.625rem;
                border-bottom: 1px solid var(--border-soft);
                vertical-align: top;
                text-align: left;
            }

            th {
                font-weight: 600;
                color: var(--text-2);
            }
        }

        /* The last thing in the box does not need room under it */
        > :last-child {
            margin-bottom: 0;
        }
    }

    /* Boxed, on the page that asks for it to be agreed to - the text is
       previewed, its first lines fading out over the link that unfolds it */
    &.boxed {
        .excerpt {
            --line: calc(0.9375rem * 1.65);

            position: relative;

            .body {
                max-height: calc(20px + var(--line) * 4);
                overflow: hidden;
                mask-image: linear-gradient(
                    to bottom,
                    black calc(20px + var(--line) * 2),
                    transparent
                );
            }

            /* The link that unfolds the text, sitting on the faded lines */
            .expand {
                position: absolute;
                bottom: 10px;
                left: 50%;
                padding: 5px 12px;
                border: 1px solid var(--border-soft);
                border-radius: 999px;
                font-size: 0.8125rem;
                font-weight: 500;
                color: var(--text-2);
                white-space: nowrap;
                background: var(--surface);
                transform: translateX(-50%);

                .icon {
                    margin: 0 4px 0 0;
                    font-size: 0.6875rem;
                }

                &:hover {
                    border-color: var(--border);
                    color: var(--text);
                    background: var(--surface-4);
                }
            }

            /* Unfolded, the text scrolls inside the card, so that the
               checkbox under it stays near */
            &.unfolded {
                .body {
                    max-height: 48vh;
                    overflow-y: auto;
                    overscroll-behavior: contain;
                    mask-image: none;

                    /* A fade over the last lines, saying there is more below */
                    &::after {
                        content: '';
                        display: block;
                        position: sticky;
                        bottom: -20px;
                        height: 36px;
                        margin: -36px -22px -20px -22px;
                        background: linear-gradient(to bottom, transparent, var(--surface));
                        pointer-events: none;
                    }
                }

                .expand {
                    display: none;
                }
            }
        }

        /* The checkbox that agrees to it - a row of its own, under the text,
           with room around it so it reads as the step it is */
        .consent {
            padding: 16px 22px;
            border-top: 1px solid var(--border-soft);
            background: var(--surface-4);

            .form-check {
                display: flex;
                margin: 0;
                padding: 0;
                gap: 12px;
                align-items: flex-start;
                flex-wrap: wrap;

                .form-check-input {
                    flex: none;
                    width: 1.25rem;
                    height: 1.25rem;
                    margin: 1px 0 0 0;
                    border-color: var(--border-firm);
                    cursor: pointer;

                    &:checked {
                        border-color: var(--action);
                        background-color: var(--action);
                    }
                }

                .form-check-label {
                    flex: 1;
                    font-size: 0.9375rem;
                    line-height: 1.45;
                    cursor: pointer;

                    strong {
                        font-weight: 500;
                    }
                }

                .invalid-feedback {
                    width: 100%;
                    margin: 0 0 0 calc(1.25rem + 12px);
                }
            }
        }
    }
}

/* The agreements a user has accepted, listed on their settings page */
ul.accepted {
    margin: 0;
    padding: 0;
    list-style: none;

    li {
        margin: 0 0 8px 0;

        &:last-child {
            margin-bottom: 0;
        }
    }

    .subtle {
        display: block;
        font-size: 0.8125rem;
    }
}

/* The devices a user logs in with - a Contact's passkeys, and anybody's
   authenticator app - listed on their settings page, each with a button
   removing it */
ul.devices {
    margin: 0;
    padding: 0;
    list-style: none;

    li {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin: 0 0 12px 0;

        &:last-child {
            margin-bottom: 0;
        }
    }

    .subtle {
        display: block;
        font-size: 0.8125rem;
    }

    /* The remove button keeps its width, leaving the details to wrap */
    form {
        flex-shrink: 0;

        .btn {
            white-space: nowrap;
        }
    }
}

/* Setting up an authenticator app: the steps, with the QR code to scan, and
   the key to type where it can't be */
.authenticator {
    ol.steps {
        margin: 0 0 16px 0;
        padding-left: 20px;

        li {
            margin: 0 0 12px 0;
        }
    }

    .qr {
        margin: 12px 0;

        svg {
            display: block;
            background: #fff;
        }
    }

    .secret {
        font-family: monospace;
    }
}
