/* ---------------------------------------------------------------------------
   Shell: the sidebar (components/sidebar.html) and the phone's bar above the
   page (components/nav.html). Three states, set from base.html's script:

     wide (md and up)    sticky beside the page, labels showing
     rail (md and up)    html[data-sidebar="rail"]: icons only, a label shown
                         beside the icon under the pointer or the focus
     drawer (below md)   off the screen until [data-open], over the page

   Rules rather than utilities because the states are the html element's and the
   sidebar's attributes, which each element below would otherwise have to repeat.
   The colours are theme.css's --color-aines-* variables.
   --------------------------------------------------------------------------- */

/* The height above the page that is not the page's: the phone's bar, none beside
   the sidebar. A page sized to the viewport subtracts it.
   --shell-page-left is where the page starts: past the sidebar beside it, none
   on a phone. Anything fixed to the page's edge (the report's quick-actions bar)
   starts there. */
:root {
    --shell-bar: 3.5rem;
    --shell-sidebar-width: 15.5rem;
    --shell-page-left: 0px;
}

.shell-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--shell-bar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem 0 1rem;
    background: #fff;
    border-bottom: 1px solid var(--color-aines-line);
}

.shell-logo {
    display: inline-flex;
    align-items: center;
    border-radius: 0.375rem;
}

.shell-icon-button {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    color: var(--color-aines-ink-faint);
}
.shell-icon-button:hover {
    background: var(--color-aines-surface);
    color: var(--color-aines-ink);
}

.shell-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: var(--shell-sidebar-width);
    flex-shrink: 0;
    padding: 1.25rem 0.75rem 0.875rem;
    background: #fff;
    border-right: 1px solid var(--color-aines-line);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.shell-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 2.25rem;
    padding-left: 0.625rem;
}
/* Level with the logo, straddling the sidebar's right border. */
.shell-rail-toggle {
    position: absolute;
    top: 1.5rem;
    right: calc(-0.875rem - 0.5px);
    z-index: 1;
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 1px solid var(--color-aines-line);
    border-radius: 9999px;
    background: #fff;
    color: var(--color-aines-ink-muted);
    box-shadow: 0 1px 3px rgb(15 14 12 / 0.12);
}
.shell-rail-toggle:hover {
    border-color: var(--color-aines-green);
    background: var(--color-aines-green-wash);
    color: var(--color-aines-green-deep);
}
.shell-logo-full {
    height: 1.625rem;
    width: auto;
}
.shell-logo-mark {
    display: none;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
}
.shell-when-rail {
    display: none;
}

/* The pages scroll, and only they: the logo and the foot stay put, and the
   account menu, which opens out of the foot and past a narrowed sidebar's edge,
   is not inside a box that would clip it. The padding keeps a focused link's
   outline inside the scrolling box. */
.shell-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin: -0.25rem;
    padding: 0.25rem;
}
.shell-nav ul {
    display: grid;
    gap: 0.125rem;
}

/* A page, and the foot's buttons, which look the same. */
.shell-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    color: var(--color-aines-ink-muted);
    text-align: left;
    text-decoration: none;
}
.shell-link:hover {
    background: var(--color-aines-surface);
    color: var(--color-aines-ink);
}
.shell-link[aria-current="page"] {
    background: var(--color-aines-green-wash);
    color: var(--color-aines-green-deep);
    font-weight: 600;
}
.shell-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A sub-page sits under its parent's label, on a line down from the parent's icon,
   marked by the logo's dot on that line when open. */
.shell-sub {
    padding-left: 2.625rem;
    font-size: 0.8125rem;
}
.shell-sub::after {
    content: "";
    position: absolute;
    left: calc(1.25rem + 0.21875rem - 0.5px);
    top: -0.125rem;
    bottom: 0;
    width: 1px;
    background: var(--color-aines-line);
}
.shell-sub[aria-current="page"]::before {
    content: "";
    position: absolute;
    z-index: 1;
    left: 1.25rem;
    top: 50%;
    width: 0.4375rem;
    height: 0.4375rem;
    margin-top: -0.21875rem;
    border-radius: 9999px;
    background: var(--color-aines-green);
}

.shell-foot {
    display: grid;
    gap: 0.125rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-aines-line-soft);
}
.shell-account {
    position: relative;
}
.shell-user {
    gap: 0.625rem;
    padding: 0.375rem 0.5rem;
}
.shell-user[aria-expanded="true"] {
    background: var(--color-aines-surface);
}

/* Opens upwards out of the foot, over the pages above it; past a narrowed
   sidebar's edge. */
