﻿/*
 * The house style for a control on its own - the counterpart of Resources/Styles/Controls.xaml,
 * and deliberately the same split: this file is a button, an input, a tick; layouts.css is a
 * button in a toolbar and an input in a form.
 *
 * The figures are read off the XAML styles rather than invented, so a screen looks the same in
 * either head while both exist. Where the XAML carries a literal - BaseButton pins its padding
 * at 14,0,14,0 and its radius at 6 - the token with that value is used here instead.
 */

/* ==========================================================================
   Icons

   Inline SVG stroked in currentColor, which is the one real gain of a WebView over the XAML
   head: MAUI rasterises at build time, so there a colour and a size are baked into the asset and
   74 icons become 458 files. Here the tone comes from whatever is drawing the icon, exactly as
   IconTone intends - a filled button gives it PosOnBrand because that is the button text colour.
   ========================================================================== */

.icon {
    width: var(--icon-size);
    height: var(--icon-size);
    flex-shrink: 0;
    /* An icon sits on the caption baseline rather than on the line box, or it rides high. */
    vertical-align: -0.15em;
}

.icon--tile { width: var(--icon-size-tile); height: var(--icon-size-tile); }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: var(--control-height);
    padding: 0 var(--space-4);
    border: 1px solid var(--pos-border-strong);
    border-radius: var(--radius);

    /* The sample's control pill: translucent white over whatever it is standing on, with the
       page's own hairline. Deliberately lighter than a card, so a row of buttons on a toolbar
       does not read as a row of cards. */

    /*
     * NO GLASS EDGE, and this is the one rule of the treatment worth writing down twice.
     *
     * PosGlassSheen is OPAQUE white on purpose, and on the surface it was tuned for that is
     * right: a glass card's own fill starts at 94% white, so a sheen at anything less is darker
     * than the thing it is meant to be lighting and simply disappears. A button is not that
     * surface. Its fill is flat, and a filled one is a navy gradient - so the same inset landed
     * as a pure white hairline ACROSS THE TOP OF EVERY BUTTON IN THE APPLICATION, read as a
     * border rather than as a lit edge, and on the primary and accent buttons it was a white
     * stripe on dark navy.
     *
     * Glass goes on things that float, which a button on a toolbar does not do. The elevation on
     * hover and the brand glow on a filled one are what give these depth.
     */
    background: var(--pos-control-fill);
    color: var(--pos-text);
    font-family: inherit;
    font-size: var(--text-base);
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    /*
     * Transitions are fine here, and the comment that used to forbid them was carried over from
     * the XAML head by mistake. That flicker was a WinUI one: MAUI cleared BackgroundColor and
     * the parent panel then took the pointer, because a transparent background is not
     * hit-testable. A document has neither of those mechanisms - hover is CSS state on the
     * element itself - so the fault cannot occur and there is nothing to guard against.
     *
     * Kept to 90ms all the same. A button on the counter is pressed a hundred times an hour and
     * anything slower reads as lag rather than as polish.
     */
    transition:
        background var(--motion-instant) var(--ease-standard),
        border-color var(--motion-instant) var(--ease-standard),
        box-shadow var(--motion-instant) var(--ease-standard),
        transform var(--motion-instant) var(--ease-standard);
}

/*
 * The tactile detail, and the whole of it. One pixel down and the shadow pulled in - enough that
 * a press is felt, far short of a button that looks like it belongs on a cash register. It is
 * translate rather than margin so nothing around it reflows.
 */
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:hover { background: var(--pos-control-fill-hover); border-color: var(--pos-border-strong); box-shadow: var(--elev-1); }
.btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.btn:disabled:hover { background: var(--pos-surface); border-color: var(--pos-border-strong); box-shadow: none; }
.btn:disabled:active { transform: none; }

/*
 * Focus is drawn, and drawn clearly. This is a keyboard-first application: a cashier tabbing
 * through a form has to be able to see where they are, and the platform default outline is
 * exactly what a WebView loses when a page restyles its buttons.
 */
/*
 * FOCUS IS A THIN OUTLINE NOW, NOT A SHADOW HALO, and the rule it replaces is worth recording.
 * The halo existed because an outline cannot be rounded to match its control, so on a 6px input
 * it drew a rectangle with the corners poking out of it. At a 2px radius there is nothing left
 * for it to poke out of - the objection went with the corners - and a hairline is what was asked
 * for.
 */
.btn:focus-visible,
.field__input:focus-visible,
.field__select:focus-visible,
.tab:focus-visible,
.rail__item:focus-visible,
.link:focus-visible {
    outline: 1px solid var(--pos-focus);
    outline-offset: 1px;
}

