/*
 * Shared visual language for every server-rendered page.
 *
 * To retheme the application, update the custom properties in the theme
 * section below. Layouts and components must use these properties rather than
 * adding page-specific colour, spacing, radius, or shadow values. The class
 * names below are deliberately small reusable building blocks; the style guide
 * in this folder's README explains when to use each one. Page cards share one
 * content width; narrow layouts stack row details before offering row actions.
 */

/* Theme: the single source of truth for the application's visual decisions. */
:root {
    color-scheme: light;
    --color-page-background: #f4f5f7;
    --color-surface: #ffffff;
    --color-text: #202124;
    --color-text-muted: #555d69;
    --color-text-strong: #303641;
    --color-border: #d8dce1;
    --color-border-strong: #707988;
    --color-brand: #b4232d;
    --color-brand-pressed: #8d1721;
    --color-focus: #155eef;
    --color-error: #a01820;
    --color-success: #147a42;
    --color-success-surface: #ecfdf3;
    --color-success-border: #abefc6;
    --color-button-secondary-border: #707988;
    --font-family: Arial, Helvetica, sans-serif;
    --font-family-code: Consolas, "Courier New", monospace;
    --radius-control: 0.625rem;
    --radius-card: 1rem;
    --shadow-card: 0 0.25rem 1rem rgb(24 31 43 / 6%);
    --space-1: 0.375rem;
    --space-2: 0.75rem;
    --space-3: 1.25rem;
    --space-4: 1.75rem;
    --space-5: 2.5rem;
    --control-min-height: 3.25rem;
    --content-max-width: 56rem;
}

* {
    box-sizing: border-box;
}

/* Component display rules must never reveal content explicitly hidden by markup or a script. */
[hidden] {
    display: none !important;
}

