/*
   GReal' own sheet. The shared core (gnexus.css) is linked FIRST and owns
   colour, type and the form controls; this file owns only what is particular
   to this app.

   Deliberately small. GNexus.Ui is two stylesheets and no components
   (ADR 0010), and the reason GReal shares the core is a SECURITY argument:
   a person crosses GPass.Auth into this app in one sign-in flow, and a change
   of clothes halfway through reads as a change of site.
*/

.booting {
    padding: 2rem;
    text-align: center;
    color: var(--muted);
}

/* Blazor's own error bar, which the framework UNHIDES when something throws.

   `display: none` here is LOAD-BEARING, not a default. index.html ships the
   element in the markup, so without this rule it is visible from the first
   paint and every page claims something went wrong. That is exactly how it
   behaved on the first browser run of this app — the same shape as the
   Console's reconnect modal, which also has to supply its own hidden state. */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0.7rem 1rem;
    color: var(--danger);
    background: var(--danger-bg);
    box-shadow: 0 -1px 0 var(--border);
}

#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* THE SHELL: header, nav, content, footer.

   A FIXED FRAME WITH ONE SCROLLING PANEL, not a tall page. The whole shell is
   exactly the height of the window and does not scroll; `main` and the menu
   each scroll inside it. That is deliberate and it is the difference between
   a web page and an application window:

   - A distribution screen is a GRID — a purchase entry, a 163-row register.
     If the page scrolled as one, the column headings would leave the screen
     and the bar and footer would go with them.
   - The menu is 327 entries. It needs its OWN scrollbar, or reaching the
     bottom of Reports means scrolling the invoice away.

   100dvh, not 100vh: on a phone, `vh` is the height WITHOUT the browser's own
   collapsing address bar, so a 100vh frame is permanently taller than the
   window and the footer sits below the fold — which is exactly the thing a
   footer must not do. */
.shell {
    height: 100dvh;
    display: grid;
    /* `minmax(0, 1fr)`, not a bare `1fr`. The latter means
       `minmax(auto, 1fr)`, whose AUTO minimum is the content's size — so a
       tall page grew this row and `main` scrolled the whole shell instead of
       scrolling inside itself, leaving a scrollbar that moved nothing. Same
       trap as the master grid below. */
    /* FIVE ROWS: bar, the ACTING AS line, the period line, the body, the
       footer. Both status lines are `auto` and render only when there is
       something to say — the context line only when this login holds a
       mapping at all, which most do not — so an empty row costs nothing.

       ADDING A ROW HERE MEANS ADDING IT TO BOTH `grid-template-areas` below.
       The desk-width template and the menu-hidden one are ONE layout in two
       states, and a named area missing from one of them does not fall back to
       nothing: the item is AUTO-PLACED into an implicit track, which is how
       the range line once ended up beside the footer. */
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    overflow: hidden;
}

.shell-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    /* Short on purpose. The bar carries a name and one control; every
       pixel it takes is a pixel off the grid underneath, and an ERP screen
       is read down. */
    padding: .2rem .9rem;
    background: var(--bar);
    color: var(--bar-text);

    /* Above the phone drawer, so sliding the menu out never covers the button
       that closes it again. */
    position: relative;
    z-index: 40;
}

.shell-bar h1 {
    font-size: .98rem;
    margin: 0;
}

.bar-brand {
    flex: 1;
}

/* ---- the account control in the bar ------------------------------------ */

.bar-account { position: relative; flex: 0 0 auto; }

/* A round button, because round reads as "a person" and square reads as "a
   command" — which is what every other control in this bar is. */
.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    padding: 0;
    color: var(--bar);
    background: var(--bar-text);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.avatar:hover { background: color-mix(in srgb, var(--bar-text) 85%, var(--bar)); }

.avatar:focus-visible {
    outline: 2px solid var(--bar-text);
    outline-offset: 2px;
}

/* THE MENU ITSELF.

   Two items and nothing else, set TIGHT. The pair used to sit in the nav
   panel inheriting list spacing on top of their own padding, which left a gap
   between them big enough to read as two unrelated things. A menu of two is
   one block: same row height, one hairline between them, no margins. */
.account-menu {
    position: absolute;
    top: calc(100% + .55rem);
    right: 0;
    z-index: 60;
    min-width: 12rem;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
}

.account-menu a,
.account-menu button,
.account-menu .account-name {
    display: flex;
    align-items: center;
    gap: .65rem;
    width: 100%;
    margin: 0;
    padding: .6rem .85rem;
    font: inherit;
    font-size: .9rem;
    text-align: left;
    color: var(--text);
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
}

.account-menu .account-name { cursor: default; color: var(--muted); }

/* The divider is a BORDER on the second row, not a margin between the two —
   a margin would put the gap back. */
.account-menu button { border-top: 1px solid var(--border); }

.account-menu a:hover,
.account-menu button:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.account-menu .nav-icon { opacity: .7; }

/* The click-away catcher. Invisible — unlike the drawer's scrim, this overlay
   is not meant to dim anything, only to catch the next click. */
.scrim-bare { background: none; z-index: 50; }

.menu-toggle {
    background: none;
    border: 0;
    color: inherit;
    font-size: 1.25rem;
    cursor: pointer;
    padding: .25rem .5rem;
}

/* THE NAV — a real drawer on a phone.

   It SLIDES OVER the page rather than appearing in the flow above it. In the
   flow it pushed `main` down, so opening the menu re-laid-out the screen
   underneath and closing it moved everything back; with a fixed frame it would
   also have squeezed the content into whatever was left. A drawer leaves the
   page exactly where it was.

   `transform`, not `display`, so it animates and so the markup is identical at
   both widths — one list, two shapes (ADR 0010's argument, one level down: a
   second copy for wide screens is how the two quietly stop matching). */
.shell-menu {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: 17rem;
    max-width: 85vw;

    /* The PANEL does not scroll — the tree inside it does (.menu-scroll), so
       Profile and Sign out stay put. Two nested scrollers would give a
       scrollbar on the outer one that moves almost nothing. */
    overflow: hidden;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .18s ease;
}

.shell.menu-open .shell-menu { transform: translateX(0); }

/* Respect a person who has asked the system to stop animating. */
@media (prefers-reduced-motion: reduce) {
    .shell-menu { transition: none; }
}

.scrim {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, .35);
    border: 0;
}

/* THE CONTENT — the one panel that scrolls.

   It owns the page's breathing room, which nothing did before: `main` had no
   padding at all, so every card sat flush against the bar above it and the
   menu beside it. `min-width: 0` is load-bearing in a grid — without it a wide
   table refuses to shrink and pushes the whole frame sideways instead of
   scrolling inside this box. */
main {
    /* A COLUMN: the tab strip, then the panel filling what is left. `hidden`
       rather than `auto` because the panel owns the scrolling now — two
       nested scrollers gives an outer bar that moves almost nothing. */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;

    /* ONE padding at both widths, so the tab strip's negative margin can
       cancel it exactly. It was 1.25rem here and 1.5rem at desk width, and
       that quarter-rem mismatch is the gap that showed under the app bar. */
    padding: 1rem;
}

/* THE FOOTER.

   Always visible, and it carries the two facts that are otherwise unanswerable
   from inside the app: WHICH BUSINESS this window is looking at — somebody
   with two open needs to tell them apart, and the header only has room for the
   person's name — and HOW MANY permissions this session resolved, which is the
   only window there is onto ADR 0028. Permissions no longer travel in the
   token, so "am I seeing the whole menu?" has no other answer a person can
   check for themselves.

   The build is here for the same reason: a tester reporting "the menu closes"
   is reporting it about a particular build. */