/* The action on the screen. One per screen, and the teal is not it. */
.btn--primary {
    background: var(--pos-primary);
    border-color: transparent;
    color: var(--pos-on-brand);
    font-weight: 700;
}

.btn--primary { background: var(--grad-primary); box-shadow: var(--glow-primary); }
.btn--primary:hover { background: var(--grad-primary-hover); box-shadow: var(--glow-primary); }
.btn--primary:active:not(:disabled) { background: var(--pos-primary-active); box-shadow: none; }
.btn--primary:disabled:hover { background: var(--pos-primary); }

/* Money in, and confirmations. The teal earns its place here and almost nowhere else. */
.btn--accent {
    background: var(--pos-primary);
    border-color: transparent;
    color: var(--pos-on-brand);
    font-weight: 700;
}

.btn--accent { background: var(--grad-primary); box-shadow: var(--glow-primary); }
.btn--accent:hover { background: var(--grad-primary-hover); box-shadow: var(--glow-primary); }
.btn--accent:active:not(:disabled) { background: var(--pos-primary-active); box-shadow: none; }
.btn--accent:disabled:hover { background: var(--pos-accent); }

/* Everything that is a real action but not the action. */
.btn--secondary { color: var(--pos-primary); }

/* Cancelling a document, deleting a row. Never the default action on a screen. */
.btn--danger { color: var(--pos-danger); border-color: var(--pos-danger); }
.btn--danger:hover { background: var(--pos-danger-soft); }

.btn--link {
    height: var(--control-height-sm);
    padding: 0 var(--space-2);
    border-color: transparent;
    background: none;
    color: var(--pos-primary);
    font-size: var(--text-sm);
}

.btn--link:hover { background: var(--pos-primary-soft); }

/*
 * A document number that opens the document. Deliberately not .btn--link: this sits inside a
 * table cell among figures, so it keeps the row's own type size and line height and adds nothing
 * but the colour and the underline that say it can be pressed. A button element rather than an
 * anchor because ShellNavigation owns Back, not browser history.
 */
.doclink {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--pos-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: var(--pos-border-strong);
    cursor: pointer;
    white-space: nowrap;
}

.doclink:hover { color: var(--pos-primary-hover); text-decoration-color: currentColor; }

.doclink:focus-visible {
    outline: 2px solid var(--pos-focus);
    outline-offset: 1px;
    border-radius: var(--radius-sm);
}

.btn--large { height: var(--control-height-lg); font-size: var(--text-lg); }
.btn--small { height: var(--control-height-sm); padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn--block { width: 100%; }

/* ==========================================================================
   Branch switcher

   A short list of rows, each its own button rather than a form to submit — picking one acts
   straight away. The current row is the one exception to "pick one to switch": disabled, marked,
   never itself clickable.
   ========================================================================== */

.branch-switch { display: flex; flex-direction: column; gap: var(--space-1); }

.branch-switch__row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    height: var(--control-height);
    padding: 0 var(--space-3);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius);
    background: var(--pos-surface);
    color: var(--pos-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.branch-switch__row:hover:not(:disabled) { background: var(--pos-grid-row-hover); }

.branch-switch__row--current {
    border-color: var(--pos-primary);
    background: var(--pos-primary-soft);
    color: var(--pos-primary);
    font-weight: 650;
    cursor: default;
}

/*
 * The one Back, in the shell fixed bar.
 *
 * Its own style rather than a link, because it is not a link: it is the only way out of a screen,
 * it is the same button on every screen, and it has to be findable without being looked for. A
 * transparent borderless caption in the corner of a white bar was not - hence the soft brand tint,
 * which reads as something you press without competing with the page own actions.
 */
.btn--back {
    height: var(--control-height-sm);
    padding: 0 var(--space-4) 0 var(--space-3);
    border-color: transparent;
    background: var(--pos-primary-soft);
    color: var(--pos-primary);
    font-weight: 700;
}

.btn--back:hover { background: var(--pos-primary-soft); filter: brightness(0.97); }

/* An icon-only button still needs a square target and an accessible name. */
.btn--icon { width: var(--control-height); padding: 0; }
.btn--icon.btn--small { width: var(--control-height-sm); }

/* ==========================================================================
   Links that are buttons

   Anything clickable says so with the pointer. In the XAML head that needs a Windows seam over
   UIElement.ProtectedCursor; here it is one declaration, and the rule is the same - it goes
   wherever a click handler does.
   ========================================================================== */

.link {
    border: 0;
    background: none;
    padding: 0;
    color: var(--pos-primary);
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.link:hover { text-decoration: underline; }

[role="button"], .clickable { cursor: pointer; }

/* ==========================================================================
   Text
   ========================================================================== */

.muted { color: var(--pos-text-muted); font-size: var(--text-sm); }
.subtle { color: var(--pos-text-subtle); font-size: var(--text-sm); }
.strong { font-weight: 650; }
.danger-text { color: var(--pos-danger); }
.accent-text { color: var(--pos-accent); }
.warning-text { color: var(--pos-warning); }

/*
 * A figure. Tabular numerals so a column of money lines up on the decimal point without the
 * table having to be monospaced, which is what the XAML head Numeric style is for.
 */
/*
 * Numeric values align left, like every other column. The house rule is that alignment is
 * a property of the table rather than of the data type, so a figure does not sit
 * differently from the text beside it and nobody has to relearn a screen.
 *
 * tabular-nums stays, and is not alignment: it makes every digit the same width, so a
 * column of figures still forms clean vertical stripes to scan down instead of shivering
 * as a 1 follows a 7. It is what is left of the readability that right alignment used to
 * buy, and it costs nothing.
 */
.numeric { font-variant-numeric: tabular-nums; text-align: left; white-space: nowrap; }

.field-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--pos-text-muted);
}

