/* Design tokens for the storefront, back office and platform admin.
   Paste this at the top of the one hand-written CSS file in Pos.Server wwwroot.
   Names match docs/design/README.md and src/Pos.Desktop/Styles/Theme.axaml. */

@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/IBMPlexSans-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/IBMPlexSans-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/IBMPlexSans-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/IBMPlexSans-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/IBMPlexMono-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/IBMPlexMono-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  /* Type */
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --text-xs: 0.6875rem;   /* 11 */
  --text-sm: 0.75rem;     /* 12 */
  --text-md: 0.8125rem;   /* 13 */
  --text-base: 0.875rem;  /* 14 */
  --text-lg: 1rem;        /* 16 */
  --text-xl: 1.125rem;    /* 18 */
  --text-2xl: 1.25rem;    /* 20 */
  --text-3xl: 1.625rem;   /* 26 */
  --text-4xl: 1.875rem;   /* 30 */
  --text-5xl: 2.5rem;     /* 40 */
  --tracking-caps: 0.06em;

  /* Colour */
  --ink: #17191C;
  --ink-2: #2B2F35;
  --text-muted: #4A4F57;
  --text-subtle: #5F6670;
  --ground: #F4F2EE;
  --ground-2: #EFEDE8;
  --ground-3: #E9E6E0;
  --surface: #FFFFFF;
  --line: #DAD7D0;
  --line-soft: #EEEBE5;
  --line-strong: #CFCBC3;
  --field-border: #8C877E;
  --accent: #C2410C;
  --accent-hover: #9A3412;
  --accent-soft: #FDEBDD;
  --accent-softer: #FFF6EF;
  --accent-on-dark: #F5A66B;
  --ok: #1F7A3A;
  --ok-strong: #1F6B34;
  --ok-soft: #E3F1E6;
  --warn: #8A5A00;
  --warn-soft: #FBF0D4;
  --info: #1A4E8F;
  --info-soft: #E4EDF8;
  --danger: #B42318;
  --danger-soft: #FDE7E5;
  --dark-text: #F4F2EE;
  --dark-muted: #B9BCC2;
  --dark-surface: #1F2226;
  --dark-line: #2E3137;

  /* Shape and space */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --border: 1px;
  --border-strong: 2px;
  --target: 44px;
  --input-h: 48px;
  --shadow-float: 0 16px 40px rgba(23, 25, 28, 0.22);
}

/* Base, matching the mockups. */
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font-sans); font-size: var(--text-lg); line-height: 1.5; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* The one hand-written stylesheet of the cloud pages, the back office and the storefront; platform admin joins it
   later. The tokens above are docs/design/tokens.css as it stands, and every rule below takes its colours, type,
   spacing and radii from them and writes none in by hand (SPEC 2 Look and type, 8 rule 15). Mobile first: every rule
   is written for a phone, and the media query further down gives the shell room on a desk. Spacing and alignment use
   logical properties (inline-start, inline-end, block), so the layout mirrors under dir="rtl" with no second file.
   SPEC 2 (Web UI row), 5.4, 5.5, 8 rule 10. */

:root {
    color-scheme: light;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* The back office reads at the body size of the README; the storefront keeps the larger body of the base rule. */

body:not(.storefront) {
    font-size: var(--text-base);
}

/* The shell, after the BackOrders mockup: a dark bar with the tenant and the way out; under it the side navigation on
   the second ground and the page. On a phone the navigation stacks above the page, its links wrapping in rows; on a
   desk it stands at the start beside a fluid page, one link to a line. The page in the current section is drawn in
   ink. */

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    min-height: calc(var(--space-12) + var(--space-2));
    padding: var(--space-2) var(--space-4);
    background: var(--ink);
    color: var(--dark-text);
}

.site-header .brand {
    margin-inline-end: auto;
    font-size: var(--text-lg);
    font-weight: 700;
    color: inherit;
    text-decoration: none;
}

.shell {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.shell > nav {
    padding: var(--space-3) var(--space-3);
    border-block-end: thin solid var(--line);
    background: var(--ground-2);
}

.shell > nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
}

.shell > nav a {
    display: block;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: var(--text-base);
    text-decoration: none;
}