.shell-account-menu {
    position: absolute;
    bottom: calc(100% + 0.375rem);
    left: 0;
    z-index: 10;
    width: 14rem;
    padding: 0.375rem;
    background: #fff;
    border: 1px solid var(--color-aines-line);
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgb(15 14 12 / 0.12);
}
.shell-account-who {
    display: grid;
    padding: 0.5rem 0.625rem 0.625rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--color-aines-line-soft);
    line-height: 1.125rem;
}
.shell-account-who > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.shell-account-email {
    color: var(--color-aines-ink-faint);
    font-size: 0.75rem;
}

/* The narrowed sidebar's name for the icon under the pointer or the focus: one
   element on <body>, placed by base.html's script. */
.shell-tooltip {
    position: fixed;
    z-index: 50;
    transform: translateY(-50%);
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    background: var(--color-aines-ink);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1rem;
    white-space: nowrap;
    pointer-events: none;
}
.shell-avatar {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background: var(--color-aines-green-deep);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.shell-user-name {
    color: var(--color-aines-ink);
    font-size: 0.8125rem;
    font-weight: 600;
}

.shell-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgb(15 14 12 / 0.4);
}

.shell-link:focus-visible,
.shell-icon-button:focus-visible,
.shell-rail-toggle:focus-visible,
.shell-logo:focus-visible {
    outline: 2px solid var(--color-aines-green);
    outline-offset: 2px;
}

/* Drawer: below md the sidebar is off the screen until opened. */
@media (max-width: 767px) {
    .shell-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        width: min(18rem, 85vw);
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 200ms ease, visibility 0s linear 200ms;
    }
    .shell-sidebar[data-open] {
        transform: none;
        visibility: visible;
        box-shadow: 0 10px 30px rgb(15 14 12 / 0.18);
        transition: transform 200ms ease;
    }
    .shell-rail-toggle {
        display: none;
    }
}

@media (min-width: 768px) {
    :root {
        --shell-bar: 0px;
        --shell-page-left: var(--shell-sidebar-width);
    }
    html[data-sidebar="rail"] {
        --shell-sidebar-width: 4.25rem;
    }
    /* Above the page, so the account menu that opens past a narrowed sidebar's
       edge is not under the page's own positioned cards and menus. */
    .shell-sidebar {
        position: sticky;
        top: 0;
        z-index: 30;
        height: 100vh;
        height: 100dvh;
    }
    .shell-bar,
    .shell-drawer-close,
    .shell-backdrop {
        display: none;
    }

    /* Rail. */
    html[data-sidebar="rail"] .shell-sidebar {
        padding-inline: 0.625rem;
    }
    html[data-sidebar="rail"] .shell-brand {
        flex-direction: column;
        gap: 0.75rem;
        padding-left: 0;
    }
    html[data-sidebar="rail"] .shell-logo-full,
    html[data-sidebar="rail"] .shell-when-wide,
    html[data-sidebar="rail"] .shell-sub {
        display: none;
    }
    html[data-sidebar="rail"] .shell-logo-mark,
    html[data-sidebar="rail"] .shell-when-rail {
        display: block;
    }
    /* The account menu opens out of the rail at its full width, so its link
       keeps the wide look. */
    html[data-sidebar="rail"] .shell-link:not(.shell-account-menu *) {
        justify-content: center;
        padding-inline: 0;
    }
    /* Out of sight but still the link's name for a screen reader. */
    html[data-sidebar="rail"] .shell-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    /* The parent stands in for a sub-page, which the rail does not show. */
    html[data-sidebar="rail"] .shell-holds-current {
        background: var(--color-aines-green-wash);
        color: var(--color-aines-green-deep);
    }
}

@media (prefers-reduced-motion: reduce) {
    .shell-sidebar,
    .shell-sidebar[data-open] {
        transition: none;
    }
}

/* HTMX loading indicator */
.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}

/* A box that scrolls its wide table sideways also holds the table's screen-reader
   labels (`sr-only`, which is absolutely positioned). Without a positioned box
   around them they are placed against the page, and a label in a column past the
   box's edge widens the page itself, which then scrolls sideways too. Covers the
   agents' tables as well, which this sheet styles. */
.overflow-x-auto:not(.absolute, .fixed, .sticky) {
    position: relative;
}

/* The RFQ board's countdown to its next refresh: a full bar emptying towards its
   left end over the poll interval, set on the element. Restarted by the swap that
   replaces it. */
.rfq-board-poll {
    height: 3px;
    border-radius: 9999px;
    background-color: var(--color-aines-line-soft);
    overflow: hidden;
}
.rfq-board-poll-bar {
    height: 100%;
    background-color: var(--color-aines-green); /* the loading bar's */
    transform-origin: left center;
    animation-name: rfq-board-countdown;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}