/*
 * The asterisk on a required field's caption. Its own colour rather than the caption's, because
 * a marker the same weight and hue as the words beside it stops being a marker - and its own
 * class rather than the danger token used directly, so a required field never reads as a field
 * in error.
 */
.req { color: var(--pos-danger); font-weight: 700; margin-left: 2px; }

/* ==========================================================================
   The field hint marker

   What a box is for, on demand rather than always. It was a line of muted text under every
   control; eighty-odd of those is a paragraph between each field and the next, which is what made
   the forms read as cluttered. See FieldHint.razor for the whole argument, and layouts.css for why
   .field__hint still exists and still means something different.

   IT COSTS NO HEIGHT, which is the entire point. Absolutely positioned in the field's own top
   right corner, so it lands on the caption's line and the field is exactly as tall as its label
   and its box - which is what let the change be a tag rename across eighty screens rather than a
   re-layout of each one.
   ========================================================================== */

.field__info {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 1;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 16px;
    height: 16px;

    color: var(--pos-text-subtle);
    cursor: help;
    transition: color var(--motion-instant) var(--ease-standard);
}

.field__info:hover,
.field__info:focus-visible { color: var(--pos-primary); }

/*
 * The same outline every other focusable control on this sheet takes, with the marker's own round
 * radius so the ring follows the glyph rather than boxing it.
 */
.field__info:focus-visible {
    outline: 1px solid var(--pos-focus);
    outline-offset: 1px;
    border-radius: var(--radius-lg);
}

.field__info .icon { width: 14px; height: 14px; }

/*
 * DISPLAY:NONE WHEN HIDDEN, never opacity:0 and never visibility:hidden. Those two take a thing
 * away from the eye and not from the scroll box: it is still laid out, it still contributes to the
 * page's scrollable width, and on a marker sitting at a field's right-hand edge that is a
 * horizontal scrollbar on a page with no business having one. It is exactly how the deleted
 * Popover went wrong.
 */
.field__bubble { display: none; }

.field__info:hover .field__bubble,
.field__info:focus-visible .field__bubble,
.field__info:focus-within .field__bubble {
    display: block;

    position: absolute;
    top: calc(100% + var(--space-2));

    /*
     * Anchored to the marker's right edge and opening leftwards, because the marker is itself at
     * the field's right edge - opening the other way would put the bubble off the side of the
     * form. Downwards rather than upwards for the same kind of reason: a form has the rest of
     * itself below a field and, at the top of a dialog, nothing above it.
     */
    right: 0;

    width: max-content;
    max-width: 260px;

    padding: var(--space-2) var(--space-3);

    font-size: var(--text-xs);
    font-weight: 400;
    line-height: 1.45;
    text-align: left;

    /*
     * Wraps rather than running on one line. The Popover's white-space:nowrap is the other half of
     * how it grew a scrollbar, and a hint is a sentence rather than a caption.
     */
    white-space: normal;

    color: var(--pos-text);
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    box-shadow: var(--elev-3);
}

/*
 * The tone classes a few hints carried land on the marker, so the glyph says at a glance that this
 * one is saying something has changed. The bubble keeps the page's own ink either way - coloured
 * prose in a small box is harder to read, and the marker has already made the point.
 */
.field__info.accent-text .field__bubble,
.field__info.warning-text .field__bubble,
.field__info.danger-text .field__bubble { color: var(--pos-text); }

.section-heading {
    font-size: var(--text-sm);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pos-text-muted);
}

/* ==========================================================================
   Inputs

   Compact on purpose, in the spirit of form-control-sm. These are the numbers that make the
   difference between a dense ERP screen and a stretched mobile form.
   ========================================================================== */