.shell-foot {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .35rem 1rem;
    font-size: .75rem;
    color: var(--muted);
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.shell-foot .foot-spacer { flex: 1 1 auto; }

.shell-foot .foot-fact {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    white-space: nowrap;
}

.shell-foot code {
    font-family: var(--mono);
    font-size: .72rem;
}

/* On a phone there is no room for all of it, and the business reference is
   the one that answers a question somebody actually has. */
@media (max-width: 599px) {
    .shell-foot .foot-optional { display: none; }
}

/* The identity facts on the skeleton's home page. */
.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: .5rem 1.5rem;
    margin: 1rem 0 0;
}

.facts dt {
    font-weight: 600;
    color: var(--muted);
}

.facts dd {
    margin: 0;
}

.perms {
    margin: 0;
    padding-left: 1.25rem;
}

@media (min-width: 900px) {
    .shell {
        grid-template-columns: 16rem 1fr;
        grid-template-areas:
            "bar     bar"
            "context context"
            "period  period"
            "menu    main"
            "foot    foot";
    }

    .shell-bar    { grid-area: bar; }
    .context-line { grid-area: context; }
    .period-line  { grid-area: period; }
    .shell-menu  { grid-area: menu; }
    main         { grid-area: main; }
    .shell-foot  { grid-area: foot; }

    /* The drawer becomes a column: everything that made it float is undone
       here, in one place, rather than being conditional above. */
    .shell-menu {
        position: static;
        z-index: auto;
        width: auto;
        max-width: none;
        transform: none;
        transition: none;
        background: none;
    }

    .menu-toggle { display: none; }
}

/* ---- the menu ---------------------------------------------------------- */

/*
   GReal has 328 menu entries across three levels. The visual job is
   different from GHour's nine: there, everything fits and hierarchy is
   decoration; here, hierarchy is the only thing that makes the menu usable
   at all.

   Same tokens and the same shapes as GHour, deliberately (ADR 0010). A
   person crosses GPass.Auth into either app in one sign-in flow, and a
   change of clothes halfway reads as a change of site.
*/

/* THE MENU IS A COLUMN WITH A FIXED FOOT.

   The tree scrolls; the account block below it does not. Before this the whole
   panel scrolled, so expanding a section with nineteen entries pushed Profile
   and Sign out out of sight — and one of those is how somebody leaves. */
.menu {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem;
}

/* `min-height: 0` IS LOAD-BEARING, not a tidy-up.

   A flex item's default `min-height: auto` refuses to shrink below its content,
   so a 327-entry tree makes this box as tall as the tree, `overflow` never has
   anything to clip, and the scrollbar appears on the panel instead — which is
   exactly the behaviour being fixed. Removing this line silently restores the
   bug. */
.menu-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

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

.menu-brand {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: -1rem -1rem .75rem;
    padding: .7rem 1rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--bar-text);
    background: var(--bar);
}

/* A destination. */
.menu a,
.menu .linkish {
    display: flex;
    align-items: center;
    gap: .7rem;
    width: 100%;
    padding: .45rem .7rem;
    text-align: left;
    font-size: .9rem;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    background: none;
    border: 0;
    cursor: pointer;
}