body {
    /* Let the page fill spare height while reserving normal document space for the version footer. */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    min-width: 320px;
    margin: 0;
    background: var(--color-page-background);
    color: var(--color-text);
    font-family: var(--font-family);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

button,
input,
select {
    font: inherit;
}

/* Pages fill the space above the footer and grow naturally when their content needs scrolling. */
.page-shell,
.landing-page {
    flex: 1 0 auto;
    padding: var(--space-2);
}

/* The shared release label stays below content so it cannot cover scanner controls. */
.app-footer {
    padding: var(--space-2);
    color: var(--color-text-muted);
    font-size: 0.875rem;
    text-align: center;
}

.page-shell--centred {
    display: grid;
    place-items: center;
}

.landing-page {
    display: grid;
    grid-template-rows: auto auto;
    gap: var(--space-4);
    align-content: start;
}

/* Surfaces are the shared card treatment used for grouped page content. */
.surface-card {
    min-width: 0;
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.surface-card--narrow {
    width: min(100%, 29rem);
}

/* Branding can be presented as a standalone mark or a compact header lockup. */
.product-mark {
    display: grid;
    width: 3rem;
    height: 3rem;
    margin-bottom: var(--space-3);
    border-radius: 0.75rem;
    background: var(--color-brand);
    color: var(--color-surface);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    place-items: center;
}

.product-mark--compact {
    width: 2.25rem;
    height: 2.25rem;
    margin: 0;
    border-radius: var(--radius-control);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.brand-lockup {
    display: inline-flex;
    gap: var(--space-2);
    align-items: center;
    color: var(--color-text-strong);
    font-weight: 700;
    min-width: 0;
    flex: 1 1 12rem;
}

.eyebrow {
    margin: 0 0 var(--space-1);
    color: var(--color-brand);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(1.5rem, 6vw, 2rem);
    line-height: 1.2;
}

h2 {
    margin-bottom: var(--space-1);
    font-size: 1.125rem;
    line-height: 1.25;
}

.intro {
    margin: var(--space-2) 0 var(--space-4);
    color: var(--color-text-muted);
    line-height: 1.5;
}

.page-introduction > p:not(.eyebrow),
.function-card p,
.review-list-heading p:not(.eyebrow) {
    margin: var(--space-2) 0 0;
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* Form elements use the same accessible dimensions and error treatment on every page. */
.form-stack {
    display: grid;
    gap: var(--space-3);
}

.field-group {
    display: grid;
    gap: var(--space-1);
}

.field-hint {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    line-height: 1.4;
}

label {
    color: var(--color-text-strong);
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-width: 0;
    min-height: var(--control-min-height);
    padding: var(--space-2) 0.875rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-control);
    background: var(--color-surface);
    color: var(--color-text);
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 0.2rem solid var(--color-focus);
    outline-offset: 0.15rem;
}

.button {
    display: inline-grid;
    min-width: 0;
    min-height: var(--control-min-height);
    padding: var(--space-2) 1rem;
    border-radius: var(--radius-control);
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    place-items: center;
    line-height: 1.25;
}

.button--primary {
    border: 1px solid var(--color-brand-pressed);
    background: var(--color-brand);
    color: var(--color-surface);
}

.button--primary:active {
    background: var(--color-brand-pressed);
}

.button--secondary {
    border: 1px solid var(--color-button-secondary-border);
    background: var(--color-surface);
    color: var(--color-text);
}

.button--danger {
    border: 1px solid var(--color-error);
    background: var(--color-surface);
    color: var(--color-error);
}

.button--danger:active {
    background: var(--color-error);
    color: var(--color-surface);
}

.button:disabled,
.button--disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.validation-summary,
.field-error {
    color: var(--color-error);
    font-weight: 600;
}

/* A server-side field error gets the same visible boundary on every form. */
.input-validation-error {
    border-color: var(--color-error);
}

.validation-summary:empty,
.validation-summary-valid,
.field-error:empty {
    display: none;
}

.validation-summary ul {
    margin: 0;
    padding-left: var(--space-3);
}

/* All authenticated pages align their header and cards to the same content column. */
.app-header,
.app-content {
    width: min(100%, var(--content-max-width));
    margin: 0 auto;
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    justify-content: space-between;
}

.app-header .button {
    min-height: 2.75rem;
}

.app-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
    max-width: 100%;
}

.app-actions .button {
    white-space: nowrap;
}

.app-content {
    display: grid;
    gap: var(--space-4);
    align-content: start;
}

.page-introduction {
    max-width: 38rem;
}

/* The home function menu lists only pages that have an implemented, defined responsibility. */
.function-menu-section {
    display: grid;
    gap: var(--space-3);
}

.function-card h2,
.function-card p {
    margin-bottom: 0;
}

.function-menu {
    display: grid;
    gap: var(--space-3);
}

.function-card {
    display: grid;
    gap: var(--space-3);
}

.function-card h2 {
    color: var(--color-text-strong);
    font-size: 1.125rem;
    line-height: 1.25;
}

.function-card .button {
    justify-self: start;
}

/* The scan page presents a temporary browser-session collection while each distinct barcode is validated. */
.scan-card {
    display: grid;
    gap: var(--space-3);
}

/* The selected workflow location is a compact context card with an explicit return path before scanning begins. */
.scan-location-card {
    display: grid;
    gap: var(--space-3);
}

.scan-location-card h2,
.scan-location-card p {
    margin-bottom: 0;
}

.scan-location-card p:not(.eyebrow) {
    margin-top: var(--space-1);
    color: var(--color-text-muted);
    line-height: 1.5;
}

.scan-location-card .button {
    justify-self: start;
}

.scan-form {
    max-width: 30rem;
}

/* The scanner's real text target stays focusable for keyboard-wedge input without exposing a clickable field. */
.visually-hidden,
.scan-capture-input {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    pointer-events: none;
}

.scan-feedback {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: var(--space-3);
    border: 1px solid var(--color-success-border);
    border-radius: var(--radius-control);
    background: var(--color-success-surface);
}

.scan-feedback h2,
.scan-feedback p {
    margin: 0;
}

.scan-feedback .button {
    justify-self: start;
}

.scan-list-card {
    display: grid;
    gap: var(--space-3);
}

.scan-list-heading {
    display: grid;
    gap: var(--space-2);
}

.scan-list-heading h2,
.scan-list-heading p,
.scan-item-identity p {
    margin-bottom: 0;
}

.scan-list-summary-actions {
    display: grid;
    gap: var(--space-2);
    align-items: center;
}

.scan-total {
    color: var(--color-text-strong);
    font-size: 1.25rem;
}

.scan-total strong {
    font-size: 1.5rem;
}

.scan-empty-state {
    margin: 0;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.scan-list {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.scan-list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
    align-items: center;
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background: var(--color-page-background);
}

.scan-list-item > form {
    justify-self: end;
}

.scan-item-identity {
    display: grid;
    gap: var(--space-1);
}

.scan-barcode {
    color: var(--color-text-strong);
    font-family: var(--font-family-code);
    font-size: 1.25rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

/* Configured display fields stay directly below the barcode and wrap rather than clipping long descriptions. */
.scan-item-details {
    display: grid;
    gap: var(--space-1);
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    line-height: 1.35;
}

.scan-item-details > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
}

.scan-item-details dt {
    color: var(--color-text-strong);
    font-weight: 700;
}

.scan-item-details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* Keeps the Shape ID visible when the same barcode is validated at more than one location. */
.scan-item-location {
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    font-weight: 700;
}

.scan-item-count {
    color: var(--color-text-muted);
    font-size: 1rem;
    font-weight: 700;
}

.scan-item-lookup-status {
    color: var(--color-text-muted);
    line-height: 1.4;
    font-size: 0.875rem;
}

.scan-item-lookup-status--invalid,
.review-submit-status--invalid {
    color: var(--color-error);
    font-weight: 700;
}

.scan-sync-status {
    margin: 0;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.scan-sync-status--error {
    color: var(--color-error);
    font-weight: 700;
}

/* The editor is one reusable popup rather than a full count form in each active scan row. */
.scan-count-open {
    overflow: hidden;
}

.scan-count-dialog {
    position: fixed;
    z-index: 10;
    inset: 0;
    display: grid;
    padding: var(--space-3);
    background: rgb(32 33 36 / 55%);
    place-items: center;
}

.scan-count-dialog-panel {
    width: min(100%, 30rem);
    min-width: 0;
    max-height: calc(100vh - var(--space-3) - var(--space-3));
    max-height: calc(100dvh - var(--space-3) - var(--space-3));
    overflow-y: auto;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-card);
}

.scan-count-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
    padding: var(--space-3);
}

.scan-count-form h2,
.scan-count-form p {
    margin-bottom: 0;
}

.scan-count-dialog-barcode {
    margin-top: var(--space-1);
    color: var(--color-text-strong);
    font-family: var(--font-family-code);
    font-size: 1.125rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.scan-count-stepper {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    align-items: center;
}

.scan-count-stepper .button {
    min-width: 0;
    padding-right: var(--space-2);
    padding-left: var(--space-2);
    font-size: 1.5rem;
}

.scan-count-stepper input {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
    text-align: center;
}

.scan-count-dialog-actions {
    display: grid;
    gap: var(--space-2);
}

.scan-count-dialog-confirmation {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
}

.scan-count-dialog-actions .button {
    width: 100%;
}

/* The server-rendered edit page reuses scan controls and provides a dependable path on feature-limited browsers. */
.scan-edit-form {
    max-width: 30rem;
}

.scan-edit-actions {
    display: grid;
    gap: var(--space-2);
}

/* The review page presents a dense validation check and the final, explicit batch-submission action. */
.review-summary-card,
.review-list-card,
.review-submit-card {
    display: grid;
    gap: var(--space-3);
}

.review-summary-card h2,
.review-list-heading h2,
.review-list-heading p,
.review-scan-list-item p,
.review-submit-card h2,
.review-submit-card p {
    margin-bottom: 0;
}

.review-summary-metrics,
.carton-grv-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin: 0;
}

.review-summary-metrics > div,
.carton-grv-metrics > div {
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background: var(--color-page-background);
}

.review-summary-metrics dt,
.carton-grv-metrics dt {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 700;
}

.review-summary-metrics dd,
.carton-grv-metrics dd {
    margin: var(--space-1) 0 0;
    color: var(--color-text-strong);
    font-size: 1.5rem;
    font-weight: 700;
}

.review-list-heading {
    display: grid;
    gap: var(--space-2);
}

.review-scan-list {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.review-scan-list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: center;
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background: var(--color-page-background);
}

.review-scan-reference {
    margin-top: var(--space-1);
    color: var(--color-text-muted);
    line-height: 1.4;
}

.review-scan-count {
    display: grid;
    gap: var(--space-1);
    color: var(--color-text-muted);
    font-size: 0.875rem;
    text-align: right;
}

.review-scan-count strong {
    color: var(--color-text-strong);
    font-size: 1.5rem;
}

.review-submit-form {
    max-width: 30rem;
}

.review-submit-status {
    margin: 0;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* The carton-information page replaces one read-only result at a time, so header and contents remain easy to scan. */
.carton-information-result-card {
    display: grid;
    gap: var(--space-3);
}

.carton-information-result-card h2,
.carton-information-result-card p {
    margin-bottom: 0;
}

.carton-information-result-card--not-found {
    border-color: var(--color-error);
}

.carton-information-barcode {
    margin-top: var(--space-1);
    color: var(--color-text-strong);
    font-family: var(--font-family-code);
    font-size: 1.25rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.carton-information-fields {
    display: grid;
    gap: var(--space-2);
    margin: 0;
}

.carton-information-fields > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--color-border);
}

.carton-information-fields > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.carton-information-fields dt {
    color: var(--color-text-strong);
    font-weight: 700;
}

.carton-information-fields dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.carton-information-content-list {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.carton-information-content-list > li {
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background: var(--color-page-background);
}

.carton-information-empty-state {
    margin: 0;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.carton-information-empty-state--error {
    color: var(--color-error);
    font-weight: 700;
}

/* The carton builder keeps one order picker and its server-read SKU quantities compact enough for handheld use. */
.carton-builder-card {
    display: grid;
    gap: var(--space-3);
}

.carton-builder-heading,
.carton-builder-heading > div,
.carton-builder-submit,
.carton-builder-line-details {
    display: grid;
    gap: var(--space-1);
}

.carton-builder-heading h2,
.carton-builder-heading p,
.carton-builder-submit p,
.carton-builder-line-details span {
    margin-bottom: 0;
}

.carton-builder-heading p:not(.eyebrow),
.carton-builder-line-details span {
    color: var(--color-text-muted);
    line-height: 1.5;
}

.carton-builder-order-form .button,
.carton-builder-submit .button {
    justify-self: start;
}

.carton-builder-lines {
    display: grid;
    gap: var(--space-2);
}

.carton-builder-line {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background: var(--color-page-background);
}

.carton-builder-line-details strong {
    color: var(--color-text-strong);
    font-family: var(--font-family-code);
    overflow-wrap: anywhere;
}

.carton-builder-quantity-field input[type="number"] {
    text-align: right;
}

/* Saved signatures are reference cards: they identify reusable contents without implying a physical carton exists. */
.carton-builder-reference-status {
    margin: 0;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.carton-builder-reference-status--error {
    color: var(--color-error);
    font-weight: 700;
}

.carton-builder-signature-list,
.carton-builder-signature-lines {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.carton-builder-signature {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background: var(--color-page-background);
}

.carton-builder-signature--new {
    border-color: var(--color-success);
    background: var(--color-success-surface);
}

.carton-builder-signature-heading {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    justify-content: space-between;
}

.carton-builder-signature-heading h3 {
    margin: 0;
    color: var(--color-text-strong);
    font-family: var(--font-family-code);
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.carton-builder-signature-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: var(--color-success);
    color: var(--color-surface);
    font-size: 0.75rem;
    font-weight: 700;
}

.carton-builder-signature-lines > li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: center;
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}

.carton-builder-signature-lines > li > div {
    display: grid;
    gap: var(--space-1);
    min-width: 0;
}

.carton-builder-signature-lines strong {
    color: var(--color-text-strong);
    font-family: var(--font-family-code);
    overflow-wrap: anywhere;
}

.carton-builder-signature-lines span {
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* Carton GRV keeps one order and one receiving location visible while it groups unique serialized labels by signature. */
.carton-grv-card,
.carton-grv-context-card,
.carton-grv-summary-card,
.carton-grv-submit-card {
    display: grid;
    gap: var(--space-3);
}

.carton-grv-card-heading,
.carton-grv-card-heading > div,
.carton-grv-summary-heading,
.carton-grv-summary-heading > div {
    display: grid;
    gap: var(--space-1);
}

.carton-grv-card-heading h2,
.carton-grv-card-heading h3,
.carton-grv-card-heading p,
.carton-grv-summary-heading h2,
.carton-grv-summary-heading p,
.carton-grv-context-card h2,
.carton-grv-context-card p,
.carton-grv-submit-card h2,
.carton-grv-submit-card p {
    margin-bottom: 0;
}

.carton-grv-card-heading p:not(.eyebrow),
.carton-grv-context-card p:not(.eyebrow),
.carton-grv-summary-heading p:not(.eyebrow),
.carton-grv-location-locked {
    color: var(--color-text-muted);
    line-height: 1.5;
}

.carton-grv-current-order,
.carton-grv-location-locked {
    margin: 0;
}

.carton-grv-order-form .button,
.carton-grv-scan-form .button,
.carton-grv-summary-card > .button {
    justify-self: start;
}

.carton-grv-context-card {
    align-items: center;
}

.carton-grv-context-card .button {
    justify-self: start;
}

.carton-grv-location-locked {
    font-weight: 700;
}

.carton-grv-scan-form,
.carton-grv-submit-form {
    max-width: 34rem;
}

.carton-grv-summary-heading {
    gap: var(--space-3);
}

.carton-grv-signature-groups {
    display: grid;
    gap: var(--space-3);
}

/* GRV and bond share native tappable signature cards; details remain available without JavaScript. */
.carton-grv-signature-group {
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background: var(--color-page-background);
}

.carton-grv-signature-group h3 {
    margin: var(--space-1) 0 0;
    color: var(--color-text-strong);
    font-size: 0.9375rem;
}

.carton-grv-signature-heading {
    display: grid;
    gap: var(--space-2);
    min-height: var(--control-min-height);
    cursor: pointer;
    list-style: none;
}

.carton-grv-signature-heading::-webkit-details-marker {
    display: none;
}

.carton-grv-signature-heading:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 3px;
}

.carton-grv-signature-identity,
.carton-grv-signature-summary-actions,
.carton-grv-signature-details {
    display: grid;
    gap: var(--space-1);
}

.carton-grv-signature-reference {
    color: var(--color-text-strong);
    font-family: var(--font-family-code);
    overflow-wrap: anywhere;
}

.carton-grv-signature-open-text,
.carton-grv-signature-close-text {
    color: var(--color-brand);
    font-weight: 700;
}

.carton-grv-signature-close-text,
.carton-grv-signature-group[open] .carton-grv-signature-open-text {
    display: none;
}

.carton-grv-signature-group[open] .carton-grv-signature-close-text {
    display: inline;
}

.carton-grv-signature-details {
    margin-top: var(--space-3);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}

.carton-grv-signature-heading h3,
.carton-grv-signature-heading p {
    margin-bottom: 0;
}

.carton-grv-signature-heading h3,
.carton-grv-content-lines strong {
    color: var(--color-text-strong);
    font-family: var(--font-family-code);
    overflow-wrap: anywhere;
}

.carton-grv-carton-count {
    color: var(--color-text-muted);
    font-weight: 700;
}

.carton-grv-carton-count strong {
    color: var(--color-text-strong);
    font-size: 1.375rem;
}

.carton-grv-content-lines,
.carton-grv-label-list,
.carton-grv-review-label-list {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.carton-grv-content-lines > li,
.carton-grv-label-list > li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: center;
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}

.carton-grv-content-lines > li > div {
    display: grid;
    gap: var(--space-1);
    min-width: 0;
}

.carton-grv-content-lines span,
.carton-grv-review-label-list code {
    color: var(--color-text-muted);
    line-height: 1.4;
}

.carton-grv-label-list code,
.carton-grv-review-label-list code {
    font-family: var(--font-family-code);
    overflow-wrap: anywhere;
}

.carton-grv-label-list .button {
    min-height: 2.75rem;
}

.carton-grv-review-label-list > li {
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}

/* The location selector uses one map with keyboard selection, filtering, and an explicit confirmation form.
   Selecting a location requires its small script; there is no duplicate form list. */
.location-selector-card {
    display: grid;
    gap: var(--space-3);
}

.location-warehouse-form,
.location-selector-heading {
    display: grid;
    gap: var(--space-2);
}

.location-warehouse-form .button {
    justify-self: start;
}

.location-selector-heading h2,
.location-selector-heading p {
    margin-bottom: 0;
}

.location-selector-heading p:not(.eyebrow),
.location-selector-count,
.location-filter-empty {
    margin: 0;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.location-selector-count strong {
    color: var(--color-text-strong);
    font-size: 1.25rem;
}

.warehouse-map {
    display: block;
    width: 100%;
    min-height: 17rem;
    max-height: 65vh;
    max-height: 65dvh;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background: var(--color-page-background);
}

.warehouse-map--interactive {
    cursor: grab;
    touch-action: none;
}

.warehouse-map--panning {
    cursor: grabbing;
}

.location-map-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.location-map-selection-form {
    display: flex;
}

.location-map-selection-status {
    margin: 0;
    color: var(--color-text-strong);
    font-weight: 700;
}

.warehouse-map-location {
    cursor: pointer;
}

.warehouse-map-location rect {
    fill: var(--color-surface);
    stroke: var(--color-button-secondary-border);
    stroke-width: 1;
}

.warehouse-map-location text {
    fill: var(--color-text-strong);
    font-family: var(--font-family-code);
    font-weight: 700;
    pointer-events: none;
}

.warehouse-map-location:focus-visible rect {
    stroke: var(--color-focus);
    stroke-width: 3;
}

.warehouse-map-location--selected rect {
    fill: var(--color-success-surface);
    stroke: var(--color-success);
    stroke-width: 2;
}

@media (min-width: 48rem) {
    .page-shell,
    .landing-page {
        padding: var(--space-4);
    }

    .surface-card {
        padding: var(--space-4);
    }

    .function-menu {
        grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    }

    .function-card {
        align-content: space-between;
    }

    .scan-list-heading {
        grid-template-columns: 1fr auto;
        align-items: end;
    }

    .scan-location-card {
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .scan-list-summary-actions {
        justify-items: end;
    }

    .scan-list-item {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    /* Count controls stack on handhelds so enlarged text cannot push the popup sideways. */
    .scan-count-stepper {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .scan-count-stepper .button {
        min-width: var(--control-min-height);
    }

    .scan-count-stepper input {
        grid-column: auto;
        grid-row: auto;
    }

    .scan-count-dialog-confirmation {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scan-item-details > div {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .carton-information-fields > div {
        grid-template-columns: minmax(7rem, auto) minmax(0, 1fr);
    }

    .review-list-heading {
        grid-template-columns: 1fr auto;
        align-items: end;
    }

    .carton-builder-order-form {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
    }

    .carton-builder-line {
        grid-template-columns: minmax(0, 1fr) minmax(12rem, 16rem);
        align-items: end;
    }

    .carton-grv-context-card,
    .carton-grv-summary-heading,
    .carton-grv-signature-heading {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .carton-grv-metrics {
        min-width: 15rem;
    }

    .carton-grv-signature-summary-actions {
        text-align: right;
    }

    .location-warehouse-form {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
    }

    .location-selector-heading {
        grid-template-columns: 1fr auto;
        align-items: end;
    }
}