.field__input,
.field__select,
.field__textarea {
    width: 100%;

    /*
     * SHORTER THAN A BUTTON, ON PURPOSE, and its own token rather than ControlHeight shared.
     *
     * A box that is typed into is a line of type; a button is a target for a hand. They were one
     * number, so taking the space off the boxes would have taken it off every button in the
     * application - which was not what was asked for and is not what a dense form needs.
     *
     * The side padding is untouched. What a field holds is a name, an address or a figure, and
     * narrowing the box costs readability at the counter rather than buying anything back.
     */
    height: var(--field-height);
    padding: 0 var(--space-3);
    border: 1px solid var(--pos-border-strong);
    border-radius: var(--radius);
    background: var(--pos-surface);
    color: var(--pos-text);
    font-family: inherit;
    font-size: var(--text-base);
}

.field__textarea { height: auto; min-height: calc(var(--field-height) * 2); padding: var(--space-2) var(--space-3); resize: vertical; }

/*
 * A FIGURE THE SCREEN WORKS OUT, wearing a box's shape so it lines up with the boxes beside it -
 * on an <output>, never an <input>, so there is nothing here to type into. A shade of the page's
 * sunken ground is what says so at a glance. Flex rather than the box's own line-height because
 * it centres its own text where an input does that natively.
 */
.field__readout {
    display: flex;
    align-items: center;
    background: var(--pos-surface-sunken);
    color: var(--pos-text);
    font-weight: 700;
    overflow: hidden;
    white-space: nowrap;
}

.field__input,
.field__select,
.field__textarea {
    transition: border-color var(--motion-instant) var(--ease-standard);
}

.field__input:hover:not(:disabled),
.field__select:hover:not(:disabled),
.field__textarea:hover:not(:disabled) { border-color: var(--pos-text-subtle); }

/* A focused field says so on its own edge and nowhere else. No halo: asked for directly, and a
   3px glow around every box on a dense form is most of what made a screen look padded. */
.field__input:focus, .field__select:focus, .field__textarea:focus {
    border-color: var(--pos-focus);
    outline: 1px solid var(--pos-focus);
    outline-offset: 0;
}

/*
 * A field that is sometimes empty greys out; it does not disappear. A control that comes and
 * goes re-flows the row under the cashier hands mid-sale, and nothing to choose between is not
 * the same as nothing to show.
 */
.field__input:disabled,
.field__select:disabled,
.field__textarea:disabled {
    background: var(--pos-surface-sunken);
    color: var(--pos-text-subtle);
    cursor: default;
}

/*
 * A view-only form is the same form with its boxes greyed (the disabled look above) and nothing to
 * press. The fieldset only exists to disable what is inside it, so it must not draw as one or take
 * part in layout: display: contents hands its children straight to whatever grid or flex row the
 * form is laid out in.
 */
.readonly-scope { display: contents; border: 0; margin: 0; padding: 0; min-width: 0; }
.readonly-scope:disabled .btn:disabled { opacity: 1; }

.field__input--numeric { text-align: left; font-variant-numeric: tabular-nums; }

.field__input::placeholder, .field__textarea::placeholder { color: var(--pos-text-subtle); }

/* Native date and number spinners are browser furniture in the middle of an application. */
.field__input[type="number"]::-webkit-inner-spin-button,
.field__input[type="number"]::-webkit-outer-spin-button { appearance: none; margin: 0; }

.field__select {
    appearance: none;
    padding-right: var(--space-6);
    /* The chevron is drawn rather than imported, so it tints with the text like every icon. */
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: right var(--space-4) center, right var(--space-3) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
}

/* ==========================================================================
   Tick boxes
   ========================================================================== */

.check {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    font-size: var(--text-base);
}

.check__box {
    width: var(--check-box-size);
    height: var(--check-box-size);
    flex-shrink: 0;
    margin: 0;
    accent-color: var(--pos-primary);
    cursor: pointer;
    transition: box-shadow var(--motion-instant) var(--ease-standard);
}

.check__box:focus-visible { outline: 1px solid var(--pos-focus); outline-offset: 1px; }

.check--disabled { color: var(--pos-text-subtle); cursor: default; }
.check--disabled .check__box { cursor: default; }

/* ==========================================================================
   Status pills

   Wording and colour are declared where the pill is used, never inside a converter class - the
   same rule TextMap and ToneMap encode in the XAML head.
   ========================================================================== */

/*
 * A status chip. Tinted fill, matching text, and a hairline in the same hue.
 *
 * The border is the whole of what was added and it earns its place: a soft fill on a white row
 * has almost no edge, so down a column they read as coloured text rather than as a set of states.
 * The hairline gives each one a boundary without making it louder - which is what a saturated
 * fill would do instead, and saturated pills down a data grid are how a business screen ends up
 * looking like a dashboard demo.
 *
 * currentColor, so the six tones below set one colour and get their border for free. There is no
 * seventh: a status vocabulary bigger than six stops being scannable.
 */
.pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-3);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid currentColor;
}

.pill--neutral { background: var(--pos-surface-sunken); color: var(--pos-text-muted); }
.pill--info    { background: var(--pos-info-soft);     color: var(--pos-info); }
.pill--success { background: var(--pos-success-soft);  color: var(--pos-success); }
/* Owing money is ordinary trade. Red is kept for Cancelled, the one state that says a fault. */
.pill--warning { background: var(--pos-warning-soft);  color: var(--pos-warning); }
.pill--danger  { background: var(--pos-danger-soft);   color: var(--pos-danger); }

/* ==========================================================================
   The busy and the said-so lines
   ========================================================================== */

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--pos-border-strong);
    border-top-color: var(--pos-primary);
    border-radius: var(--radius-pill);
    animation: spin 0.7s linear infinite;
}

/*
 * The error and note line every screen shows. Same shape as an alert row on the dashboard, and
 * for the same reason: a bar down the leading edge in the message's own colour, so the severity
 * survives a glance where a soft tint on white does not.
 *
 * It appears where a screen's result appears rather than floating over the page, and it is not
 * dismissible - a failure somebody can flick away without reading is a failure they will report
 * as "it just did nothing".
 */
.banner {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    border-left: 3px solid currentColor;
    animation: banner-in var(--motion-fast) var(--ease-out);
}

@keyframes banner-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.banner--error   { background: var(--pos-danger-soft);  color: var(--pos-danger); }
.banner--note    { background: var(--pos-accent-soft);  color: var(--pos-accent); }
.banner--warning { background: var(--pos-warning-soft); color: var(--pos-warning); }
.banner--info    { background: var(--pos-info-soft);    color: var(--pos-info); }

/* ==========================================================================
   Toasts

   The message ABOUT AN ACTION - saved, cancelled, refused - in the bottom-right
   corner rather than in the page.

   The reason it moved is that it was never really page content. It appeared and
   disappeared between one action and the next, so on every screen carrying one
   the whole layout shifted by the height of a line at exactly the moment
   somebody was reading it - and on New Sale that height came out of the lines
   grid, which is to say out of the sale being rung up, on precisely the sales
   that had just gone wrong.

   The other .banner blocks above are NOT this. A dialog's own refusal, the
   cancelled notice on an expense, the "goods still out" line on a processing
   order - those explain the thing they sit beside and belong in the flow.
   ========================================================================== */

.toasts {
    position: fixed;

    /*
     * THE TOP-RIGHT CORNER, under the top bar. It was bottom-right, which is where New Sale's Save
     * and Save and print sit - a refusal drawn there covered the very buttons somebody needed to
     * press next. The top edge has only the title bar's own controls, and the strip starts below
     * them (--toast-top) so it never covers the way out of a screen either.
     */
    right: var(--space-4);
    top: var(--toast-top);

    /* Above the lookup list (200), the picture preview (250) and a dialog (100),
       because a refusal has to be readable whatever else is open. */
    z-index: 400;

    display: grid;
    gap: var(--space-2);
    max-width: min(30rem, 50vw);

    /* The strip itself takes no clicks; each toast takes its own, so text in one
       can still be selected while nothing behind it is blocked. */
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-surface);
    font-size: var(--text-sm);

    /*
     * A FILLED SURFACE, never a tint. The soft tokens are what every .banner in
     * the page uses and they are the wrong thing out here: PosAccentSoft is teal
     * at ten percent, so a floating message drew whatever screen it landed on
     * straight through itself - a table, a form, half a figure - behind the one
     * sentence somebody has to read at the moment it appears. The strong colour
     * carries PosOnBrand in both themes, which is what the filled button and the
     * grid header already do, and the fill is what says error or saved now that
     * there is no coloured rule down the side to do it.
     *
     * Flat, not a gradient: five of those are declared for the app and each is
     * built from two colours already neighbouring in the palette. A sixth, on a
     * toast, would be decoration.
     */
    color: var(--pos-on-brand);

    /* Floating, so it takes the floating level. No lit edge: the sheen is opaque
       white, which on a solid red or teal band is a drawn line rather than a catch
       of light - the same reason a button has none. */
    box-shadow: var(--elev-3);
    animation: toast-in var(--motion-base) var(--ease-out);
}

.toast--error { background: var(--pos-danger); }
.toast--note  { background: var(--pos-accent); }

/*
 * A confirmation goes away on its own; a refusal does not.
 *
 * "Saved." is worth seeing and not worth keeping, so it fades after five seconds.
 * An error stays until the next action clears it, because it is the one message
 * somebody may need to read twice, copy a number out of, or still have on screen
 * when they come back from asking a colleague.
 */