.menu a:hover,
.menu .linkish:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.menu a.active {
    font-weight: 600;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* A section heading, which is also the control that opens it.

   A BUTTON, not a link: it goes nowhere. Making it a link would put 45
   destinations in the menu that lead to no page, and a keyboard user would
   tab through every one of them. */
.nav-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .45rem .5rem;
    margin-top: .1rem;
    font: inherit;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-align: left;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.nav-toggle:hover { color: var(--text); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.nav-toggle.open { color: var(--text); }

/* OPEN / CLOSED, as a rotation.

   This was ▸ and ▾ set at .7rem, and at that size the two glyphs are near
   enough identical that the state of a section could not be read at a glance —
   which in a menu whose whole job is hierarchy is the one thing that must be
   legible. It was also at the mercy of whichever font happened to resolve the
   character.

   One shape, turned 90°. The MOVEMENT is what the eye reads, and there is no
   second glyph to keep in step with the first. */
.nav-chevron {
    flex: 0 0 auto;
    transition: transform .15s ease;
    opacity: .75;
}

.nav-toggle.open .nav-chevron { transform: rotate(90deg); opacity: 1; }
.nav-toggle:hover .nav-chevron { opacity: 1; }

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

/* The root icons. `currentColor`, so they follow the heading through hover,
   the accent on the active trail, and dark mode, without a second set of
   rules for any of it. */
.nav-icon {
    flex: 0 0 auto;
    opacity: .8;
}

.nav-toggle:hover .nav-icon,
.nav-toggle.open .nav-icon,
.nav-toggle.here .nav-icon { opacity: 1; }

.nav-label { flex: 1 1 auto; }

/* How many destinations are inside. A section with nineteen entries should
   say so BEFORE it is opened — that is the difference between choosing to
   open it and being surprised by it. */
.nav-count {
    flex: 0 0 auto;
    padding: .05rem .4rem;
    font-size: .7rem;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--muted);
    background: color-mix(in srgb, var(--muted) 14%, transparent);
    border-radius: 999px;
}

/* Depth, shown as indentation AND as a rule down the left, so a section
   inside a section is obvious at a glance rather than by counting pixels. */
.nav-depth-1 > .nav-children,
.nav-depth-2 > .nav-children {
    margin-left: .55rem;
    padding-left: .55rem;
    border-left: 1px solid var(--border);
}

.nav-depth-1 > .nav-toggle { font-size: .78rem; text-transform: none; letter-spacing: 0; }
.nav-depth-2 > .nav-toggle { font-size: .78rem; text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ---- menu corrections -------------------------------------------------- */

/* THE BRAND APPEARS ONCE.

   The bar says "GReal" and so did the menu panel, one centimetre apart. In
   GHour that panel heading earns its place: it is a DRAWER that slides over
   the page on a phone, where the bar is not adjacent to it. At desk width the
   menu is a permanent column directly under the bar, and the word is simply
   there twice.

   So it is kept for the drawer and dropped for the column. */
@media (min-width: 900px) {
    .menu-brand { display: none; }
    .menu { padding-top: .75rem; }
}

/* ZEBRA STRIPING, which needs the destinations to be siblings — NavTree now
   renders one <ul> per level rather than a <ul> around each entry, because
   nth-child counts siblings and a list of one is never even.

   Very low contrast on purpose: this is a menu, and the stripe is there to
   let the eye track along a row in a list of nineteen, not to decorate. */
.nav-list li:nth-child(even) > a {
    background: color-mix(in srgb, var(--text) 4%, transparent);
}

.nav-list li:nth-child(even) > a:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* WHERE YOU ARE.

   The active entry has to beat the zebra stripe, so it is repeated at the same
   specificity — a stripe declared later would otherwise win on an even row and
   the selection would visibly depend on whether the entry happened to be
   second or third in its section.

   And it is a BAR, not just a tint. In a list of nineteen near-identical labels
   ("Receipt", "Receipt Modify", "Receipt Payment Search") a 14% wash is not
   something the eye finds — the solid edge is. `!important` is not needed
   anywhere here; order and specificity do it. */
.nav-list li > a.active,
.nav-list li:nth-child(even) > a.active {
    position: relative;
    font-weight: 600;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    box-shadow: inset 3px 0 0 var(--accent);
}

/* THE TRAIL. Every section between the root and the page on screen, marked —
   so when a branch is shut, the path to where you are is still readable. A
   highlight that only exists on the leaf disappears the moment somebody
   collapses the section they are standing in. */
.nav-toggle.here {
    color: var(--accent);
}

.nav-toggle.here > .nav-label { font-weight: 700; }

/* Closed AND holding the current page is the case worth shouting about: the
   entry itself is off screen, so this mark is all there is. */
.nav-toggle.here:not(.open) {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
}

/* PIN / HIDE.

   Desk width only. On a phone the menu is already a drawer that is out of the
   way, and a second control that hides it would do nothing visible. */
.menu-pin { display: none; }

@media (min-width: 900px) {
    .menu-pin {
        display: inline-flex;
        align-items: center;
        margin: 0;
        padding: .3rem .55rem;
        font-size: .9rem;
        line-height: 1;
        color: var(--bar-text);
        background: none;
        border: 1px solid color-mix(in srgb, var(--bar-text) 40%, transparent);
        border-radius: 8px;
        cursor: pointer;
    }

    .menu-pin:hover { background: color-mix(in srgb, var(--bar-text) 14%, transparent); }

    /* One column instead of two, so the page takes the whole window. A
       distribution screen is wide — a purchase entry grid or a 163-row
       register — and 16rem of menu is a real cost once somebody knows where
       they are going. */
    .shell.menu-hidden {
        grid-template-columns: 1fr;

        /* THE `period` ROW MUST BE HERE TOO, and leaving it out was a real
           bug with three faces. `.period-line` asks for `grid-area: period`;
           a named area that does not exist in the template does not fall
           back to nothing — the item is AUTO-PLACED, which created an
           implicit track. So collapsing the menu sent the range line to the
           bottom right beside the footer, and the implicit column stopped
           `main` using the width the menu had just given up.

           Any future row added to the expanded template has to be added
           here as well. The two are one layout in two states — `context`
           (ADR 0032's ACTING AS line) is here for exactly that reason. */
        grid-template-areas: "bar" "context" "period" "main" "foot";
    }

    .shell.menu-hidden .shell-menu { display: none; }
}


/* ---- the tab workspace (ADR 0029) -------------------------------------- */

/* `main` is the scroll container, so the strip has to stay put while the pane
   under it moves. Sticky rather than fixed: it belongs to the content column,
   not to the window. */
.tab-strip {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: .25rem;
    /* NO pull-out any more. The strip sits directly on the panel below it,
       aligned with main's content edge like everything else. */
    margin: 0;
    flex: 0 0 auto;
    padding: 0;
    /* SIDEWAYS ONLY. `overflow-x: auto` on its own is not enough: CSS coerces
       the other axis from `visible` to `auto`, so a strip one pixel taller
       than its box grows a VERTICAL scrollbar that scrolls nothing. Saying
       `hidden` explicitly is what stops it.

       Horizontal scrolling is the intended answer for many tabs — with thirty
       open the strip scrolls rather than wrapping, because a tab bar that
       reflows to three rows moves every tab each time one is closed. */
    overflow-x: auto;
    overflow-y: hidden;
    background: none;
}

.tab {
    display: flex;
    align-items: center;

    /* An EXPLICIT height. Padding alone could not shrink this: the labels
       are buttons, and they inherit `line-height: 1.5` from the body, so a
       .85rem font reserved ~20px of line box before any padding was added.
       Fixing the height and setting line-height on the children is what
       actually controls it. */
    height: 1.7rem;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: color-mix(in srgb, var(--text) 4%, transparent);
}

/* The active tab joins the panel below it — the border they would have shared
   is covered, which is what makes a strip read as tabs rather than buttons.
   The OVERLAP itself lives on `.tab-panel`, further down: a negative margin
   here is clipped by the strip's own `overflow-y: hidden`, which is what cut
   the bottoms off the labels. */
.tab.active {
    background: var(--surface);
}

.tab-label {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 .1rem 0 .6rem;
    font: inherit;
    font-size: .82rem;

    /* 1.15, not 1. A line box exactly the font size clips descenders —
       the "p" of "Supplier" and the comma-tails were being cut. */
    line-height: 1.15;
    color: var(--muted);
    background: none;
    border: 0;
    cursor: pointer;
    white-space: nowrap;
}

.tab.active .tab-label { color: var(--text); font-weight: 600; }

/* Unsaved work. The only thing a hidden pane can say for itself. */
.tab-dirty { margin-left: .3rem; color: var(--accent); font-size: 1.1rem; line-height: 0; }

.tab-close {
    height: 100%;
    padding: 0 .4rem;
    font: inherit;
    font-size: .9rem;
    line-height: 1;
    display: flex;
    align-items: center;
    color: var(--muted);
    background: none;
    border: 0;
    cursor: pointer;
    border-radius: 0 8px 0 0;
}

.tab-close:hover { color: var(--danger); background: var(--danger-bg); }

/* A hidden pane keeps its component ALIVE and measures zero. Anything that
   sizes itself on initialise comes up 0-wide in a background tab and looks
   broken only when that tab is first shown — the known cost of keeping panes
   alive, written here so it is findable. */
.pane[hidden] { display: none; }

/* A menu entry that opens a tab rather than navigating. Styled as the links
   beside it, because the difference is behaviour and not meaning. */
.nav-open {
    display: flex;
    align-items: center;
    gap: .7rem;
    width: 100%;
    padding: .45rem .7rem;
    font: inherit;
    font-size: .9rem;
    text-align: left;
    color: var(--text);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.nav-open:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* ---- the master-screen pattern ----------------------------------------- */

/* LIST LEFT, FORM RIGHT, as the system it replaces. One screen, no
   navigation: an operator correcting six salesmen never leaves the page. */
/* LIST LEFT, FORM RIGHT, ACTION BAR UNDER THE FORM.

   Three regions in one grid rather than a grid plus a loose bar beneath it:
   the bar used to span both columns, so its buttons ran on under the list and
   "View Mode" sat in a strip of nothing. It belongs to the record being
   edited, which is the right-hand column.

   `stretch`, not `start`: the list column is as tall as the row, so a list of
   three names does not leave a short panel floating above empty space. */
.master {
    display: grid;
    grid-template-columns: 18rem 1fr;

    /* `minmax(0, 1fr)`, NEVER a bare `1fr`.

       `1fr` is shorthand for `minmax(auto, 1fr)`, and that `auto` minimum is
       the CONTENT's size — so a list of 245 rows made this row eight thousand
       pixels tall, the panel burst out of the page, and the sticky tab strip
       ended up floating over the middle of it. The zero minimum is what lets
       the row be smaller than its contents, which is the whole basis for
       scrolling inside it. */
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
        "title title"
        "list  form"
        "list  bar";
    gap: .5rem 1rem;

    /* FILLS `main` EXACTLY, rather than guessing with viewport maths.

       `calc(100vh - 12rem)` was a guess at the bar, tab strip, padding and
       footer added together, and being a few pixels out is what left `main`
       with a scrollbar that scrolled nothing. `100%` of a parent that already
       has a definite height needs no arithmetic and cannot drift when any of
       those change.

       It also matters for VIRTUALISATION: `Virtualize` sizes its window from
       the scroll container, and a container with no definite height looks
       infinitely tall — so it rendered every row and fetched all of them,
       which is the opposite of the point. */
    height: 100%;

    /* NO FLOOR. This was `min-height: 22rem`, a guard against the master
       collapsing, and it is what clipped the action bar: the panel around it
       is `overflow: hidden`, so when the window was shorter than about 520px
       (browser zoom at 150-200%, docked dev tools) the master kept its 22rem
       and the panel cut its bottom off — at 360px the New / Edit / Save /
       Reset bar was not on screen at all, and nothing scrolled to reach it.

       It is not needed: the middle row is `minmax(0, 1fr)`, so the list and
       the form already shrink and scroll INSIDE the master while the title and
       the bar keep their height. A short window now gives a short list and a
       short form — both scrollable — instead of a bar you cannot press. */
    min-height: 0;
}

/* A MASTER WITH NO LIST — every transaction screen (2026-10-25).

   The list pane is right for a master and wrong for a document. You browse
   customers; nobody browses invoices. Keeping it on the transaction screens
   cost two round trips before anything was keyed — a list on open and the
   document itself on select — and gave 18rem of the width to rows the
   operator had not asked for, on exactly the grid that already scrolls
   sideways because a purchase line is eleven columns.

   So those screens open empty and the form takes the whole panel. Reaching a
   document is a Find button over the same lookup picker every code field
   uses, which costs one search when somebody wants one and nothing when they
   do not. See `docs/design/tab-workspace-and-master-screens.md`. */
.master.solo {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "title"
        "form"
        "bar";
}

/* What an empty transaction screen says before anything is keyed. One line,
   because a screen that explains itself at length is a screen somebody reads
   once and resents twice. */
.master .nothing {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 8rem;
    color: var(--muted);
    text-align: center;
}

/* The screen's name, as the WPF form has it. The tab says it too, but a tab
   is chrome — somebody reading a printout or a screenshot needs the page to
   say what it is. Compact, because the request that produced it was for LESS
   height overall. */
/* CENTRED, ON A BAND, as the WPF form has it.

   Left-aligned and unfilled it read as another label among the field labels.
   A tinted band makes it the thing the eye lands on first, which is what a
   screen title is for — and it is the only place the screen names itself,
   since the tab beside it is chrome. */
.master-title {
    grid-area: title;
    margin: 0;
    padding: .25rem .6rem;
    text-align: center;
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--bar-text);
    background: var(--bar);
    border-radius: 6px;
}

/* Grid items get `min-height: auto` too, and refuse to shrink below their
   content for exactly the same reason. */
.master-list { grid-area: list; min-height: 0; }
.master-bar  { grid-area: bar; margin-top: 0; }

/* The form scrolls on its own — Customer has three sections of fields, and
   they must not push the action bar off the bottom. */
.master-form {
    grid-area: form;
    min-height: 0;
    overflow-y: auto;
}

@media (max-width: 760px) {
    /* The list goes above the form rather than beside it. A 18rem column on a
       phone leaves neither usable. */
    .master { grid-template-columns: 1fr; }
}

/* A column: the search box pinned, the rows scrolling under it. Without this
   a long list would push the search off the top of the page, and the one
   control that shortens the list would be the one you have to scroll to. */
.master-list {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

/* `min-height: 0` is load-bearing — a flex item refuses to shrink below its
   content without it, so the rows would make this box as tall as the list and
   `overflow` would have nothing to clip. */
.master-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.master-search {
    width: 100%;
    margin: 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
}

.master-rows { width: 100%; border-collapse: collapse; font-size: .875rem; }

/* FROZEN. The header scrolled away with the rows, so after twenty names
   nothing said which column was which.

   Sticky on the `th` rather than the `thead`: a table header row cannot be a
   containing block for sticky in every browser, and the cells can. It needs
   an opaque background of its own — sticky elements do not inherit one, so
   rows would otherwise slide visibly underneath it. */
.master-rows th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: .35rem .6rem;
    text-align: left;
    font-size: .75rem;
    color: var(--muted);
    background: var(--bg);

    /* A border on a sticky cell scrolls away with the cell's box in some
       engines; a box-shadow is painted and stays. */
    box-shadow: inset 0 -1px 0 var(--border);
}

.master-rows td { padding: .35rem .6rem; border-bottom: 1px solid var(--border); }
.master-rows tbody tr { cursor: pointer; }
.master-rows tbody tr:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

.master-rows tbody tr.selected {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    font-weight: 600;
}

/* Inactive is shown, not hidden — somebody searching for a salesman who left
   should find them and see why they are not in the pickers. */
.master-rows tbody tr.inactive td { color: var(--muted); font-style: italic; }

.master-form {
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* A READ-ONLY FIELD LOOKS LOCKED (ADR 0033). A master's Code is never typed, and a box that
   looks like every other box invites a click, a few keystrokes, and no explanation. The page
   background and the muted text colour are the pair the rest of the app already uses for "not
   yours to edit", and both have dark-mode values. */
.master-form input[readonly] {
    background: var(--bg);
    color: var(--muted);
    cursor: default;
}

.field-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: .6rem 1rem;
    align-items: center;
    max-width: 38rem;
}

.field-grid label { margin: 0; }
.field-grid input[type="text"],
.field-grid input[type="number"] { margin: 0; }

.pad { padding: .75rem; }

/* THE MODE IS ALWAYS VISIBLE, as it is in the legacy — "View Mode" bottom-left
   in red. Mode is state an operator reads, not something they infer from
   whether a field accepts typing. */
.master-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .75rem;
    padding: .5rem .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.master-bar .mode { font-size: .8rem; font-weight: 600; color: var(--muted); }
.master-bar .mode.dirty { color: var(--accent); }
/* `<span class="spacer">` PUSHES WHAT FOLLOWS TO THE RIGHT — and the rule
   that makes it do so is NOT in the stylesheet this app loads.
   `gnexus-admin.css` defines `.spacer { flex: 1 }`; GReal.App loads
   `gnexus.css`, which does not. So every spacer here was an inert empty span
   until somebody noticed.

   It was first patched as `.master-bar .spacer`, scoped to the one place the
   symptom was seen, and the lookup footer then hit exactly the same thing —
   the Select and Cancel buttons drifted sideways as the count beside them
   changed width, because nothing was absorbing the slack. Made general here
   so the next footer does not have to rediscover it. */
.spacer { flex: 1 1 auto; }

/* The key hints the legacy prints on every button. Shown now because the
   shortcuts are not wired yet, so these read as a promise rather than a
   description — and that is the next thing to build. */
.master-bar kbd {
    margin-left: .35rem;
    padding: .05rem .3rem;
    font-family: var(--mono);
    font-size: .7rem;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* A section heading inside a master form. The legacy splits these across
   tabs because a WinForms form cannot scroll comfortably; a web page can, so
   licence and terms sit below the contact details rather than behind them —
   somebody checking a credit limit against a licence expiry sees both. */
.master-form h3.section {
    margin: 1.25rem 0 .6rem;
    padding-top: .75rem;
    font-size: .9rem;
    border-top: 1px solid var(--border);
}

/* FOUR-COLUMN LISTS NEED REAL WIDTH, and 26rem was not it.

   Item is Code|Name|Pack|MRP and Manufacturer is Code|Name|Short|City,
   and in both the NAME is the column that matters — `ABBOTT INDIA
   LIMITED` truncating to `ABBOTT IND…` makes the list unreadable while
   the form half sits empty beside it.

   TWO STEPS rather than one, because the trade runs the other way on a
   narrow screen: 34rem at 800px would leave the form about 200px, which
   is worse than a clipped name. So the list only takes the extra width
   once there is width to take.

   `minmax(0, 1fr)` and not `1fr` — a bare `1fr` is `minmax(auto, 1fr)`,
   whose auto minimum is the content's, and that is what blew this grid
   out to several thousand pixels once already. */
@media (min-width: 761px) {
    .master:has(.master-list-wide) { grid-template-columns: 26rem minmax(0, 1fr); }
}

@media (min-width: 1200px) {
    .master:has(.master-list-wide) { grid-template-columns: 34rem minmax(0, 1fr); }
}

.master-rows th.num,
.master-rows td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* VIRTUALISED ROWS MUST BE A FIXED HEIGHT.

   `Virtualize` is told `ItemSize="33"` and positions everything from that
   number. If a real row is taller — a wrapped name, a different font — the
   scrollbar and the content drift apart and the list jumps as you scroll.
   Fixing the height here is what keeps the two honest. */
.master-rows tbody tr { height: 33px; }

.master-rows td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
}

/* A page still in flight. Same height, so nothing moves when it arrives. */
.master-rows tr.loading-row td {
    color: var(--muted);
    text-align: center;
}

/* The pane fills main, so the master inside it can be `height: 100%` and
   `main` never needs a scrollbar of its own. */
/* `position: relative` is what BOUNDS A PICKER TO ITS PANE.
   `.lookup-backdrop` is `position: absolute; inset: 0`, and with no
   positioned ancestor that resolves against the viewport — so a lookup opened
   in invoice tab 3 covered the whole window, including invoice tab 1 behind
   it. Measured at 1440x900 when the pane was a fraction of that. */
.pane { height: 100%; position: relative; }

/* ---- the tab control's content panel ----------------------------------- */

/* WHAT THE TABS ARE ATTACHED TO.

   Before this the strip floated above the page and read as a separate
   control sitting on top of unrelated content. A panel directly beneath it,
   sharing its surface and its border, is what turns a row of buttons into a
   tab control — and the active tab covering one pixel of the panel's top
   border is the whole illusion.

   Square at the top-left so the first tab meets it flush; rounded elsewhere. */
.tab-panel {
    flex: 1 1 auto;

    /* Rises one pixel so the active tab's bottom border covers the panel's
       top one. Done here rather than as a negative margin on the tab, which
       the strip would clip. */
    margin-top: -1px;
    min-height: 0;
    padding: .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    overflow: hidden;
}

/* The active tab paints OVER the panel's top border. `position: relative`
   plus a z-index is needed because a negative margin alone does not raise it
   above a later sibling. */
.tab.active {
    position: relative;
    z-index: 1;

    /* NO negative margin here. The strip is `overflow-y: hidden` — it has to
       be, because `overflow-x: auto` coerces a `visible` other axis back to
       `auto` — so anything hanging below the tab is CLIPPED, which is what
       was cutting the bottom off the labels. The panel rises to meet the
       tabs instead; see `.tab-panel`. */
    border-bottom: 1px solid var(--surface);
}

/* Inside the panel, the form and the action bar lose their own card
   backgrounds — the panel already is one, and a white card on a white panel
   is a border drawn for no reason. The LIST keeps its border, because it is a
   genuinely separate region rather than decoration. */
.tab-panel .master-form,
.tab-panel .master-bar {
    background: none;
    border: 0;
    border-radius: 0;
}

.tab-panel .master-form { padding: 0 .25rem; }

.tab-panel .master-bar {
    padding: .5rem 0 0;
    border-top: 1px solid var(--border);
}

/* ---- chrome buttons are not form buttons ------------------------------- */

/* `gnexus.css` styles every <button> as a FORM button:
   `margin-top: 1.25rem; padding: .65rem 1rem`. That is right for a Save
   button under a field and wrong for a tab, a menu row or an icon — and the
   margin is invisible until something clips it, which is exactly how the tab
   labels ended up with their bottoms cut off: the 20px top margin pushed each
   label out of its tab and into the strip's `overflow: hidden`.

   Resetting it here, in one place, for the buttons that are CHROME. */
.tab-label,
.tab-close,
.nav-open,
.menu-toggle,
.menu-pin,
.avatar,
.account-menu button,
.master-bar button,
.form-tab,
.master-search {
    margin: 0;
}

/* COLUMN WIDTHS, where a list declares them.

   `.master-rows td` carries `max-width: 0` — the standard trick that makes
   `text-overflow: ellipsis` work in a table cell at all. The side effect is
   that EVERY cell then claims the same maximum, so the browser falls back to
   dividing the table evenly: on the four-column manufacturer list that gave
   the name 144px of a 544px table and clipped `ABBOTT INDIA LIMITED` while
   `Short` sat half empty beside it.

   A `<colgroup>` on the table fixes the proportions, but only `table-layout:
   fixed` makes the browser OBEY it rather than treat it as a hint. Scoped
   with `:has(col)` so it applies to exactly the lists that said what they
   want — Salesman and Customer are two columns and are right already, and a
   blanket `fixed` would have split them 50/50 and given a five-character code
   the same room as a name. */
.master-rows:has(col) { table-layout: fixed; }

/* TABS INSIDE A FORM — "Basic Details" / "Terms", as the WPF masters have.

   A SECOND tab bar on a screen that already has one, which is a thing to be
   careful about rather than clever with: the workspace strip above says WHICH
   DOCUMENT, this one says WHICH PAGE OF IT. They are deliberately not the
   same size or weight, so the eye can tell at a glance which level a tab
   belongs to — the workspace tabs are the taller, louder pair.

   The strip's bottom border and the active tab's shadow do the classic
   folder-tab join: the border runs the width of the form, and the active tab
   paints over its own millimetre of it so the page below looks continuous. */
.form-tabs {
    display: flex;
    gap: .2rem;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid var(--border);
}

/* THE FORM'S OWN TABS STAY PUT WHILE ITS FIELDS SCROLL.

   `.master-form` is the scroll container, and this strip is an ordinary child
   of it — so scrolling the fields scrolled the strip away with them, leaving a
   form whose tabs had vanished under the title band. It only shows when the
   form is taller than its box (a short window, or a long tab such as the
   customer's), which is why it went unnoticed on a big screen.

   STICKY, NOT A RESTRUCTURE: the strip stays where the markup puts it and
   simply holds the top edge, so every tabbed form gets it with no page edits.

   THE BACKGROUND IS WHAT MAKES IT WORK. A sticky element is transparent by
   default and the fields would scroll visibly THROUGH it; `--surface` is the
   form's own colour, so it reads as part of the form. `z-index` keeps inputs
   (some of which are positioned) from painting over it.

   `>` because only the form's own strip should stick — not some other
   `.form-tabs` that ever ends up nested deeper. */
.master-form > .form-tabs {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface);
}

.form-tab {
    /* The global `button` rule in gnexus.css is for a Save button under a
       field: `margin-top: 1.25rem; padding: .65rem 1rem`. The margin is reset
       with the other chrome buttons above; the padding has to go here,
       because .65rem would make these taller than the workspace tabs and
       invert the hierarchy the comment above depends on. */
    padding: .35rem .85rem;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--bg);
    color: var(--muted);
    font-size: .8125rem;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
}