@keyframes rfq-board-countdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Form control: a bordered box for inputs and selects alike.
   The console's Tailwind has no forms plugin, so its preflight zeroes
   border-width (leaving `border-gray-300` setting only a colour) and leaves a
   select's native chrome alone. The result is a text input with no visible box
   sitting beside a natively-drawn select — and the mismatch differs by
   platform. This is the smallest rule that makes the two the same control. */
.form-control {
    border-width: 1px;
}
/* The chevron goes on both control types that offer a list: a <select>, and a
   text input backed by a <datalist>. Chrome draws its own indicator inside the
   latter, but only on hover, so without this the two sit side by side looking
   like different kinds of field until you touch one. What cannot be reconciled
   is the popup each opens — a datalist's list and a select's menu are native
   widgets — so the resting state is as far as this goes. */
select.form-control,
input.form-control[list] {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 2rem;
}

/* A status pill that is itself the control (status_select in
   components/status_chip.html, and the field-reporting plugins' list rows): the
   native arrow goes and a small chevron in the pill's own ink takes its place.
   The plugins rely on this rule too, which is one more reason the web goes first. */
select.status-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23494846' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.4rem center;
    background-repeat: no-repeat;
    background-size: 1em 1em;
}
select.status-select.text-white {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
}
/* The open list is the browser's own and keeps its own colours. */
select.status-select option {
    color: var(--color-aines-ink, #0f0e0c);
    background: #fff;
}

/* Chrome's own datalist indicator, hidden so the chevron above is the only one. */
input.form-control[list]::-webkit-calendar-picker-indicator {
    display: none !important;
}

/* ---------------------------------------------------------------------------
   The one distinction the compliance console exists to protect.

   Nothing we write may be mistakable for something the authority wrote. A
   condition read as ours is a condition nobody honours; a note of ours read as
   theirs is a promise the source never asked for. Two treatments carry it, and
   they are deliberately different in kind rather than in shade:

     the authority's words   quoted   — a rule in the margin, set in a serif
     ours                    a field  — a filled, bordered surface, set in the
                                        interface face

   A person tells them apart without reading a label, and without a hue: every
   hue in this console already means something. The Aines green is action —
   links, buttons, selection, the focus ring. Red, yellow and green dots are the
   light, which is a judgement a person made. A further meaning would have had to
   borrow one of those, and the pale blue this replaces borrowed the action
   colour of its day so faintly (#EFF6FF, about one per cent off white) that it
   read as nothing at all.

   The rule lives here rather than in the templates because it was restated in
   six of them, where nothing could enforce it and a grey rule could drift onto
   something we typed.
   --------------------------------------------------------------------------- */

/* The two states of one editable field. Both carry the face: if only the read
   view had it, the text would reflow the moment someone clicked into it. */
.panel-source,
.panel-source-edit {
    font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
}

/* The rule that marks the words as quoted. Read view only — a field being
   edited is already unmistakable, and it carries its own active border. */
.panel-source {
    border-left: 2px solid #d1d5db;   /* gray-300 */
    padding: 0.125rem 0 0.125rem 0.75rem;
}

/* Ours. A surface you could write on, because these are the fields you write
   in: the note that never leaves the console, and the answer that does. */
.panel-ours {
    background-color: #f9fafb;        /* gray-50 */
    border: 1px solid #e5e7eb;        /* gray-200 */
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
}

/* Fold-card chevron: rotates 90° down when its <details> parent is open.
   A rule rather than `group-open:rotate-90` because the plugin templates use
   it too, without a `group` on their <details>. */
.fold-chev {
    transition: transform 150ms ease;
}
details[open] > summary .fold-chev {
    transform: rotate(90deg);
}

/* A card inside a fold would print the heading its summary already carries. A
   rule rather than a flag on the include, because the card re-renders itself
   from a route that cannot know which of the two rails asked for it. */
.fold-body [data-panel-heading] {
    display: none;
}

/* The case card's buttons while their request is out (`hx-disabled-elt`).
   Tailwind v2 as bundled has no disabled: variant, and without a visible change
   a Connect round trip reads as the click not having registered. */
[data-case-panel] button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Safari ignores `list-style: none` on a summary and draws its triangle anyway,
   so on iOS a summary that asked for no marker — because it carries a chevron of
   its own, or is styled as a button — showed two arrows. Scoped to `list-none`
   so the folds that do want the native marker keep it. */
summary.list-none::-webkit-details-marker {
    display: none;
}