.toast--note {
    animation:
        toast-in var(--motion-base) var(--ease-out),
        toast-out var(--motion-base) var(--ease-standard) 5s forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(calc(var(--space-3) * -1)); }
    to { opacity: 1; transform: none; }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(calc(var(--space-2) * -1)); visibility: hidden; }
}

/*
 * Narrow enough and the width matters rather than the corner: the strip keeps its
 * own padding on both sides so a long refusal wraps instead of running off the
 * screen.
 */
@media (max-width: 860px) {
    .toasts { max-width: calc(100vw - var(--space-4) * 2); }
}

/* ==========================================================================
   A product picture

   Shown wherever a product is picked or listed. A row whose DTO says HasImage is false never
   calls the server at all, which is why this has an empty state rather than a broken image.
   ========================================================================== */

.thumb {
    display: grid;
    place-items: center;
    width: var(--control-height);
    height: var(--control-height);
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-sm);
    background: var(--pos-surface-sunken);
    color: var(--pos-text-subtle);
}

.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb--large { width: var(--space-7); height: var(--space-7); }

/*
 * The picture a thumbnail opens into when it is hovered, drawn once at the top of the shell and
 * placed beside the row by pos.placeBeside. Three things about it are deliberate.
 *
 * It takes no clicks. The row underneath is usually a lookup result being picked with the mouse,
 * and a panel that swallowed that press would make choosing a product with a picture behave
 * differently from choosing one without.
 *
 * It is solid, not glass, and it is the one floating thing in the app that is. Glass says "this
 * is over that" - which is worth having on a result list, where the row behind is context. Here
 * the picture IS the content, and letting a table of figures show through the label somebody is
 * squinting at costs exactly the clarity this exists to provide.
 *
 * It sits above the lookup list at 200 and the dialog at 100, because a counter hand hovers a
 * thumbnail inside both of those.
 */
.picture-preview {
    position: fixed;
    z-index: 250;
    pointer-events: none;
    width: var(--picture-preview-size);
    padding: var(--space-2);
    display: grid;
    gap: var(--space-2);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);

    /*
     * Lit like every other surface and deliberately still opaque. This one floats, so it could
     * take the fill - but what it floats over is a list of products and what it holds is a
     * photograph of one of them, and a second cylinder showing faintly through the first is the
     * one thing this control exists to prevent.
     */
    background: var(--pos-surface);
    box-shadow: var(--elev-3), var(--glass-edge);
    animation: preview-in var(--motion-fast) var(--ease-out);
}

/*
 * Contain, never cover, and a fixed height with it. A cylinder photographed upright and a fitting
 * photographed on its side are different shapes, and cropping to a square is how a label ends up
 * outside the box that was opened to read it. The height is fixed so the panel is the same size
 * before the picture has decoded as after - a box that resized under the mouse would be placed
 * against the wrong rectangle.
 */
.picture-preview img {
    width: 100%;
    height: var(--picture-preview-size);
    object-fit: contain;
    border-radius: var(--radius);
    background: var(--pos-surface-sunken);
}

.picture-preview__caption {
    padding: 0 var(--space-1);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--pos-text-muted);
    text-align: center;
    overflow-wrap: anywhere;
}

@keyframes preview-in {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: none; }
}

/*
 * The file input a styled label stands in for. Hidden from sight but not from the keyboard or a
 * screen reader - display: none would take it out of the tab order and off the accessibility
 * tree, which would leave the button unreachable without a mouse.
 */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Search box

   Search is live everywhere: the spinner sits inside the box being typed into rather than over
   the table, because the table keeps its previous rows while a new search runs. A table that
   swaps its body for a spinner on every keystroke loses the one thing that says what it was a
   list of.
   ========================================================================== */

.searchbox { position: relative; min-width: 0; width: 340px; max-width: 100%; }

.searchbox__input { padding-left: calc(var(--space-3) + var(--icon-size) + var(--space-2)); }

.searchbox__icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--pos-text-subtle);
    pointer-events: none;
    display: flex;
}

.searchbox__spinner { position: absolute; right: var(--space-3); top: 50%; transform: translateY(-50%); }

/* The browser's own clear cross, which duplicates Escape and sits where the spinner goes. */
.searchbox__input::-webkit-search-cancel-button { appearance: none; }

/* ==========================================================================
   Segmented control

   Four choices, always visible, with the current one pressed. It replaces a status column read
   on the left and a row of buttons pressed on the right: on the attendance sheet those were
   different columns, so reading somebody's state and correcting it meant the eye travelling
   between them thirty times. Here it is one glance and one press.

   The pressed segment carries a fill rather than an outline, because at a glance down a column
   of thirty rows an outline reads as hover.
   ========================================================================== */