.form-tab:hover { color: var(--text); }

.form-tab.active {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;

    /* Paints over the strip's own bottom border, so the active tab and the
       page below it are one shape. */
    box-shadow: 0 1px 0 var(--surface);
}

/* The page under the tabs. The first field would otherwise sit hard against
   the strip. */
.form-pane { padding-top: 1rem; }

/* A section heading immediately under the tabs needs no top margin — the
   pane's padding has already given it room. */
.form-pane > .section:first-child { margin-top: 0; }

/* THE AUDIT LINE, ON ONE LINE, when it sits inside a tabbed form.

   Created and Modified stacked as a two-column list cost about 60px, and the
   manufacturer form measured 843px in an 843px pane at 1920x1080 — fitting
   exactly, which is another way of saying it scrolls as soon as anything
   grows by a pixel. The WPF screen this copies puts the same four facts in a
   corner for the same reason: they are looked at perhaps once a month, and
   they were taking the room of two fields that are used every time.

   Flow rather than grid, so the pairs run along the line and wrap together
   only if they must. */
.form-pane .facts {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1.25rem;
    align-items: baseline;
    margin-top: 1.25rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
    font-size: .8125rem;
}

.form-pane .facts dt { color: var(--muted); font-weight: 600; }
.form-pane .facts dd { margin: 0 .75rem 0 0; color: var(--muted); }