.shell > nav a:hover {
    background: var(--ground-3);
    color: var(--ink);
}

.shell > nav a[aria-current="page"] {
    background: var(--ink);
    color: var(--surface);
    font-weight: 600;
}

.shell > main {
    max-width: none;
    margin-inline: 0;
    min-width: 0;
}

/* Signed out, the login stands alone in a narrow column with room above it. */

body:not(.storefront) > main {
    max-width: 28rem;
    padding-block-start: var(--space-12);
}

.site-header form {
    max-width: none;
    margin: 0;
}

main {
    flex: 1;
    width: 100%;
    max-width: 64rem;
    margin-inline: auto;
    padding: var(--space-4);
}

h1 {
    margin-block: var(--space-2) var(--space-4);
    font-size: var(--text-3xl);
    font-weight: 700;
    line-height: 1.2;
}

h2 {
    margin-block: var(--space-6) var(--space-3);
    font-size: var(--text-2xl);
    font-weight: 600;
    line-height: 1.25;
}

p {
    margin-block: 0 var(--space-3);
}

/* Focus is visible everywhere; the owner may well be on a keyboard. */

:focus-visible {
    outline: medium solid var(--accent);
    outline-offset: calc(var(--space-1) / 2);
}

.site-header :focus-visible {
    outline-color: var(--accent-on-dark);
}

/* Forms: one field per line, the label above its field, the button under the last one. */

form {
    display: grid;
    gap: var(--space-2);
    max-width: 28rem;
}