.seg {
    display: inline-flex;
    border: 1px solid var(--pos-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--grad-glass);
    box-shadow: var(--glass-edge);
}

.seg__btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    height: var(--control-height);
    padding: 0 var(--space-3);
    border: 0;
    border-left: 1px solid var(--pos-border);
    background: transparent;
    color: var(--pos-text-muted);
    font: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
    white-space: nowrap;
}

.seg__btn:first-child { border-left: 0; }

.seg__btn:hover:not(:disabled) { background: var(--pos-surface-hover); color: var(--pos-text); }

.seg__btn:disabled { opacity: 0.5; cursor: default; }

.seg__btn--on,
.seg__btn--on:hover:not(:disabled) {
    background: var(--pos-primary);
    color: var(--pos-on-brand);
}

/* ==========================================================================
   Tenders

   How a document is being paid: a tab per payment method, each with its own amount. ONE control
   for the whole application - a sale, a supplier bill, a credit note either way and the three
   payment forms - which is why these rules are here rather than in sale.css, where they lived
   while the counter was the only screen drawing them.
   ========================================================================== */

/* ========================================================================== 
   Tenders 
   ========================================================================== */ 
 
/* 
 * THE WHOLE OF HOW A SALE IS PAID, IN ONE BORDERED PANEL - asked for directly, and it is the fix 
 * for a real fault rather than decoration. 
 * 
 * TenderTabs drew no wrapper at all, so its tab strip and its three boxes were inlined into 
 * .sale__settle as ordinary siblings of the fee and the bill discount. The strip was the only 
 * item on that row allowed to grow, so it absorbed all the slack: the tabs sat hard against the 
 * fields on the left and the Amount and Cash given boxes were pushed to the far right-hand end, 
 * the better part of a screen from the tabs that own them, with nothing saying the two were one 
 * control. 
 * 
 * So the panel is the single flex item now, the strip and the fields stack inside it, and it 
 * wraps as a unit. flex-basis is what the fields actually need - the two money boxes at 110 and 
 * the transaction id at 170, plus the gaps - so it takes a line of its own only when the row 
 * genuinely cannot hold it, rather than splitting itself across two. 
 * 
 * IT COSTS A ROW OF HEIGHT and that was weighed: this is the one screen in the application whose 
 * vertical budget is the sale being rung up, since every row of furniture is subtracted from the 
 * lines a cashier can see. The padding is therefore the tight one and the border does the 
 * grouping - a fill or a shadow here would say the same thing and cost more. 
 */ 
.tenders__panel { 
    flex: 1 1 400px; 
    min-width: 0; 
    display: flex; 
    flex-direction: column; 
    gap: var(--space-2); 
    padding: var(--space-2) var(--space-3) var(--space-3); 
    border: 1px solid var(--pos-border-strong); 
    border-radius: var(--radius-surface); 
} 
 
/* 
 * THE TAB STRIP, ACROSS THE HEAD OF THE PANEL. It carries no flex-basis of its own any more: it is 
 * a block inside a column, so it is the panel's full width and the tabs wrap within it. It used to 
 * be flex-basis: 100% on the settle row itself, then briefly an item that grew there, and both of 
 * those were ways of describing a position on a row it no longer sits on. 
 */ 
.tenders__strip { 
    display: flex; 
    flex-wrap: wrap; 
    align-items: center; 
    gap: var(--space-1); 
    min-width: 0; 
} 
 
/* 
 * THE BOXES THE SELECTED TAB OWNS, DIRECTLY UNDER IT AND ALIGNED WITH IT. Their left edge is the 
 * strip's left edge because both are children of the same padded column, which is the whole point 
 * of the panel - a tab and the figure it is taking have to read as one thing. 
 * 
 * Aligned at the top like the settle row itself, so the Amount, Cash given and Txn captions line 
 * up with each other however many of them the method draws. 
 */ 
.tenders__fields { 
    display: flex; 
    flex-wrap: wrap; 
    align-items: flex-start; 
    gap: var(--space-2) var(--space-3); 
    min-width: 0; 
} 
 
/* 
 * AN OUTLINED CHIP, AND THE ONE THAT IS SHOWING IS FILLED - the same treatment .tab wears on every 
 * other tab strip in the application, so a tab is one thing wherever somebody meets it. 
 * 
 * It was an underline before, on the argument that a row of filled buttons would out-shout the 
 * sale being rung up. That argument is answered by only ONE of them being filled: the rest are an 
 * outline on the card's own ground, which is quieter than a button and louder than the bare text 
 * they were, on the row where a cashier has to see at a glance what the sale is being paid with. 
 * 
 * The border is carried by every tab all the time rather than added on selection, which is what 
 * stops the strip moving as the eye follows it - the same reason the old underline was drawn 
 * transparent. And the ink on the filled one is --pos-on-brand rather than a typed white: the 
 * primary is a LIGHT green under [data-theme="dark"], where white would be unreadable. 
 */ 