/* DATA-ENTRY DENSITY. A master form is not a sign-up page.

   `gnexus.css` gives every input `padding: .65rem .75rem`, which measures
   46px tall. That is right for the four fields on a login screen and wrong
   for nine on a master: it cost 414px of the manufacturer form in padding
   alone, which is why the form scrolled on a 900px window while the WPF
   screen it copies fits the same fields twice over.

   The legacy's fields are about 22px. Going that far would be a step too far
   for a touch screen and for anybody who does not have a mouse — 32px is the
   compromise, and it is still a comfortable click target.

   Scoped to `.master-form`, so this is a statement about DATA ENTRY rather
   than a global override of the design system. */
.master-form input[type="text"],
.master-form input[type="email"],
.master-form input[type="number"],
.master-form input[type="search"],
.master-form input[type="date"],
.master-form select,
.master-form textarea {
    padding: .35rem .55rem;
    font-size: .875rem;
}

/* The rows can close up once the fields have. */
.master-form .field-grid { gap: .4rem 1rem; }

/* ---- Search and Select ------------------------------------------------ */

/* SCOPED TO THE PANE, not the window. `position: absolute` inside the tab
   panel rather than `fixed`: a picker opened in invoice tab 3 must not cover
   invoice tab 1, and must not outlive switching away from it. */