label {
    color: var(--text-muted);
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    min-height: var(--input-h);
    padding: var(--space-2) var(--space-3);
    border: thin solid var(--field-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

/* A checkbox sits on one line with its words, the box first in the reading direction. */

label.check {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    color: var(--ink);
}

input[type="checkbox"] {
    margin: 0;
    flex: none;
    min-height: 0;
    inline-size: var(--space-5);
    block-size: var(--space-5);
    accent-color: var(--accent);
}

/* A group of fields inside a form, the attributes of a product, on its own surface; each row is a pair, the name and
   the value side by side. */

fieldset {
    display: grid;
    gap: var(--space-2);
    min-inline-size: 0;
    margin: 0;
    padding: var(--space-4);
    border: thin solid var(--line);
    border-radius: var(--radius-md);
}

legend {
    padding-inline: var(--space-1);
    color: var(--text-muted);
    font-weight: 600;
}

.pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

/* A button is the accent, the one main action; a quiet button is the secondary one beside it. */

button,
.button {
    display: inline-block;
    justify-self: start;
    min-height: var(--target);
    padding: var(--space-2) var(--space-4);
    border: thin solid var(--accent);
    border-radius: var(--radius-md);
    background: var(--accent);
    color: var(--surface);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button:hover {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
    color: var(--surface);
}

.hint {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

button.quiet {
    border-color: var(--line-strong);
    background: transparent;
    color: inherit;
    font-weight: 500;
}

button.quiet:hover {
    border-color: var(--ink);
    background: var(--ground-3);
    color: var(--ink);
}

/* The way out on the dark bar reads as a link in the accent for dark backgrounds, as in the mockup. */

.site-header button.quiet {
    padding-inline: var(--space-2);
    border-color: transparent;
    color: var(--accent-on-dark);
    font-size: var(--text-base);
}

.site-header button.quiet:hover {
    border-color: transparent;
    background: var(--ink-2);
    color: var(--accent-on-dark);
    text-decoration: underline;
}

[role="alert"] {
    padding: var(--space-2) var(--space-3);
    border-inline-start: var(--space-1) solid var(--danger);
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
}

/* Tables scroll sideways inside their own box on a phone rather than wrap into noise. */

.table {
    overflow-x: auto;
    border: thin solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th,
td {
    padding: var(--space-3) var(--space-3);
    border-block-end: thin solid var(--line-soft);
    text-align: start;
}

th {
    border-block-end-color: var(--line);
    color: var(--text-subtle);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-block-end: none;
}

/* Money and quantities line up in Mono, at the end of the column. */

th.number,
td.number {
    text-align: end;
}

td.number {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* A tree in a table: a row's name is set in from the edge by one empty indent per level under the top. */

td.tree-name .indent {
    display: inline-block;
    inline-size: var(--space-5);
}

/* Figures, codes and days stay on one line; a wide table scrolls in its box instead of breaking them. */

td.number,
td.code,
td.date {
    white-space: nowrap;
}

/* The search above a list: the label over the box, the button at the end of the box on the same line. */

form.search {
    grid-template-columns: 1fr auto;
    align-items: end;
    margin-block-end: var(--space-4);
}

form.search label {
    grid-column: 1 / -1;
}

form.search button {
    min-height: var(--input-h);
}

/* The pager under a list: the way back at the start, where the list stands in the middle, the way on at the end. */

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    margin-block-start: var(--space-3);
    color: var(--text-muted);
    font-size: var(--text-md);
}

/* Money, quantities and phone numbers are typed in Mono, as they are read. */

input[type="number"],
input[type="tel"] {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* The way back out of a form beside its button is a link the size of a touch target. */

body:not(.storefront) form > button + a {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    min-height: var(--target);
}

/* A card holds one form or one list on its own surface; a heading at its top starts at its edge. */

.card > h2:first-child {
    margin-block-start: 0;
}

/* The way to a new record sits under the title of its list, the list under it with room between. */

h1 + p:has(> .button) {
    margin-block-end: var(--space-5);
}

.card {
    padding: var(--space-4);
    border: thin solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

/* Two cards on one page, the form of a product and the list of its variants, keep a space between them, and so
   does a card under a list, the dispatch store under the stores. */

.card + .card,
.table + .card {
    margin-block-start: var(--space-4);
}

/* A form under a list or another form inside a card, the selling units and the barcodes of a product, keeps a
   space above it. */

.card .table + form,
.card p + form,
.card form + form {
    margin-block-start: var(--space-4);
}

/* A barcode is read digit by digit, and a day is read against the one above it. */

td.code,
td.date {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* The sections of the settings page: one card each, the link first and what it holds under it. */

ul.sections {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

ul.sections li {
    padding: var(--space-4);
    border: thin solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

ul.sections a {
    font-weight: 600;
}

ul.sections .hint {
    margin-block-start: var(--space-1);
}

/* The storefront, after the StoreHome mockup of docs/design, for a phone in a hand: the dark bar with the shop's name
   and its three links, then one column that a desk centres, the header's contents and the footer lined up with it.
   The categories are tiles two to a row and four on a desk, the products one surface of rows with their details, the
   section headings small capitals, the trail above a category or product page one row of links, and the footer the
   shop's name and address on one quiet line. SPEC 5.4, 8 rule 15. */

body.storefront main {
    max-width: 48rem;
}

body.storefront .site-header {
    flex-wrap: nowrap;
    gap: var(--space-1);
    padding-block: 0;
    padding-inline: max(var(--space-4), calc((100% - 48rem) / 2 + var(--space-4))) max(var(--space-2), calc((100% - 48rem) / 2 + var(--space-2)));
}

body.storefront .site-header .brand {
    min-width: 0;
    overflow-wrap: anywhere;
}

.site-header .search-link,
.site-header .cart-link,
.site-header .account-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--target);
    min-height: var(--target);
    padding-inline: var(--space-2);
    border-radius: var(--radius-sm);
    color: inherit;
    font-size: var(--text-base);
    font-weight: 500;
    text-decoration: none;
}

.site-header .search-link:hover,
.site-header .cart-link:hover,
.site-header .account-link:hover {
    background: var(--ink-2);
    color: var(--accent-on-dark);
}

body.storefront main h2 {
    margin-block: var(--space-6) var(--space-3);
    color: var(--text-muted);
    font-size: var(--text-md);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* What an empty search or one that found nothing says is quiet. */

#results > p {
    color: var(--text-muted);
}

ul.categories {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

ul.categories a {
    display: block;
    min-height: calc(var(--space-12) + var(--space-6));
    padding: var(--space-3);
    border: thin solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}

ul.categories a:hover,
ul.categories a:focus-visible {
    border-color: var(--ink);
    color: var(--ink);
}

ul.products {
    display: grid;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: thin solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    list-style: none;
}

ul.products li {
    padding: var(--space-3) var(--space-4);
}

ul.products li + li {
    border-block-start: thin solid var(--line-soft);
}

.product-name {
    margin: 0;
    font-weight: 600;
}

.product-name a {
    color: var(--ink);
    text-decoration: none;
}

.product-name a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

p.offer {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-2);
    align-items: baseline;
    margin: var(--space-1) 0 0;
}

p.offer .price {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

p.offer .includes-gst {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* The state under the price, always in words and in the colour of its state: green in stock, blue confirmed after
   ordering, subdued when it cannot be ordered. */

p.offer .availability {
    flex-basis: 100%;
    color: var(--text-subtle);
    font-size: var(--text-md);
}

p.offer.in-stock .availability {
    color: var(--ok);
    font-weight: 600;
}

p.offer.on-request .availability {
    color: var(--info);
    font-weight: 600;
}

/* The search on the storefront fills the column: the box drawn in ink, the accent button beside it at the same
   height. */

body.storefront form.search {
    max-width: none;
}

body.storefront form.search input {
    border: calc(var(--space-1) / 2) solid var(--ink);
    border-radius: var(--radius-md);
}

/* The product page, after the StoreProduct mockup: the product on one surface, its price the largest figure, its state
   a badge in words and the colour of the state, the quantity drawn in ink beside the one accent button, and its
   details as rows of a name and a value under a line. SPEC 5.4, 8 rule 15. */

section.product-summary {
    padding: var(--space-5) var(--space-4);
    border: thin solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

section.product-summary h1 {
    margin: 0;
}

section.product-summary > p.offer {
    gap: 0 var(--space-2);
    margin-block-start: var(--space-2);
}

section.product-summary > p.offer .price {
    font-size: var(--text-4xl);
}

section.product-summary > p.offer .includes-gst {
    font-size: var(--text-md);
}

/* The badge takes a line of its own under the price without stretching across it: an empty item of full width breaks
   the line before it. */

section.product-summary > p.offer::after {
    content: "";
    flex-basis: 100%;
    order: 1;
}

section.product-summary > p.offer .availability {
    flex-basis: auto;
    order: 2;
    margin-block-start: var(--space-2);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--ground-3);
    color: var(--text-muted);
    font-weight: 600;
}

section.product-summary > p.offer.in-stock .availability {
    background: var(--ok-soft);
    color: var(--ok-strong);
}

section.product-summary > p.offer.on-request .availability {
    background: var(--info-soft);
    color: var(--info);
}

/* The cart: the form that adds a product, a quantity box and its button side by side under the label, and each line of
   the cart with what it comes to at the end of its name, its quantity and the way to remove it on one row under. */

form.add-to-cart,
form.cart-quantity {
    grid-template-columns: minmax(0, 7rem) minmax(0, 1fr);
    align-items: end;
    max-width: none;
    margin-block-start: var(--space-3);
}

form.add-to-cart label,
form.cart-quantity label {
    grid-column: 1 / -1;
    font-size: var(--text-md);
}

form.add-to-cart input,
form.cart-quantity input {
    border: calc(var(--space-1) / 2) solid var(--ink);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-xl);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: center;
}

form.add-to-cart button,
form.cart-quantity button {
    min-height: var(--input-h);
}

section.product-summary form.add-to-cart {
    margin-block-start: var(--space-4);
}

section.product-summary form.add-to-cart button {
    justify-self: stretch;
    min-height: calc(var(--input-h) + var(--space-1));
}

/* Beside the one accent button of a page, the buttons of the variants and of the cart's lines are drawn in ink. */

ul.variants form.add-to-cart,
form.cart-quantity {
    grid-template-columns: minmax(0, 7rem) auto;
    justify-content: start;
}

ul.variants form.add-to-cart button,
form.cart-quantity button {
    border: calc(var(--space-1) / 2) solid var(--ink);
    background: var(--surface);
    color: var(--ink);
}

ul.variants form.add-to-cart button:hover,
form.cart-quantity button:hover {
    border-color: var(--ink);
    background: var(--ground-3);
    color: var(--ink);
}

ul.cart-lines li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 var(--space-3);
}

ul.cart-lines .product-name {
    grid-column: 1;
    grid-row: 1;
}

ul.cart-lines p.line-total {
    grid-column: 2;
    grid-row: 1;
    text-align: end;
}

ul.cart-lines p.offer {
    grid-column: 1 / -1;
    font-size: var(--text-base);
}

ul.cart-lines form.cart-quantity {
    grid-column: 1;
}

ul.cart-lines form.cart-remove {
    grid-column: 2;
    align-self: end;
    justify-self: end;
}

form.cart-remove {
    margin-block-start: var(--space-2);
}

p.line-total {
    margin: var(--space-2) 0 0;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

ul.cart-lines p.line-total {
    margin: 0;
}

/* Under the lines the total on a surface of its own, the figure large and in Mono at the end, what it holds and what
   checkout adds quiet under it, and the way to checkout the one accent button of the page, across the surface. */

div.cart-summary {
    margin-block-start: var(--space-4);
    padding: var(--space-4);
    border: thin solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

p.cart-total {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0 var(--space-3);
    margin: 0;
    font-weight: 700;
}

p.cart-total .price {
    font-family: var(--font-mono);
    font-size: var(--text-3xl);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

p.cart-gst,
p.cart-delivery {
    margin-block: var(--space-1) 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* Checkout, the placed page, the order status page and the account pages, after the StoreCheckout mockup: the forms
   fill the column with the label over each field, the ways of paying are cards with the chosen one in the accent, the
   lines and the details are each a surface of rows, the total stands on a dark panel with the figure large in Mono, and
   the one accent button of the page runs across the column under it. Every other button is quiet. SPEC 5.4, 8
   rule 15. */

form.checkout-details,
form.checkout-place,
form.checkout-edit,
form.account-sign-in,
form.account-code {
    gap: var(--space-2);
    max-width: none;
}

form.checkout-details label:not(.check),
form.account-sign-in label,
form.account-code label {
    margin-block-start: var(--space-2);
    color: var(--ink);
    font-size: var(--text-base);
}

form.checkout-details > button,
form.checkout-place > button,
form.account-sign-in > button,
form.account-code > button {
    justify-self: stretch;
    min-height: calc(var(--input-h) + var(--space-2));
    margin-block-start: var(--space-3);
    font-size: var(--text-lg);
}

form.checkout-edit > button {
    justify-self: stretch;
}

/* The six digits of a code are read and typed one by one, so they stand large in Mono with room between them. */

form.account-code input {
    font-family: var(--font-mono);
    font-size: var(--text-xl);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: 0.3em;
}

/* The ways of paying: a card each, the radio first, the chosen card drawn in the accent. */

fieldset.options {
    gap: var(--space-2);
    margin-block-start: var(--space-3);
    padding: 0;
    border: none;
}

fieldset.options legend {
    margin-block-end: var(--space-2);
    padding: 0;
    color: var(--ink);
    font-size: var(--text-base);
    font-weight: 600;
}

fieldset.options label.check {
    align-items: center;
    gap: var(--space-3);
    min-height: calc(var(--input-h) + var(--space-1));
    padding: var(--space-2) var(--space-3);
    border: thin solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    font-weight: 400;
    cursor: pointer;
}

fieldset.options label.check:has(input:checked) {
    border-color: var(--accent);
    outline: thin solid var(--accent);
    background: var(--accent-softer);
}

input[type="radio"] {
    flex: none;
    width: auto;
    min-height: 0;
    margin: 0;
    inline-size: var(--space-5);
    block-size: var(--space-5);
    accent-color: var(--accent);
}

/* The lines of an order on one surface, each name with what it comes to at the end in Mono. */

ul.checkout-lines {
    margin: 0 0 var(--space-4);
    padding: var(--space-1) var(--space-4);
    border: thin solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    font-size: var(--text-base);
    list-style: none;
}

ul.checkout-lines li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0 var(--space-3);
    padding-block: var(--space-2);
}

ul.checkout-lines li + li {
    border-block-start: thin solid var(--line-soft);
}

ul.checkout-lines.left-out {
    color: var(--text-muted);
}

span.line-total {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

span.line-rejected {
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 600;
}

p.checkout-goods {
    padding-inline: var(--space-4);
}

p.checkout-goods .price {
    font-size: var(--text-xl);
}

p.checkout-back {
    margin-block: var(--space-2) var(--space-4);
    padding-inline: var(--space-4);
    font-size: var(--text-md);
}

/* The details the shopper gave, as rows of a word and its value on one surface. */

dl.checkout-review {
    margin: 0 0 var(--space-4);
    padding: var(--space-2) var(--space-4);
    border: thin solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    font-size: var(--text-base);
}

dl.checkout-review div {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0 var(--space-3);
    padding-block: var(--space-1);
}

dl.checkout-review dt {
    color: var(--text-muted);
}

dl.checkout-review dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* The total on a dark panel: the goods and the delivery quiet, the total under a line, large and in Mono. */

div.order-total {
    margin-block: var(--space-4);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    background: var(--ink);
    color: var(--dark-text);
}

div.order-total dl.checkout-review {
    margin: 0 0 var(--space-3);
    padding: 0 0 var(--space-3);
    border: none;
    border-block-end: thin solid var(--dark-line);
    border-radius: 0;
    background: none;
}

div.order-total dl.checkout-review dt {
    color: var(--dark-muted);
}

div.order-total dl.checkout-review dd {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

div.order-total p.cart-gst {
    color: var(--dark-muted);
}

p.checkout-link {
    margin-block: var(--space-4) 0;
    font-weight: 600;
}

/* The way on, to checkout from the cart and to the order from the placed page, is the one accent button of the page. */

div.cart-summary p.checkout-link a,
div.order-total + p.checkout-link a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(var(--input-h) + var(--space-2));
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--accent);
    color: var(--surface);
    font-weight: 700;
    text-decoration: none;
}

div.cart-summary p.checkout-link a:hover,
div.order-total + p.checkout-link a:hover {
    background: var(--accent-hover);
    color: var(--surface);
}

/* Under the review the note that nothing is paid yet, then the place button across the column and the way back to the
   details under it. */

#checkout > p.cart-delivery {
    margin-block-start: var(--space-4);
    font-size: var(--text-md);
}

form.checkout-place,
form.checkout-edit {
    margin-block-start: var(--space-2);
}

/* What an order is now: its state in words on a surface of its own, what that means quiet under it. */

section.order-summary {
    margin-block-end: var(--space-4);
    padding: var(--space-4);
    border: thin solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

section.order-summary p {
    margin-block: 0;
    color: var(--text-muted);
    font-size: var(--text-base);
}

section.order-summary p + p {
    margin-block-start: var(--space-2);
}

section.order-summary p.order-state {
    color: var(--ink);
    font-size: var(--text-xl);
    font-weight: 600;
}

/* The answer a partly confirmed order asks for and the bank transfer to make: a card each, its heading at the top. */

section.order-approval,
section.bank-transfer {
    margin-block-end: var(--space-4);
    font-size: var(--text-base);
}

body.storefront main section.order-approval h2,
body.storefront main section.bank-transfer h2 {
    margin-block-start: 0;
}

ul.rejected-lines {
    margin: 0 0 var(--space-3);
    padding-inline-start: var(--space-5);
}

p.bank-details {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--ground-2);
    white-space: pre-line;
}

strong.order-reference {
    font-family: var(--font-mono);
    font-size: var(--text-xl);
    font-variant-numeric: tabular-nums;
}

div.order-answers {
    display: grid;
    gap: var(--space-2);
}

div.order-answers form {
    max-width: none;
    margin: 0;
}

div.order-answers button {
    justify-self: stretch;
    min-height: calc(var(--input-h) + var(--space-1));
}

/* Signed in: who it is and the way out on one row, the orders in a table under. */

form.account-sign-out {
    margin-block-end: var(--space-4);
}

table.account-orders td.code a {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* The details of a product as rows of a name and its value, the names in one column. */

dl.attributes {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-3) 0 0;
    font-size: var(--text-base);
}

dl.attributes div {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 5fr);
    gap: var(--space-3);
}

section.product-summary dl.attributes {
    margin-block-start: var(--space-5);
    padding-block-start: var(--space-4);
    border-block-start: thin solid var(--line);
}

dl.attributes dt {
    color: var(--text-muted);
}

dl.attributes dd {
    margin: 0;
}

nav.trail ol {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin: 0 0 var(--space-2);
    padding: 0;
    list-style: none;
    color: var(--text-muted);
    font-size: var(--text-md);
}

nav.trail li + li::before {
    content: "\203A";
    padding-inline-end: var(--space-1);
}

.site-footer {
    padding: var(--space-3) var(--space-4) var(--space-4);
    color: var(--text-muted);
    font-size: var(--text-sm);
    text-align: center;
}

.site-footer p {
    margin: 0;
}

body.storefront .site-footer {
    width: 100%;
    max-width: 48rem;
    margin-inline: auto;
    text-align: start;
}

body.storefront .site-footer p {
    display: inline;
}

body.storefront .site-footer p + p::before {
    content: " \00B7  ";
}

/* htmx: the element that made a request fades until the answer lands. */

.htmx-request {
    opacity: 0.6;
    transition: opacity 100ms;
}

/* On a desk the shell gets room and the back office's side navigation stands beside the page. */

@media (min-width: 48rem) {
    .site-header {
        padding-inline: var(--space-6);
    }

    main {
        padding: var(--space-8);
    }

    .shell {
        flex-direction: row;
    }

    .shell > nav {
        flex: 0 0 14rem;
        padding: var(--space-5) var(--space-3);
        border-block-end: none;
        border-inline-end: thin solid var(--line);
    }

    .shell > nav ul {
        flex-direction: column;
        gap: calc(var(--space-1) / 2);
    }

    .shell > main {
        flex: 1;
        padding-block: var(--space-6) var(--space-12);
    }

    ul.categories {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    body.storefront .site-header {
        padding-inline: max(var(--space-6), calc((100% - 48rem) / 2 + var(--space-8))) max(var(--space-4), calc((100% - 48rem) / 2 + var(--space-6)));
    }

    body.storefront .site-footer {
        padding-inline: var(--space-8);
    }
}

/* The online orders, after the BackOrders and BackOrder mockups. The list: the states as round pills with their counts,
   wrapping on a phone, the one being read in the accent; the table on one line a row, the reference and the total in
   Mono and heavier, scrolling in its box. SPEC 5.5, 8 rule 15. */

.order-states ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0 0 var(--space-5);
    padding: 0;
    list-style: none;
}

.order-states a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--target);
    padding: 0 var(--space-4);
    border: thin solid var(--line);
    border-radius: calc(var(--target) / 2);
    background: var(--surface);
    color: var(--ink);
    font-size: var(--text-base);
    font-weight: 500;
    text-decoration: none;
}

.order-states a:hover {
    border-color: var(--ink);
    color: var(--ink);
}

.order-states a[aria-current="page"] {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--surface);
    font-weight: 600;
}

table.orders td {
    white-space: nowrap;
}

table.orders td.code a,
table.orders td.number {
    font-weight: 600;
}

/* One order: the way back above the title; the title with the state as a badge and when it was placed; then the
   lines, each a card with its decision as a badge and, in Sourcing, the three ways to decide it side by side where
   the width allows; beside the lines on a desk and under them on a phone, who it goes to, what it comes to and the
   steps that can be taken now, the one main step in the accent. */

p.order-back {
    margin-block-end: var(--space-2);
    font-size: var(--text-base);
}

.order-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    margin-block-end: var(--space-5);
}

.order-head h1 {
    margin: 0;
}

.order-head dl,
.order-head dl div {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    margin: 0;
}

.order-head dl div {
    gap: var(--space-2);
}

.order-head dt,
dl.order-facts dt {
    color: var(--text-subtle);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.order-head dd {
    margin: 0;
    color: var(--text-muted);
}

.order-head .stage dd {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-size: var(--text-md);
    font-weight: 700;
}

.order-head .code dd,
dl.order-facts .code dd,
dl.order-sum dd {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.order-desk {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-5);
}

.order-lines {
    display: grid;
    gap: var(--space-3);
    flex: 999 1 32rem;
    min-width: 0;
}

.order-lines > h2,
.order-messages > h2 {
    margin: 0;
    color: var(--text-subtle);
    font-size: var(--text-xs);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* The messages written about the order, under the lines and the side, oldest first: whom each went to and whether it
   is sent, waiting or failed, in words and colour, so staff can phone a customer a message did not reach. */

.order-messages {
    display: grid;
    gap: var(--space-3);
    margin-block-start: var(--space-6);
}

.order-messages > p {
    margin: 0;
}

table.messages td.text {
    min-inline-size: 18rem;
    overflow-wrap: anywhere;
}

span.message-status {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-md);
    font-weight: 600;
    white-space: nowrap;
}

span.message-status.sent {
    background: var(--ok-soft);
    color: var(--ok-strong);
}

span.message-status.waiting {
    background: var(--warn-soft);
    color: var(--warn);
}

span.message-status.failed {
    background: var(--danger-soft);
    color: var(--danger);
}

.order-side {
    display: grid;
    gap: var(--space-3);
    flex: 1 1 18rem;
    min-width: 0;
}

.order-lines .card + .card,
.order-side .card + .card {
    margin-block-start: 0;
}

.order-line h3 {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 600;
}

.order-line h3 a {
    color: var(--ink);
    text-decoration: none;
}

.order-line h3 a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

p.line-amount {
    margin-block: var(--space-1) var(--space-3);
    color: var(--text-muted);
}

p.line-decision {
    display: inline-block;
    margin: 0;
    font-size: var(--text-md);
    font-weight: 600;
}

p.line-decision.confirmed,
p.line-decision.rejected {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
}

p.line-decision.confirmed {
    background: var(--ok-soft);
    color: var(--ok-strong);
}

p.line-decision.rejected {
    background: var(--danger-soft);
    color: var(--danger);
}

p.line-decision.pending {
    color: var(--text-muted);
}

.line-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
    gap: var(--space-3);
    margin-block-start: var(--space-4);
}

.choice {
    padding: var(--space-3) var(--space-4);
    border: thin solid var(--line);
    border-radius: var(--radius-md);
}

.choice:focus-within {
    border-color: var(--accent);
    background: var(--accent-softer);
}

.choice .hint {
    font-size: var(--text-md);
}

/* A step is a form of its own: a line's choice stacks its field under its title, the button last; a decision on a
   line is saved with the dark button of the mockup, so the accent stays for the order's own step. */

form.order-step {
    display: grid;
    gap: var(--space-2);
    max-width: none;
    margin: 0;
}

.choice form.order-step label:not(.cost) {
    color: var(--ink);
    font-size: var(--text-base);
}

.choice form.order-step label.cost {
    font-size: var(--text-md);
}

.order-line form.order-step button:not(.quiet) {
    border-color: var(--ink);
    background: var(--ink);
}

.order-line form.order-step button:not(.quiet):hover {
    border-color: var(--ink-2);
    background: var(--ink-2);
}

.order-side form.order-step button {
    justify-self: stretch;
    min-height: var(--input-h);
}

dl.order-facts,
dl.order-sum {
    display: grid;
    gap: var(--space-3);
    margin: 0;
}

dl.order-facts dd {
    margin: var(--space-1) 0 0;
    overflow-wrap: anywhere;
}

dl.order-sum {
    gap: var(--space-2);
}

dl.order-sum div {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
}

dl.order-sum dt {
    color: var(--text-muted);
}

dl.order-sum dd {
    margin: 0;
}

dl.order-sum .total {
    margin-block-start: var(--space-1);
    padding-block-start: var(--space-3);
    border-block-start: thin solid var(--line-soft);
    font-size: var(--text-lg);
    font-weight: 700;
}

dl.order-sum .total dt {
    color: var(--ink);
}

p.order-waits {
    margin: 0;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--warn-soft);
    color: var(--warn);
    font-size: var(--text-base);
}

.order-cancel h2 {
    margin-block: 0 var(--space-3);
    font-size: var(--text-lg);
}