.tenders__tab { 
    display: inline-flex; 
    align-items: center; 
    gap: var(--space-2); 
    max-width: 100%; 
    padding: var(--space-1) var(--space-3); 
    border: 1px solid var(--pos-primary); 
    border-radius: var(--radius-sm); 
    background: transparent; 
    color: var(--pos-primary); 
    font-family: inherit; 
    font-size: var(--text-sm); 
    font-weight: 600; 
    cursor: pointer; 
    transition: color var(--motion-instant) var(--ease-standard), 
                background var(--motion-instant) var(--ease-standard); 
} 
 
/* Scoped off the selected tab deliberately: :hover carries more specificity than 
   .tenders__tab--on, so a plain :hover rule would wash the fill off the one that is showing. */ 
.tenders__tab:not(.tenders__tab--on):hover { background: var(--pos-primary-soft); } 
 
.tenders__tab--on { 
    background: var(--pos-primary); 
    border-color: var(--pos-primary); 
    color: var(--pos-on-brand); 
} 
 
/* 
 * WHAT THIS METHOD IS TAKING, ON THE TAB ITSELF - and it is what replaces seeing every tender at 
 * once. The old panel stacked a row per method, so a split was legible without touching anything; 
 * a strip shows one body at a time, and without a figure here a cashier would have to click through 
 * four tabs to find out what the sale is being paid with. 
 * 
 * Green rather than the tab's own ink, because it is money that has been committed rather than a 
 * label - and it is the same accent the counter's own Add button wears. 
 */ 
.tenders__tab-figure { 
    font-variant-numeric: tabular-nums; 
    font-weight: 700; 
    color: var(--pos-accent); 
} 
 
/* On the filled tab the figure takes the fill's own ink. The accent is a mid teal-green and it is 
   what a figure on the card's ground should be; on a primary fill it is barely there. */ 
.tenders__tab--on .tenders__tab-figure { color: var(--pos-on-brand); } 
 
/* 
 * A METHOD THAT IS CARRYING MONEY BUT IS NOT THE ONE SHOWING. It used to read as a change of ink, 
 * from the muted label to the full one - which said nothing once every unselected tab became a 
 * primary-inked chip at full strength. A soft fill is what says it now: quieter than the selected 
 * tab's, louder than the empty ones beside it, and it is the same wash the hover uses because it 
 * means the same thing to the eye - this one has something on it. 
 * 
 * Scoped off the selected tab, or a tab that is both would take the soft fill over the solid one. 
 */ 
.tenders__tab--paid:not(.tenders__tab--on) { background: var(--pos-primary-soft); }

/* The control's own boxes, not the sale screen's. They were .sale__money and .sale__txn while the
   counter was the only screen drawing this; a supplier bill reaching into a stylesheet named after
   New Sale for the width of its amount box is a dependency nobody would write on purpose. */
.tenders__amount { width: 110px; }
.tenders__ref { width: 170px; }

/* A form drawn as a fieldset so it can be disabled whole: only the border and padding of the
   element are reset, its layout is the ordinary .form's. */
fieldset.form--readonly { border: 0; margin: 0; padding: 0; min-width: 0; }

/* The tick-box column of a report table the reader picks rows of: as narrow as the box itself. */
.grid__cell--check { width: 1%; white-space: nowrap; }

/*
 * A document's date with its time beside it (DocumentDateField). The date takes the room; the time
 * keeps a fixed width so it never squeezes to two digits. Only drawn when the day is not today or
 * the document carries its own time - otherwise the date stands alone and fills the row as before.
 */
.date-time { display: flex; gap: var(--space-2); min-width: 0; }
.date-time > .field__input:first-child { flex: 1; min-width: 0; }
.date-time__time { flex: 0 0 var(--date-time-width); width: var(--date-time-width); }

/* The paperclip beside a document's number on a list: the document carries proof. */
.proof-mark { color: var(--pos-text-muted); margin-left: var(--space-1); vertical-align: middle; }

/* A report tile that narrows the page when pressed (Item Register's ways in and out). */
.widget--link { cursor: pointer; }
.widget--link:hover { border-color: var(--pos-primary); }

/* ---- A progress bar (the Sync screen) ----------------------------------------------------- */
.progress { height: var(--space-2); background: var(--pos-surface-sunken); border-radius: var(--radius-pill); overflow: hidden; }
.progress__bar { height: 100%; background: var(--pos-accent-bright); border-radius: var(--radius-pill); }
.progress__text { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); color: var(--pos-text-muted); }