.lookup-backdrop {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    background: rgba(0, 0, 0, .35);
}

.lookup {
    display: flex;
    flex-direction: column;
    width: min(46rem, 100%);

    /* A FIXED HEIGHT, not one that follows the rows.

       Without it the dialog sized to its content, so it collapsed as you
       typed — 222 matches tall, then one match tall — and the grid, the
       footer and the Cancel button all jumped up the screen under the
       pointer while somebody was still typing. Searching is the one moment
       a picker must hold still.

       `min(…, 100%)` so a short pane still bounds it: the dialog never
       grows past the pane it belongs to. The grid below takes the slack,
       which is what `flex: 1 1 auto; min-height: 0` on `.lookup-grid` is
       for. */
    height: min(34rem, 100%);
    max-height: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
    overflow: hidden;
}

.lookup-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .85rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.lookup-title { font-weight: 600; flex: 1 1 auto; }

.lookup-search {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .85rem;
    border-bottom: 1px solid var(--border);
}

.lookup-box { flex: 1 1 auto; padding: .35rem .55rem; font-size: .875rem; }

/* THE MODE CHIP. A leading space switches prefix to contains — invisible in
   both legacy apps, and the first thing a veteran tries. Showing it is the
   one thing here neither of them had. */
.lookup-mode {
    padding: .2rem .5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
    font-size: .75rem;
    cursor: pointer;
    white-space: nowrap;
}

.lookup-mode.on { background: var(--accent-bg, var(--bg)); color: var(--text); font-weight: 600; }

.lookup-filter-toggle, .lookup-filter-drop {
    padding: .2rem .5rem;
    border: 1px solid transparent;
    background: none;
    color: var(--muted);
    font-size: .75rem;
    cursor: pointer;
}

.lookup-filters { padding: .5rem .85rem; border-bottom: 1px solid var(--border); }

.lookup-filter-row {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .35rem;
}

.lookup-filter-row select,
.lookup-filter-row input { padding: .25rem .45rem; font-size: .8125rem; }

/* `min-height: 0` so the grid can shrink inside the flex column; without it
   a long list pushes the footer off the bottom of the dialog. */
.lookup-grid { flex: 1 1 auto; min-height: 0; overflow: auto; }

.lookup-rows { width: 100%; border-collapse: collapse; font-size: .875rem; table-layout: fixed; }

.lookup-rows th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: .35rem .6rem;
    text-align: left;
    font-size: .75rem;
    color: var(--muted);
    background: var(--bg);
    box-shadow: inset 0 -1px 0 var(--border);
}

.lookup-rows td {
    padding: .3rem .6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
    border-bottom: 1px solid var(--border);
}

.lookup-rows th.num, .lookup-rows td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.lookup-rows tbody tr { cursor: pointer; }
.lookup-rows tbody tr:hover { background: var(--bg); }
.lookup-rows tbody tr.selected { background: var(--accent-bg, var(--bg)); font-weight: 600; }

.lookup-foot {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .85rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* THE BUTTONS MUST NOT MOVE WHILE YOU ARE CLICKING.

   `Select 0` / `Select 1` / `Select 12` are three different widths, so the
   footer re-laid itself on every tick — the control under the pointer slid
   sideways as it was being used, which is the one moment a target has to
   hold still. A floor wide enough for a three-digit count fixes it, and the
   same floor on Cancel keeps the pair balanced. */
.lookup-foot button { min-width: 8.5rem; justify-content: center; }

/* The count and the tally sit on the LEFT and change width as you type —
   `222 matches` to `4 matches`. `flex: 0 1 auto` so the existing
   `.spacer { flex: 1 }` does the absorbing and these two do not compete for
   the slack; this may shrink with an ellipsis but never grows into it. */
.lookup-foot > .sub {
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- the field a form places ---- */

.lookup-field { display: flex; gap: .35rem; align-items: center; }

.lookup-code { flex: 0 0 9rem; }

/* Read-only and visibly so — it reports which record the code resolved to
   rather than inviting a second thing to type. */
.lookup-display {
    flex: 1 1 auto;
    background: var(--bg);
    color: var(--muted);
    border-style: dashed;
}

.lookup-open {
    flex: 0 0 auto;
    padding: .3rem .6rem;
    line-height: 1;
    cursor: pointer;
}

/* The global `button` rule in gnexus.css is for a Save button under a field:
   `margin-top: 1.25rem`. Reset for every button that is CHROME. */
.lookup-close,
.lookup-open,
.lookup-mode,
.lookup-filter-toggle,
.lookup-filter-drop,
.lookup-foot button,
.lookup-filter-row button,
.lookup-box { margin: 0; }

/* ---- multi-select ---- */

.lookup-rows th.tick,
.lookup-rows td.tick { width: 3rem; text-align: center; padding-left: .4rem; }

/* The ROW is the click target, so the box must not swallow the click and
   leave the two disagreeing about what is ticked. */
.lookup-rows td.tick input { pointer-events: none; margin: 0; }

/* Ticked and highlighted are DIFFERENT THINGS and must look different: one
   says "this is chosen", the other says "this is where the keyboard is". */
.lookup-rows tbody tr.ticked { background: var(--accent-bg, var(--bg)); }
.lookup-rows tbody tr.ticked.selected { outline: 2px solid var(--accent, var(--border)); outline-offset: -2px; }

/* `margin-left` and not a space in the markup: Razor collapses the
   whitespace between `@(…matches)` and this span, so the count ran straight
   into the tally — "222 matches· 2 selected". */
.lookup-tally { margin-left: .45rem; font-weight: 600; color: var(--text); }

/* ---- the picked list on a page ---- */

.picked {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin: .75rem 0 0;
    padding: 0;
    list-style: none;
}

.picked li {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    font-size: .8125rem;
}

.picked code { font-size: .75rem; color: var(--muted); }

.picked button {
    margin: 0;
    padding: 0 .2rem;
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
}

.picked button:hover { color: var(--danger, crimson); }

/* ---- the view range (ADR 0031) ---- */

/* THE CONTROL lives in the bar, hard right, before the account button. */
.bar-period {
    display: flex;
    align-items: center;
    margin-left: auto;
    padding-right: .25rem;
}

.bar-period select {
    margin: 0;
    padding: .15rem .4rem;
    font-size: .8125rem;
}

/* THE FACT lives on its own line under the bar.

   A label and a date range are two different things: the select is something
   you operate, this is something you read. Sharing the bar's row they
   competed with the brand and the account control for the same strip; given
   their own line the range has the whole width and the bar is back to three
   things.

   Thin on purpose — an ERP screen is read down, and every pixel here is a
   pixel off the grid underneath. */
.period-line {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    padding: .15rem .9rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    font-size: .75rem;
    line-height: 1.5;
    color: var(--muted);
}

.period-line strong { color: var(--text); font-weight: 600; }

.period-line-label { text-transform: uppercase; letter-spacing: .04em; }

/* `All` is the expensive preset. It says so rather than leaving a blank
   where dates would be. */
.period-line-note { font-style: italic; }

/* ---- the acting context (ADR 0032) ---- */

/* THE CONTROL sits beside the range, hard right, before the account button —
   the order ADR 0032 sketches: [ Sales Rep · CIPLA ▾ ] [ FY 2026-27 ▾ ].

   It takes the `margin-left: auto` so the PAIR is pushed right as one block,
   and cancels the range's own auto margin while it is there. Two auto margins
   would split the free space between them and strand the context selector in
   the middle of the bar. The sibling selector means the range is untouched on
   its own, which is the common case: most logins hold no mapping and this
   control does not render at all. */
.bar-context {
    display: flex;
    align-items: center;
    margin-left: auto;
    padding-right: .25rem;
}

.bar-context select {
    margin: 0;
    padding: .15rem .4rem;
    font-size: .8125rem;
}

.bar-context + .bar-period { margin-left: 0; }

/* THE FACT, on its own line ABOVE the range's.

   Above, because it is the stronger of the two: a range that is wrong shows
   you too little, and a context that is wrong is how a document is raised
   against the wrong account.

   Same shape as `.period-line` and deliberately NOT the same rule — it wants
   its own accent, because "I am acting as somebody" is a different kind of
   statement from "I am looking at these dates", and the day one of them needs
   to shout the two must be separable. */
.context-line {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    padding: .15rem .9rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    font-size: .75rem;
    line-height: 1.5;
    color: var(--muted);

    /* The one thing it does not share. A context is a restriction on what you
       can see, so the line carrying it is marked rather than merely present. */
    box-shadow: inset 3px 0 0 var(--accent);
}

.context-line strong { color: var(--text); font-weight: 600; }

/* The range a picker is bounded by (ADR 0031) — only shown when the lookup
   honours one, so a manufacturer picker never grows a control that would do
   nothing. */
.lookup-period {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .4rem .85rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.lookup-period select { margin: 0; padding: .2rem .4rem; font-size: .8125rem; }

/* ---- the adopt step on the supplier master (ADR 0032) ---- */

/* Asked BEFORE the form is filled in, because afterwards is too late:
   somebody who has typed an address will not go back and throw it away. */
.adopt {
    padding: .75rem .85rem;
    margin-bottom: .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

.adopt .section:first-child { margin-top: 0; }

.adopt-list { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 11rem; overflow-y: auto; }

.adopt-list li { margin: 0; }

.adopt-list button {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    width: 100%;
    margin: 0;
    padding: .3rem .5rem;
    border: none;
    border-radius: var(--radius);
    background: none;
    text-align: left;
    cursor: pointer;
}

.adopt-list button:hover { background: var(--surface); }

/* "customer C00021" beside a firm — the fact that decides whether this is the
   same company you already sell to. */
.adopt-list .tag {
    margin-left: .4rem;
    padding: 0 .35rem;
    border-radius: 999px;
    background: var(--accent-bg, var(--border));
    font-size: .6875rem;
}

button.link {
    margin: 0 0 0 .4rem;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
}

/* "SHOW INACTIVE" under a master's search box. Retired records are hidden by
   default and this is how one is found to be switched back on. Quiet on
   purpose — it is a filter, read dozens of times a day, not an action. */
.master-inactive {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .6rem;
    font-size: .8rem;
    color: var(--muted, inherit);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.master-inactive input { margin: 0; }

/* ---- the books: reports and the journal (ADR 0034) ---------------------- */

/* A REPORT IS ONE COLUMN, where a master is two.

   A FLEX COLUMN RATHER THAN A GRID, which `.master` is. A master has a
   fixed set of areas; a report has a title, however many lines of context it
   needs, the rows and a bar - and a grid with named rows would put the
   scrolling row in the wrong place the moment one screen carried one more
   line than another. The scroller claims what is left and nothing else has to
   know how many lines came before it.

   `height: 100%` of a parent that already has a definite height, never
   viewport arithmetic: that drifts whenever the bar or the tab strip changes,
   and being a few pixels out is what leaves a panel scrolling nothing. */
.report {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    height: 100%;
    min-height: 0;
}

/* The rows scroll under their own header. A trial balance is read by running
   the eye down the Debit column, which does not work if the column heading
   has scrolled off the top. */
.report-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

/* STICKY IN BOTH DIRECTIONS: the header stays at the top and the totals stay
   at the bottom, because "does it balance?" is the one line somebody opens
   this screen to read and it must not require scrolling to the end. */
.report-rows thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.report-rows tfoot th {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background: var(--surface);
    border-top: 2px solid var(--border);
    font-variant-numeric: tabular-nums;
}

.report-rows tfoot th.num,
.journal-legs tfoot th.num { text-align: right; }

/* The opening line is part of the statement, not a row of it. Italic and
   quiet, so the entries read as the list and this reads as where they start
   from. */
.report-rows tr.opening td {
    color: var(--muted, inherit);
    background: color-mix(in srgb, var(--border) 25%, transparent);
}

/* THE ANSWER, IN COLOUR. A trial balance that balances is the ordinary case
   and says so quietly; one that does not is the loudest thing on the screen,
   because nothing else in the books is worth reading until it is found. */
.balanced { color: var(--ok); font-weight: 600; }

.unbalanced {
    color: var(--danger);
    background: var(--danger-bg);
    font-weight: 600;
    padding: .35rem .6rem;
    border-radius: 6px;
}

/* The journal's legs: a table of inputs rather than a field grid, because a
   leg is a ROW and an accountant reads down the Debit column. */
.journal-legs { margin-top: .25rem; }

.journal-legs td { padding: .2rem .3rem; vertical-align: top; }

.journal-legs input {
    width: 100%;
    margin: 0;
}

.journal-legs input.num { text-align: right; font-variant-numeric: tabular-nums; }

.journal-legs tbody tr { cursor: default; }

/* Removing a leg. A glyph rather than a word: there is one per row and the
   column has to stay narrow enough that it costs the Account column nothing. */
.journal-legs .row-remove {
    margin: 0;
    padding: 0 .35rem;
    border: none;
    background: none;
    color: var(--muted, inherit);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1.6;
}

.journal-legs .row-remove:hover { color: var(--danger); }

/* THE Dr/Cr TOGGLE on the opening balance grid. It shows a derived answer and
   takes one click to disagree, so it is styled as a value that happens to be
   clickable rather than as a button competing with Post for attention. */
.journal-legs .side {
    margin: 0;
    padding: .1rem .45rem;
    min-width: 2.6rem;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: var(--surface-2, transparent);
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-variant-numeric: tabular-nums;
}

.journal-legs .side:hover { border-color: var(--accent); }

/* ---- the voucher edit log (ADR 0038) ----------------------------------- */

/* A FILTER ROW, with one control in it. Still a row: the register will grow a
   voucher-type filter before long, and a lone select floating above a table
   reads as a control that failed to load rather than as the only one. */
.report-filters {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.report-filters .master-search { max-width: 14rem; }

/* THE DETAIL CELL HAS TO UNDO `.master-rows td`, which is `max-width: 0`,
   `white-space: nowrap` and `overflow: hidden` — exactly right for a list of
   single-line rows and fatal for a table nested inside one. Found by reading
   that rule rather than by watching a timeline get clipped. */
.log-rows td.log-detail {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    padding: .5rem .75rem;
    background: color-mix(in srgb, var(--border) 18%, transparent);
}

/* A ROW THAT IS NOT A ROW. `height: 33px` applies to every
   `.master-rows tbody tr` for `Virtualize`'s sake; a table row treats height
   as a MINIMUM, so the timeline grows this row instead of spilling out of it.
   The pointer and the hover come off, because there is nothing here to
   choose. */
.log-rows tr.log-open { cursor: default; }
.log-rows tr.log-open:hover { background: none; }

.log-timeline {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

/* One event, with a rule down its left: a timeline is read as a sequence and
   the line is what makes it look like one rather than like three paragraphs. */
.log-moment {
    border-left: 2px solid var(--border);
    padding-left: .6rem;
}

.log-when {
    margin: 0 0 .25rem;
    font-variant-numeric: tabular-nums;
}

.log-when .sub { margin-left: .4rem; }

/* WHICH CHANGE IT WAS, in colour, and the three are deliberately not equal: a
   creation is the ordinary course of business, an alteration is worth a look,
   and a deletion is the one an auditor stops on. */
.change {
    display: inline-block;
    padding: .05rem .4rem;
    border-radius: 3px;
    font-size: .75rem;
    font-weight: 600;
}

/* AMBER FOR AN ALTERATION, and `--accent` was wrong for it: this theme's
   accent IS green, so a screenshot showed Created and Altered as two chips
   of the same colour — the distinction the three chips exist to make, lost.
   `--warn-bg`/`--warn-text` already exist for exactly this and are defined
   for both themes. */
.change.created { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.change.altered { background: var(--warn-bg); color: var(--warn-text); }
.change.deleted { background: var(--danger-bg); color: var(--danger); }

/* A voucher that no longer exists, said once and said plainly. */
.gone { color: var(--danger); }

/* The snapshot itself. Smaller than the register above it on purpose: it is
   EVIDENCE sitting inside a row, not a report of its own competing with the
   one the person opened.

   A TABLE INSIDE A TABLE INHERITS THE OUTER ONE'S RULES, and three of them
   are actively wrong here. Every one of these resets was put in after
   looking at a screenshot, because the Playwright assertions all passed
   while the thing was unreadable — `ToContainTextAsync` reads the DOM, and
   `ToBeVisibleAsync` is satisfied by a box, so neither can see text that is
   clipped to nothing or a header hidden behind another header:

   - `.report-rows thead th` is `position: sticky; top: 0`, so the snapshot's
     own header stuck to the top of the scroller and vanished UNDER the
     register's header.
   - `.report-rows tfoot th` is `position: sticky; bottom: 0`, which pinned
     "Total" to the bottom of the pane, away from the lines it totals.
   - `.master-rows td` is `max-width: 0; overflow: hidden`, which squashed
     every line to nothing, and `.master-rows tbody tr` forces 33px.

   Specificity is what makes these win: two classes and two elements beats
   the one class and two elements each of those rules has. */
.log-snapshot {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

.log-rows td.log-detail .log-snapshot th,
.log-rows td.log-detail .log-snapshot td {
    position: static;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.log-rows td.log-detail .log-snapshot tr { height: auto; }

.log-snapshot th,
.log-snapshot td {
    padding: .15rem .4rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.log-snapshot th.num,
.log-snapshot td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.log-snapshot tfoot th {
    border-bottom: none;
    border-top: 1px solid var(--border);
}

/* ---- document screens: purchase and sales (design §1-3) ---------------- */

/* A LINE GRID SCROLLS SIDEWAYS, and that is the honest answer for a purchase
   line: item, batch, expiry, MRP, rate, quantity, two units, the pack size, a
   discount and a tax is eleven columns, and squeezing them into the form pane
   would make every one of them too narrow to read. A document screen is used
   on a desk, not a phone. */
.doc-lines {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.doc-lines table { min-width: 56rem; }

.doc-lines input { min-width: 4.5rem; }

.doc-lines .lookup-field { min-width: 11rem; }

/* WHICH LOTS A LINE WILL DRAW FROM — the column no other screen has. Stacked,
   because a line can take from several and each needs its quantity, its batch
   and what it cost. */
.journal-legs td.takes {
    display: table-cell;
    font-size: .75rem;
    line-height: 1.5;
    white-space: nowrap;
}

.journal-legs td.takes .take {
    display: block;
    font-variant-numeric: tabular-nums;
}

/* ---- closing the books (ADR 0039) -------------------------------------- */

/* THE WATERMARK, SAID LOUDLY. It is the one fact on the screen that changes
   what the rest of the product will accept, and a business reading it is
   usually checking whether a refusal elsewhere was this or a bug. `--warn-bg`
   rather than danger: a closed period is the CORRECT state for a filed month,
   not a fault. */
.closed-through {
    margin: 0;
    padding: 0.7rem 0.9rem;
    background: var(--warn-bg);
    color: var(--warn-text);
    border-left: 3px solid var(--warn-text);
    line-height: 1.5;
}

/* THE HISTORY. It reuses `.change` from the edit log for the Closed/Reopened
   chip, deliberately: both tables answer "what was done to the books", and two
   different visual languages for that on two screens would be two things to
   learn. `created` is the green one and `deleted` the red one — a REOPEN is
   the dangerous act here, so it takes the alarming colour even though no row
   was deleted to earn it. */
.closure-rows td {
    /* OVERRIDES `.master-rows td`, which is `max-width: 0; overflow: hidden`
       for the one-line master lists. A reason is a sentence and has to wrap:
       the edit log learnt this the expensive way, from a screenshot rather than
       from an assertion, because a clipped cell is visible to a person and
       invisible to `ToContainTextAsync`. */
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    vertical-align: top;
}

.closure-rows tr { height: auto; }

/* Both dates in one cell, the earlier one quietly: "30 Apr 2026 / was 31 May
   2026" is a complete sentence and one date is not. */
.closure-rows .sub {
    display: block;
    font-size: 0.78rem;
    opacity: 0.75;
}

/* THE REASON, SPANNING THE ROW ABOVE IT. Indented and quiet so a scan down the
   table reads the acts, and the sentence is there when one of them is the row
   somebody came for. No border above it: it belongs to the act, and a rule
   between them would make it look like a row of its own. */
.closure-rows tr.closure-why td {
    padding-top: 0;
    padding-bottom: 0.6rem;
    border-top: 0;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.45;
}

.closure-rows tr.closure-why td::before {
    content: "“";
}

.closure-rows tr.closure-why td::after {
    content: "”";
}

/* AND THE ACT ROW LOSES ITS BOTTOM BORDER when a reason follows, so the two
   read as one entry. */
.closure-rows tr.closure-act:has(+ tr.closure-why) td {
    border-bottom: 0;
    padding-bottom: 0.2rem;
}

/* THE HINT UNDER THE FIELD, NOT AROUND IT. `.sub` is inline by default, so a
   two-line explanation beside a date box wraps around it and the first words
   end up level with the input — "LEAVE IT" on one line and "EMPTY TO REOPEN
   EVERYTHING" below the box. Scoped to this screen rather than changed
   globally: ten other forms rely on the inline behaviour. */
.books-closure .field-grid .sub {
    display: block;
    margin-top: 0.35rem;
    line-height: 1.45;
}

/* ---- financial statements (ADR 0044) ---------------------------------- */

/* A group is the figure that matters; its accounts are detail beneath it, and
   a balancing figure ("Net profit") is set apart so it reads as the plug that
   makes the two sides agree rather than as another group. */
.stmt .stmt-group { font-weight: 600; }
.stmt .stmt-account { color: var(--muted, #6b7280); font-size: .92em; }
.stmt .stmt-balancing { font-style: italic; border-top: 1px dashed var(--border, #d1d5db); }
.stmt .stmt-heading { font-weight: 700; text-transform: uppercase; font-size: .8em; letter-spacing: .04em; }

/* ---- the evidence viewer (ADR 0042) ------------------------------------ */

/* Full screen over everything, the app's own drawer and tab strip included: a
   scanned bill is read at size, and a viewer that left half the app showing would
   be a bigger problem than a loud one. Above the toast layer (z-index 1000). */
.evidence-viewer {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    background: rgb(15, 23, 42);
    outline: none;
}
.evidence-viewer-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem 1rem;
    background: var(--surface, #fff);
    border-bottom: 1px solid var(--border, #d1d5db);
}
.evidence-viewer-bar .spacer { flex: 1; }
.evidence-viewer-body { flex: 1; width: 100%; border: 0; background: #fff; }
.evidence-viewer-image {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: rgb(15, 23, 42);
    min-height: 0;
}
/* Fitted to the window, small ones scaled up: a viewer shows the whole scan. */
.evidence-viewer-image img { width: 100%; height: 100%; object-fit: contain; }
