/* Inventory IQ design system; page overrides live in pages/ and components/. */

@import url("https://fonts.googleapis.com/css2?family=Fira+Sans:wght@500;600;700;800&family=Mallanna&family=Nunito+Sans:opsz,wght@6..12,500;6..12,600;6..12,700;6..12,800&display=swap");
/* Later layers beat earlier ones on a tied selector, whatever the physical order below. */
@layer base, responsive, print;

@layer base {

  :root {
    --color-primary: #f4c95d;
    --color-primary-dark: #a57210;
    --color-bg: #fff8df;
    --color-panel: #fffdf4;
    --color-white: #ffffff;
    --color-panel-tint: #fffefa;
    --color-ink: #111820;
    --color-muted: #605f56;
    --color-line: #d8c98e;
    --color-soft-line: #eadcab;
    --color-success-bg: #e4f5e9;
    --color-success-border: #2f7d46;
    --color-danger-bg: #f8dfdf;
    --color-danger-border: #c32020;
    --color-warning-bg: #fff0bd;
    --color-warning-border: #a57210;
    --color-info-bg: #dceafd;
    --color-info-border: #4d73a6;
    --color-row-focus: #fff7d6;
    --color-home-bg: #3a342a;
    --color-home-border: #221f18;
    --shadow-soft: 0 12px 24px rgba(45, 33, 8, 0.08);
    --shadow-button: inset 0 0 0 3px rgba(165, 114, 16, 0.35);
    --ring-changed: inset 0 0 0 3px rgba(165, 114, 16, 0.3);
    --ring-invalid: inset 0 0 0 3px rgba(159, 52, 52, 0.28);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --admin-frame-width: 8px;
    --header-padding-y: clamp(10px, 2vw, 18px);
    --header-padding-x: clamp(12px, 2.5vw, 22px);
    --main-width: 1560px;
    --page-gutter: clamp(10px, 2vw, 28px);
    --content-width-md: 1120px;
    --card-menu-min: 230px;
    --font-main: "Nunito Sans", "Segoe UI", Calibri, sans-serif;
    --font-heading: "Fira Sans", "Segoe UI", sans-serif;
    --font-display: Mallanna, "Nunito Sans", sans-serif;
    /* Root type scale: every rem-based size in the file shrinks/grows off this single value. */
    --font-scale: clamp(15px, 0.4vw + 14px, 16px);
  }

  /* Large screens (TV mirrored from a laptop, mouse/keyboard driven): scale type and content width up for couch-distance viewing instead of leaving the extra pixels blank. */
  * {
    box-sizing: border-box;
  }

  html {
    color-scheme: light;
    font-size: var(--font-scale);
  }

  body {
    margin: 0;
    height: 100svh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-main);
  }

  body.admin-screen {
    border: 0;
    padding: var(--admin-frame-width);
  }

  body.admin-screen::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
    border: var(--admin-frame-width) solid var(--color-danger-border);
  }

  a {
    color: inherit;
  }

  button {
    font-family: inherit;
  }

  :focus-visible {
    outline: 3px solid var(--color-primary-dark);
    outline-offset: 1px;
  }

  body>header {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: clamp(8px, 2vw, 16px);
    align-items: center;
    min-height: clamp(70px, 12svh, 108px);
    padding: var(--header-padding-y) var(--header-padding-x);
    background: var(--color-primary);
    border-bottom: 5px solid var(--color-primary-dark);
    box-shadow: 0 3px 15px rgba(45, 33, 8, 0.18);
  }

  body.admin-screen>header {
    padding-top: calc(var(--header-padding-y) + var(--admin-frame-width));
    padding-inline: calc(var(--header-padding-x) + var(--admin-frame-width));
  }

  .brand {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2vw, 16px);
    min-width: 0;
  }

  .brand>div {
    min-width: 0;
  }

  .logo {
    width: clamp(44px, 8svh, 72px);
    height: clamp(44px, 8svh, 72px);
    object-fit: contain;
    flex: 0 0 auto;
  }

  .header-actions,
  .button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
  }

  .header-actions {
    justify-content: end;
  }

  body>main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    width: min(var(--main-width), calc(100% - (var(--page-gutter) * 2)));
    margin: 0 auto;
    padding: clamp(12px, 3svh, 28px) 0;
  }

  .kiosk-main,
  .quantity-main,
  .help-main,
  .label-preview-main {
    --main-width: var(--content-width-md);
  }

  .search-main {
    --main-width: 900px;
  }

  /* The quantity keypad needs the height back that the shared padding spends. */
  .quantity-main {
    padding-block: clamp(8px, 2svh, 18px);
  }

  /* Pages with their own bounded-scroll region opt out of main's scroll and stretch that region to fill it instead. */
  body>main:has(> .tabbed-panel),
  .kiosk-main:has(.continue),
  .search-main:has(.bulk-select),
  .help-main:has(.help-results) {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  body>main:has(> .tabbed-panel)>.tabbed-panel,
  .kiosk-main:has(.continue)>form {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
  }

  .kiosk-main:has(.continue)>form {
    display: flex;
    flex-direction: column;
  }

  /* The keypad fills the leftover height, so the shell is a bounded flex column, not auto height. */
  .pin-shell {
    padding: clamp(12px, 3svh, 28px) 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .pin-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .pin-panel> :not(.keypad) {
    flex: 0 0 auto;
  }

  .pin-shell .keypad {
    flex: 1 1 auto;
    min-height: 0;
    grid-auto-rows: 1fr;
  }

  /* flex, not grid: grid's implicit "auto" rows stretch to absorb a fillable-height parent's free space; flex items don't grow past their content unless flex-grow is set. */
  .stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .stack-lg {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }

  /* Flex items shrink by default; without it a bounded ancestor compresses each block instead of scrolling. */
  .stack>*,
  .stack-lg>* {
    flex-shrink: 0;
  }

  .card-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--card-menu-min)), 1fr));
    gap: 14px;
  }

  .card-menu>.card {
    align-content: start;
    min-height: clamp(92px, 7.6vw, 130px);
  }

  .card-menu>.card h2 {
    font-size: clamp(1.35rem, 2vw, 1.8rem);
  }

  .footer-actions {
    display: grid;
    gap: 12px;
    justify-items: center;
    margin-top: 20px;
  }

  .section-label {
    margin-bottom: 10px;
    color: #46380f;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  h1,
  h2,
  h3,
  p {
    margin: 0;
  }

  h1,
  h2,
  h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.015em;
  }

  h1 {
    font-size: clamp(1.35rem, 4vw, 2.4rem);
    line-height: 1;
  }

  h2 {
    font-size: clamp(1.35rem, 3vw, 1.8rem);
    line-height: 1.1;
  }

  h3 {
    font-size: clamp(1.05rem, 2.3vw, 1.25rem);
    line-height: 1.2;
  }

  p {
    color: var(--color-muted);
    font-weight: 500;
    line-height: 1.35;
  }

  .subtitle {
    color: #46380f;
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  .muted {
    color: var(--color-muted);
  }

  .item-name {
    font-weight: 800;
  }

  .text-link {
    color: #5d3f00;
    font-weight: 700;
    text-decoration: underline;
  }

  .inline-link-button {
    min-height: auto;
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
  }

  .restock-critical {
    background: #ef9f9f;
    color: #6f1010;
    font-weight: 800;
  }

  .restock-low {
    background: #f8d3d3;
    color: #7c1f1f;
  }

  .restock-projected-stockout {
    background: #ffd2a3;
    color: #7a3c00;
    font-weight: 700;
  }

  .restock-projected-low {
    background: var(--color-warning-bg);
    color: #6b4a00;
    font-weight: 700;
  }

  .support {
    max-width: 760px;
    margin: 0 auto;
    padding-top: 28px;
    color: var(--color-muted);
    text-align: center;
    font-weight: 500;
  }

  .empty-state {
    display: grid;
    justify-items: center;
    gap: 14px;
    padding: clamp(28px, 8vw, 70px) 20px;
    text-align: center;
  }

  .error-code {
    color: var(--color-muted);
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.08em;
  }

  .panel,
  .card,
  .choice-card,
  .auth-panel,
  .alert,
  .search,
  .quantity-panel,
  .continue {
    background: var(--color-panel);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
  }

  /* The gold top edge marks a block of content; a search box or an action bar is a control, not content. */
  .panel,
  .card,
  .choice-card,
  .auth-panel,
  .alert {
    border-top: 5px solid var(--color-primary-dark);
  }

  .panel {
    overflow: hidden;
  }

  .panel-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
    padding: 20px 22px;
    border-bottom: 1px solid var(--color-soft-line);
  }

  .panel-header>p {
    flex-basis: 100%;
  }

  /* A title and description wrapped together need their own gap; everything resets to margin 0. */
  .panel-header>div {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .panel-body {
    padding: 22px;
  }

  .card,
  .choice-card {
    min-height: 128px;
    display: grid;
    align-content: center;
    gap: 8px;
    padding: 18px;
    color: inherit;
    text-decoration: none;
    text-align: left;
    transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
    cursor: pointer;
  }

  .choice.selected,
  .radio-card input:checked+.choice-card {
    background: var(--color-panel-tint);
    border: 5px solid var(--color-primary-dark);

  }

  .radio-card {
    position: relative;
    display: block;
  }

  .radio-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  /* Shared square icon-only button; .item-trend-button and .row-action-button only add padding. */
  .icon-button-sm {
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--color-soft-line);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-muted);
    cursor: pointer;
    vertical-align: middle;
  }

  .icon-button-sm:hover,
  .icon-button-sm:focus-visible {
    border-color: var(--color-primary-dark);
    color: var(--color-primary-dark);
    outline: none;
  }

  .button,
  .header-action,
  .home-button,
  .cancel,
  .danger-button,
  .success-button,
  .quiet-button {
    min-height: 50px;
    display: inline-grid;
    place-items: center;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: inherit;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  }

  .button {
    border: 2px solid var(--color-ink);
    background: var(--color-white);
    color: var(--color-ink);
  }

  .home-button {
    border: 2px solid var(--color-home-border);
    background: var(--color-home-bg);
    color: var(--color-bg);
  }

  /* Icon-only header buttons stay square so they read as a tool, not a truncated label. */
  .icon-action {
    width: 50px;
    padding: 0;
  }

  .icon-action svg {
    width: 26px;
    height: 26px;
  }

  /* The one-line "what do I do here" line above a page's content. */
  .page-intro {
    max-width: var(--content-width-md);
    color: var(--color-muted);
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    line-height: 1.45;
  }

  .danger-button {
    border: 2px solid var(--color-danger-border);
    background: var(--color-danger-bg);
    color: #4a1515;
  }

  .header-action,
  .cancel {
    border: 2px solid var(--color-danger-border);
    background: var(--color-danger-bg);
    color: #4a1515;
  }

  .success-button {
    border: 2px solid var(--color-success-border);
    background: var(--color-success-bg);
    color: #123d20;
  }

  .quiet-button {
    border: 2px solid #81734c;
    background: #f4f0df;
    color: #2f2b1e;
  }

  .compact-alert {
    padding: 10px 12px;
    box-shadow: none;
  }

  .expiration-group-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: end;
  }

  .expiration-recount-link {
    min-height: 48px;
  }

  .expiration-card {
    background: var(--color-panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    border: 2px solid transparent;
  }

  .expiration-card.expiration-group-incomplete {
    border-color: var(--color-danger-border);
  }

  .expiration-card-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 2px solid var(--color-soft-line);
  }

  .expiration-card-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
  }

  .expiration-card-sub {
    color: var(--color-muted);
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 2px;
  }

  .expiration-card-body {
    padding: 6px 24px 20px;
  }

  .expiration-progress {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .expiration-progress-track {
    width: 130px;
    height: 12px;
    border-radius: 999px;
    background: #ece1bc;
    overflow: hidden;
    flex: 0 0 auto;
  }

  .expiration-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--color-primary-dark);
    transition: width 0.15s ease, background-color 0.15s ease;
  }

  .expiration-progress-label {
    font-weight: 800;
    font-size: 1.1rem;
    white-space: nowrap;
  }

  .expiration-progress.expiration-is-complete .expiration-progress-fill {
    background: var(--color-success-border);
  }

  .expiration-progress.expiration-is-complete .expiration-progress-label {
    color: var(--color-success-border);
  }

  .expiration-progress.expiration-is-over .expiration-progress-fill {
    background: var(--color-danger-border);
  }

  .expiration-progress.expiration-is-over .expiration-progress-label {
    color: var(--color-danger-border);
  }

  .expiration-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 4px;
  }

  .expiration-row+.expiration-row {
    border-top: 1px solid var(--color-soft-line);
  }

  .expiration-row-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
  }

  .expiration-date {
    font-size: 1.15rem;
    font-weight: 800;
    color: #3c2f0c;
  }

  .expiration-meta {
    color: var(--color-muted);
    font-size: 0.92rem;
    font-weight: 600;
  }

  .suggested-expiration {
    background: #fff8db;
    border-radius: var(--radius-md);
    padding-inline: 14px;
    margin-inline: -14px;
  }

  .expiration-newdate-label {
    font-size: 1.05rem;
    font-weight: 800;
    color: #3c2f0c;
    display: block;
    margin-bottom: 8px;
  }

  .expiration-date-input {
    min-height: 52px;
    padding: 0 14px;
    border: 2px solid var(--color-line);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    background: var(--color-white);
  }

  .expiration-stepper {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 0 0 auto;
  }

  .expiration-stepper[hidden] {
    display: none;
  }

  .expiration-stepper button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #3c2f0c;
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(45, 33, 8, 0.25);
  }

  .expiration-stepper button:active {
    transform: scale(0.93);
  }

  .expiration-stepper button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
  }

  .expiration-qty {
    width: 56px;
    text-align: center;
    font: inherit;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--color-ink);
    user-select: none;
    -webkit-user-select: none;
  }

  .expiration-date-warning {
    color: var(--color-danger-border);
    font-size: 0.92rem;
    font-weight: 600;
  }

  .expiration-other {
    background: var(--color-warning-bg);
    border-radius: var(--radius-md);
    padding-inline: 14px;
    margin-inline: -14px;
  }

  .expiration-other .expiration-meta {
    color: #5d4d1e;
  }

  .expiration-other[data-exp-other-discouraged="1"].expiration-other-used .expiration-meta {
    color: var(--color-danger-border);
  }

  .expiration-submit-blocked {
    opacity: 0.82;
  }

  .expiration-bulk-reminder {
    display: block;
    margin-top: 6px;
    color: #5d4d1e;
  }

  .expiration-expired {
    background: #f4b8b8;
    color: #6f1010;
    font-weight: 800;
  }

  .expiration-soon {
    background: #ffd7a8;
    color: #7a3c00;
    font-weight: 800;
  }

  .expiration-ok {
    background: var(--color-success-bg);
    color: #1f6636;
    font-weight: 700;
  }

  .button:hover,
  .header-action:hover,
  .home-button:hover,
  .cancel:hover,
  .danger-button:hover,
  .success-button:hover,
  .quiet-button:hover,
  .card:hover,
  .choice-card:hover {
    background-image: linear-gradient(rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.28));
    box-shadow: var(--shadow-button);
  }

  .button:active,
  .header-action:active,
  .home-button:active,
  .cancel:active,
  .danger-button:active,
  .success-button:active,
  .quiet-button:active,
  .card:active,
  .choice-card:active {
    transform: translateY(2px);
    box-shadow: none;
  }

  .button.selected,
  .header-action.selected,
  .danger-button.selected,
  .success-button.selected,
  .quiet-button.selected {
    box-shadow: inset 0 0 0 4px var(--color-primary-dark);
  }

  .auth-shell {
    width: min(560px, 100%);
    margin: 0 auto;
  }

  .auth-panel {
    display: grid;
    gap: 18px;
    padding: clamp(18px, 4vw, 28px);
  }

  .auth-form {
    display: grid;
    gap: 12px;
  }

  .link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
  }

  .inline-form {
    display: inline-flex;
    gap: 8px;
    align-items: center;
  }

  .full-button {
    width: 100%;
  }

  .single-link-row {
    justify-content: center;
  }

  .hidden {
    display: none !important;
  }

  .print-only {
    display: none;
  }

  .settings-groups,
  .settings-options {
    display: grid;
    gap: 16px;
  }

  .settings-section,
  .setting-row {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--color-soft-line);
    border-radius: var(--radius-md);
    background: var(--color-white);
  }

  .setting-row {
    grid-template-columns: minmax(0, 1fr) minmax(160px, auto);
    align-items: center;
  }

  .setting-control {
    display: grid;
    gap: 4px;
  }

  .setting-name {
    color: var(--color-ink);
    font-weight: 700;
  }

  label {
    color: #46380f;
    font-weight: 600;
  }

  input,
  select,
  .small-input,
  .small-select,
  .table-input {
    min-height: 50px;
    width: 100%;
    padding: 0 14px;
    border: 2px solid var(--color-ink);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font: inherit;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  }

  select,
  .small-select {
    padding-right: 44px;
  }

  .upc-add-form {
    flex: 1 1 360px;
    justify-content: end;
  }

  .upc-add-form input {
    max-width: 18ch;
  }

  input:hover,
  select:hover,
  .small-input:hover,
  .small-select:hover,
  .table-input:hover {
    background: var(--color-panel-tint);
    box-shadow: var(--shadow-button);
  }

  input:focus-visible,
  select:focus-visible,
  .small-input:focus-visible,
  .small-select:focus-visible,
  .table-input:focus-visible {
    outline: 0;
    border-color: var(--color-primary-dark);
    box-shadow: 0 0 0 2px var(--color-primary-dark);
  }

  input:-webkit-autofill {
    /* Chrome paints its own yellow on autofill; only an inset shadow this large repaints the field. */
    box-shadow: 0 0 0 100px var(--color-white) inset;
    -webkit-text-fill-color: var(--color-ink);
    caret-color: var(--color-ink);
  }

  input:-webkit-autofill:hover {
    box-shadow: 0 0 0 100px var(--color-white) inset, var(--shadow-button);
  }

  input:-webkit-autofill:focus-visible {
    border-color: var(--color-primary-dark);
    box-shadow: 0 0 0 100px var(--color-white) inset, 0 0 0 2px var(--color-primary-dark);
  }

  input[type="checkbox"] {
    width: 1.4rem;
    min-height: 1.4rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: none;
    justify-self: end;
    accent-color: var(--color-success-border);
  }

  input[type="checkbox"]:hover,
  input[type="checkbox"]:focus-visible {
    background: transparent;
    box-shadow: none;
  }

  .readonly-check:disabled {
    opacity: 1;
    cursor: default;
  }

  .table-input {
    width: 7rem;
    max-width: 100%;
  }

  [data-edit-form] .table-input {
    width: min(18rem, 100%);
    margin: 3px 0;
  }

  [data-edit-form] textarea.table-input {
    min-width: 18rem;
    min-height: 7rem;
    padding: 10px 14px;
  }

  .edit-field {
    display: block;
    margin: 6px 0;
    color: #46380f;
    font-size: 0.82rem;
    font-weight: 800;
  }

  .edit-field span {
    display: block;
    margin-bottom: 2px;
  }

  .checkbox-list {
    max-height: 10rem;
    overflow-y: auto;
    padding: 6px 8px;
    border: 2px solid var(--color-ink);
    border-radius: var(--radius-sm);
    background: var(--color-white);
  }

  .checkbox-list .check-option {
    white-space: normal;
  }

  .check-option {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 4px 0;
    white-space: nowrap;
  }

  .table-input.changed {
    background: var(--color-panel-tint);
    border-color: var(--color-primary-dark);
  }

  .changed,
  .switch.changed,
  .small-input.changed,
  .small-select.changed {
    background: #fff6d8;
    border-color: var(--color-primary-dark);
    box-shadow: var(--ring-changed);
  }

  .invalid,
  .table-input.invalid,
  .small-input.invalid,
  .small-select.invalid {
    background: var(--color-danger-bg);
    border-color: var(--color-danger-border);
    box-shadow: var(--ring-invalid);
  }

  .required-marker {
    display: inline !important;
    color: var(--color-danger-border);
    font-weight: 800;
    white-space: nowrap;
  }

  .field-hint {
    display: block;
    width: fit-content;
    max-width: 100%;
    margin-top: 4px;
    margin-bottom: 4px;
    padding: 2px 7px;
    border: 1px solid rgba(195, 32, 32, 0.22);
    border-radius: 999px;
    background: rgba(248, 223, 223, 0.9);
    color: #8b1e1e;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
  }

  .field-hint.hidden {
    display: none;
  }

  .field-hint-passive {
    border-color: rgba(165, 114, 16, 0.22);
    background: rgba(255, 244, 214, 0.92);
    color: #8b5d10;
  }

  #edit-modal-message {
    padding: 5px 0;
  }

  .validation-pulse {
    animation: validationPulse 0.28s ease-out;
  }

  @keyframes validationPulse {
    0% {
      box-shadow: 0 0 0 0 rgba(159, 52, 52, 0.35);
    }

    100% {
      box-shadow: 0 0 0 5px rgba(159, 52, 52, 0);
    }
  }

  .switch {
    display: inline-grid;
    place-items: center;
    min-width: 82px;
    min-height: 44px;
    padding: 0 12px;
    border: 2px solid var(--color-success-border);
    border-radius: 999px;
    background: var(--color-success-bg);
    color: #123d20;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  }

  .switch.off {
    border-color: #81734c;
    background: #f4f0df;
    color: #2f2b1e;
  }

  .switch:hover {
    box-shadow: var(--shadow-button);
  }

  .switch:active {
    transform: translateY(2px);
    box-shadow: none;
  }

  .tab-strip {
    flex: 0 0 auto;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: end;
    padding: 0 2px;
    border-bottom: 2px solid var(--color-ink);
  }

  .tabbed-panel {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .tabbed-panel .panel {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    border-top: 0;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* A sticky thead pins against the nearest scrolling ancestor, so .table-wrap must be it. */
  .tabbed-panel .panel>.table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  .tab-panel {
    min-width: 0;
    max-width: 100%;
  }

  .tab-button {
    min-width: 0;
    min-height: 58px;
    flex: 1 1 190px;
    display: grid;
    place-items: center;
    padding: 0 14px;
    border: 2px solid var(--color-ink);
    border-bottom: 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background: #f4f0df;
    color: var(--color-ink);
    font-family: var(--font-heading);
    font-size: clamp(1.05rem, 2.4vw, 1.3rem);
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    overflow-wrap: anywhere;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  }

  .tab-button.active {
    min-height: 64px;
    background: var(--color-panel);
    margin-bottom: -2px;
    box-shadow: inset 0 -5px 0 var(--color-primary-dark);
  }

  .tab-button:hover {
    background: var(--color-panel-tint);
    box-shadow: var(--shadow-button);
  }

  .table-wrap {
    position: relative;
    z-index: 1;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
  }

  th,
  td {
    padding: clamp(6px, 1.2vw, 10px);
    border-bottom: 1px solid var(--color-soft-line);
    font-size: clamp(0.78rem, 0.55rem + 0.45vw, 0.96rem);
    text-align: left;
    font-weight: 500;
    vertical-align: middle;
    overflow-wrap: normal;
  }

  tbody tr {
    transition: background-color 0.15s ease;
  }

  tbody tr:hover {
    background: var(--color-panel-tint);
  }

  th {
    background: #fff3c6;
    color: #3e300d;
    font-size: clamp(0.68rem, 0.5rem + 0.35vw, 0.84rem);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    overflow-wrap: normal;
  }

  th[data-sort-column] {
    cursor: pointer;
  }

  .panel thead th {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  [data-sort-table] thead th {
    cursor: pointer;
  }

  .sortable-heading a {
    display: block;
    color: inherit;
    text-decoration: none;
  }

  th.sorted-column {
    background: #fff7d6;
  }

  [data-sort-table][data-sort-direction="asc"] th.sorted-column::after {
    content: " \2191";
  }

  [data-sort-table][data-sort-direction="desc"] th.sorted-column::after {
    content: " \2193";
  }

  td.sorted-cell {
    box-shadow: inset 0 0 0 9999px rgba(255, 247, 214, 0.42);
  }

  .table-thumbnail {
    width: min(100%, 58px);
    height: 42px;
    display: block;
    object-fit: cover;
    border: 1px solid var(--color-soft-line);
    border-radius: var(--radius-sm);
    background: var(--color-white);
  }

  .info-tip {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 1.15rem;
    height: 1.15rem;
    margin-left: 4px;
    border: 1px solid #8a6b18;
    border-radius: 999px;
    background: #fff9e6;
    color: #624900;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    cursor: help;
  }

  .info-tip:hover,
  .info-tip:focus-visible {
    background: #ffe8a6;
    outline: 2px solid #b88700;
    outline-offset: 2px;
  }

  .info-tip::after {
    position: absolute;
    z-index: 1000;
    top: calc(100% + 8px);
    left: 50%;
    width: 220px;
    padding: 8px 10px;
    border: 1px solid var(--color-ink);
    border-radius: 8px;
    background: var(--color-white);
    box-shadow: var(--shadow-button);
    color: var(--color-ink);
    content: attr(data-tooltip);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.3;
    text-align: left;
    text-transform: none;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
  }

  .info-tip:hover::after,
  .info-tip:focus-visible::after,
  .info-tip.is-open::after {
    opacity: 1;
  }

  .tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .tag {
    display: inline-grid;
    place-items: center;
    min-height: 26px;
    padding: 2px 9px;
    border: 1px solid;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    transition: transform 0.12s ease, box-shadow 0.15s ease;
  }

  .tag:hover,
  .tag.selected {
    transform: translateY(-1px);
    box-shadow: var(--shadow-button);
  }

  .tag.blue {
    background: var(--color-info-bg);
    border-color: var(--color-info-border);
  }

  .tag.green {
    background: var(--color-success-bg);
    border-color: var(--color-success-border);
  }

  .tag.gold {
    background: var(--color-warning-bg);
    border-color: var(--color-warning-border);
  }

  .tag.red {
    background: var(--color-danger-bg);
    border-color: var(--color-danger-border);
  }

  .alert {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border-top-width: 1px;
  }

  .alert:hover,
  .alert.selected {
    box-shadow: var(--shadow-button);
  }

  .alert.error {
    border-color: var(--color-danger-border);
    background: var(--color-danger-bg);
  }

  .alert.success {
    border-color: var(--color-success-border);
    background: var(--color-success-bg);
  }

  .alert.warning {
    border-color: var(--color-warning-border);
    background: var(--color-warning-bg);
  }

  .alert.info {
    border-color: var(--color-info-border);
    background: var(--color-info-bg);
  }

  .flash-container {
    --flash-color: #6f6a55;
    --flash-light: var(--color-panel);
    position: fixed;
    left: 0;
    bottom: -5px;
    z-index: 100;
    width: 100%;
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 1rem 1.5rem;
    border-radius: 3rem 3rem 0 0;
    background: var(--flash-light);
    box-shadow: 0 -1px 32px rgba(17, 24, 32, 0.18);
    outline: 5px solid var(--flash-color);
    outline-offset: -2px;
    transform: translateY(101%);
    transition: transform 0.7s ease-in-out;
  }

  .flash-container.show {
    transform: translateY(0);
  }

  .flash-container.flash-error {
    --flash-color: #dc3545;
    --flash-light: #f7cdd0;
    box-shadow: 0 -1px 40px rgba(220, 53, 69, 0.4);
    outline-width: 10px;
  }

  .flash-container.flash-success {
    --flash-color: #28a745;
    --flash-light: #d7f3df;
  }

  .flash-container.flash-warning {
    --flash-color: #ffc107;
    --flash-light: var(--color-warning-bg);
  }

  .flash-container.flash-info {
    --flash-color: #17a2b8;
    --flash-light: #d3f3f7;
  }

  .flash-icon {
    width: clamp(42px, 6vh, 64px);
    height: clamp(42px, 6vh, 64px);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 3px solid var(--flash-color);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    color: var(--flash-color);
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 500;
  }

  .flash-message {
    flex: 1 1 auto;
    color: var(--color-ink);
    font-size: clamp(1.05rem, 2.4vw, 1.35rem);
    font-weight: 700;
  }

  .timer-container {
    width: 2.5rem;
    height: 2.5rem;
    position: relative;
    flex: 0 0 auto;
  }

  .timer-circle,
  .timer {
    width: 100%;
    height: 100%;
    border-radius: 50%;
  }

  .timer-circle {
    background: var(--flash-light);
    overflow: hidden;
  }

  .timer {
    background: conic-gradient(var(--flash-light) 62%, var(--flash-color) 62%);
  }

  .photo {
    height: clamp(96px, 22svh, 220px);
    border: 3px solid var(--color-ink);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-white);
  }

  .photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .quantity-panel {
    padding: clamp(10px, 2vw, 18px);
  }

  .quantity-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
  }

  .quantity-actions .quiet-button,
  .quantity-actions .success-button {
    min-height: 66px;
    font-size: clamp(1.2rem, 3vw, 1.65rem);
  }

  .modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
    border-radius: var(--radius-md);
    background: rgba(17, 24, 32, 0.48);
  }

  .modal {
    width: min(540px, 100%);
    max-height: min(88vh, 820px);
    padding: 18px;
    border: 3px solid var(--color-ink);
    border-radius: var(--radius-lg);
    background: var(--color-panel);
    box-shadow: 0 16px 40px rgba(17, 24, 32, 0.28);
    overflow-y: auto;
  }

  .confirm-modal {
    display: grid;
    gap: 16px;
    text-align: center;
  }

  .confirm-modal .button-row {
    justify-content: center;
  }

  .counting-down {
    opacity: 0.5;
    pointer-events: none;
  }

  .history-print-modal {
    display: grid;
    gap: 16px;
  }

  .history-print-modal form {
    gap: 16px;
  }

  .loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(17, 24, 32, 0.38);
  }

  .loading-overlay.hidden {
    display: none;
  }

  .loading-overlay__panel {
    min-width: min(260px, 100%);
    display: grid;
    justify-items: center;
    gap: 14px;
    padding: 22px 24px;
    border: 3px solid var(--color-ink);
    border-radius: var(--radius-lg);
    background: var(--color-panel);
    box-shadow: 0 16px 40px rgba(17, 24, 32, 0.28);
  }

  .loading-overlay__spinner {
    width: 56px;
    height: 56px;
    border: 6px solid rgba(165, 114, 16, 0.22);
    border-top-color: var(--color-primary-dark);
    border-radius: 50%;
    animation: loading-spin 0.85s linear infinite;
  }

  .loading-overlay__label {
    color: var(--color-ink);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
  }

  body.loading-active {
    cursor: progress;
  }

  body.loading-active>*:not(.loading-overlay) {
    pointer-events: none;
  }

  @keyframes loading-spin {
    to {
      transform: rotate(360deg);
    }
  }

  .helper {
    margin: 0;
    color: var(--color-muted);
    font-weight: 700;
    text-align: center;
  }

  .change-list {
    display: grid;
    gap: 8px;
    margin: 14px 0;
  }

  .change-review-backdrop {
    justify-items: center;
    align-items: center;
  }

  /* width comes from the base .modal class every caller combines this with; restating it was dead weight. */
  .change-review-modal {
    max-height: min(80vh, 720px);
    display: flex;
    flex-direction: column;
  }

  .change-review-modal .change-list {
    min-height: 0;
    overflow: auto;
    gap: 12px;
  }

  .change-review-modal .change-record {
    display: grid;
    gap: 4px;
  }

  .change-review-modal .change-record-title {
    margin: 0;
    padding: 6px 0 4px;
    color: var(--color-ink);
    font-size: 0.98rem;
    line-height: 1.2;
  }

  .change-review-modal .change-record-items {
    display: grid;
    gap: 4px;
  }

  .change-item {
    padding: 10px;
    border: 1px solid var(--color-soft-line);
    border-radius: 7px;
    background: #fffef8;
    font-weight: 600;
  }

  .change-item:hover,
  .change-item.selected {
    background: var(--color-panel-tint);
    box-shadow: var(--shadow-button);
  }

  .change-review-modal .change-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 0.92rem;
    font-weight: 600;
  }

  .change-review-modal .change-item:hover,
  .change-review-modal .change-item.selected {
    box-shadow: none;
  }

  .change-review-modal .change-item-label {
    min-width: 0;
  }

  .change-review-modal .change-item-value,
  .change-review-modal .change-item-arrow {
    color: var(--color-muted);
    font-size: 0.85rem;
    font-weight: 500;
    word-break: break-word;
  }

  .change-review-modal .change-item-checkbox {
    --change-checkbox-icon: url("https://img.icons8.com/?size=100&id=83310&format=png&color=000000");
    display: inline-flex;
    align-items: center;
    margin: auto 0;
    width: 0.95rem;
    height: 0.95rem;
    background: transparent;
    background-color: var(--color-muted);
    mask-image: var(--change-checkbox-icon);
    mask-position: center;
    mask-repeat: no-repeat;
    mask-size: contain;
    -webkit-mask-image: var(--change-checkbox-icon);
    -webkit-mask-position: center;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-size: contain;
  }

  .change-review-modal .change-item-checkbox.is-checked {
    --change-checkbox-icon: url("https://img.icons8.com/?size=100&id=83319&format=png&color=000000");
  }

  .change-review-modal .change-item-arrow {
    color: var(--color-ink);
  }

  .search {
    padding: 18px;
  }

  .status {
    margin-bottom: 10px;
    color: var(--color-muted);
    font-weight: 700;
  }

  .search input[type="search"] {
    min-height: 62px;
    padding: 0 16px;
    border: 3px solid var(--color-ink);
    font-size: 1.08rem;
    font-weight: 500;
  }

  .search input[type="search"]::-webkit-search-cancel-button {
    cursor: pointer;
    filter: brightness(0);
    transform: scale(1.2);
  }

  .search ul {
    display: grid;
    gap: 8px;
    padding: 0;
    margin: 14px 0 0;
    list-style: none;
  }

  .search li {
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid #cfcfcf;
    border-radius: var(--radius-sm);
    background: var(--color-white);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  }

  .search li:hover,
  .search li:focus-within {
    border-color: var(--color-primary-dark);
    background: var(--color-panel-tint);
  }

  .search li:active {
    box-shadow: none;
  }

  .search li.search-note {
    padding: clamp(18px, 5vw, 30px) 16px;
    border-style: dashed;
    background: var(--color-panel);
    color: var(--color-muted);
    cursor: default;
    font-weight: 700;
    text-align: center;
  }

  .search li.search-note:hover,
  .search li.search-note:focus-within {
    border-color: var(--color-line);
    background: var(--color-panel);
  }

  .search li.search-note--error {
    border-color: var(--color-danger-border);
    background: var(--color-danger-bg);
    color: var(--color-ink);
  }

  .muted-note {
    color: var(--color-muted);
    font-weight: 700;
    text-align: center;
  }

  .history-pagination {
    margin: 15px 0;
    justify-content: center;
  }

  .required-cell {
    background: var(--color-warning-bg);
    box-shadow: inset 0 0 0 2px rgba(165, 114, 16, 0.2);
  }

  tr.suggested-row>th,
  tr.suggested-row>td:not(.required-cell):not(.invalid-cell) {
    background: var(--color-warning-bg);
  }

  .invalid-cell {
    background: var(--color-danger-bg);
    box-shadow: var(--ring-invalid);
  }

  .result-title {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
    justify-content: space-between;
  }

  .result-title strong {
    font-size: 1rem;
  }

  .search .tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1;
    transition: filter 0.15s ease;
  }

  .search li:hover .tag {
    filter: saturate(1.12) brightness(0.98);
  }

  .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .admin {
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: 0 14px;
    border: 2px solid #211902;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.4);
    color: #211902;
    font-family: var(--font-heading);
    font-weight: 700;
    text-decoration: none;
  }

  .admin.icon-action {
    padding: 0;
  }

  .admin:hover,
  .admin:focus-visible {
    background: var(--color-white);
    background-image: none;
    box-shadow: 0 3px 0 rgba(33, 25, 2, 0.32);
    outline: none;
  }

  .selector {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 0;
    row-gap: clamp(14px, 3vw, 34px);
  }

  .group {
    min-width: 0;
    display: grid;
    gap: 10px;
    align-content: start;
    padding-inline: clamp(8px, 1.6vw, 17px);
  }

  .group+.group {
    border-inline-start: 3px dashed var(--color-primary-dark);
  }

  .group-step h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-muted);
    font-size: 1rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .group-step-number {
    min-width: clamp(26px, 4vw, 32px);
    min-height: clamp(26px, 4vw, 32px);
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: var(--color-primary-dark);
    color: var(--color-white);
    font-size: clamp(0.9rem, 2vw, 1.05rem);
    line-height: 1;
  }

  .group-hint {
    font-size: clamp(0.78rem, 1.8vw, 0.95rem);
    font-weight: 600;
    text-transform: none;
  }

  .choice {
    min-height: clamp(58px, 10svh, 82px);
    display: grid;
    place-items: center;
    padding: clamp(10px, 2vw, 14px);
    border: 3px solid var(--color-ink);
    border-radius: var(--radius-md);
    background: var(--color-white);
    color: var(--color-ink);
    font-family: var(--font-heading);
    font-size: clamp(1.1rem, 2.6vw, 1.55rem);
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  }

  .choice:hover,
  .choice:focus-visible {
    background: var(--color-panel-tint);
    box-shadow: 0 3px 0 rgba(17, 24, 32, 0.2);
    outline: none;
  }

  .choice:active {
    transform: translateY(2px);
    box-shadow: none;
  }

  .radio-card input:checked+.choice {
    background: #e8e8e8;
    box-shadow: inset 0 0 0 4px var(--color-primary-dark);
  }

  .choice.invalid,
  .choice-card.invalid {
    border-color: var(--color-danger-border);
    background: var(--color-danger-bg);
    color: #6f1010;
    box-shadow: var(--ring-invalid);
  }

  .continue {
    flex: 0 0 auto;
    margin-top: clamp(10px, 2svh, 18px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(min(220px, 100%), auto);
    gap: 14px;
    align-items: center;
    padding: 16px;
  }

  .continue.invalid {
    border-color: var(--color-danger-border);
    background: var(--color-danger-bg);
  }

  .continue.invalid strong,
  .continue.invalid span {
    color: #6f1010;
  }

  .continue .success-button {
    min-height: clamp(54px, 8svh, 62px);
    font-size: 1.25rem;
  }

  button:disabled {
    border-color: #9f9991;
    background: #e5e1d8;
    color: #67635b;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.75;
  }

  .pin-display {
    min-height: clamp(56px, 10svh, 72px);
    display: grid;
    place-items: center;
    padding: 0 18px;
    border: 3px solid var(--color-ink);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 6vw, 2.6rem);
    font-weight: 500;
    letter-spacing: 0.18em;
  }

  .top {
    display: grid;
    grid-template-columns: minmax(120px, 0.34fr) 1fr;
    gap: clamp(10px, 2vw, 18px);
    align-items: center;
    padding: clamp(10px, 2vw, 18px);
    background: var(--color-panel);
  }

  .name {
    font-family: var(--font-heading);
    font-size: clamp(1.45rem, 5vw, 3.2rem);
    font-weight: 700;
    line-height: 1;
  }

  .unit {
    margin-bottom: 10px;
    color: var(--color-muted);
    font-family: var(--font-display);
    font-weight: 500;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    gap: clamp(8px, 2vw, 12px);
  }

  .step-column {
    display: grid;
  }

  .admin-stack {
    display: grid;
    gap: 8px;
  }

  /* Three of these stack in the same slot a single .step/.count fills elsewhere, so each needs roughly a third of that height. */
  .admin-stack .step {
    min-height: clamp(28px, 7svh, 70px);
    font-size: clamp(1.1rem, 3vw, 2rem);
  }

  .step,
  .count {
    min-height: clamp(86px, 24svh, 230px);
    display: grid;
    place-items: center;
    border-radius: var(--radius-lg);
    font-family: var(--font-display);
    font-size: clamp(3rem, 12vw, 7.5rem);
    font-weight: 500;
  }

  .step {
    border: 3px solid var(--color-line);
    background: #fffdf8;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  }

  .step:hover {
    background: #fff6d8;
    box-shadow: var(--shadow-button);
  }

  .step:active {
    transform: translateY(2px);
    box-shadow: none;
  }

  .minus {
    color: #641919;
  }

  .plus {
    color: #123d20;
  }

  .count {
    border: 3px solid var(--color-primary-dark);
    background: var(--color-panel-tint);
    color: var(--color-ink);
  }

  .reset,
  .submit {
    min-height: clamp(54px, 8svh, 66px);
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: clamp(1.2rem, 3vw, 1.65rem);
    font-weight: 700;
    cursor: pointer;
  }

  .reset {
    border: 3px solid #81734c;
    background: #f4f0df;
    color: #2f2b1e;
  }

  .submit {
    border: 2px solid var(--color-success-border);
    background: var(--color-success-bg);
    color: #123d20;
  }

  .keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
  }

  .key,
  .clear,
  .login {
    min-height: 48px;
    border: 2px solid var(--color-ink);
    border-radius: var(--radius-md);
    background: var(--color-white);
    color: var(--color-ink);
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 5vw, 2.3rem);
    font-weight: 700;
    cursor: pointer;
  }

  .login {
    border-color: var(--color-success-border);
    background: var(--color-success-bg);
    color: #123d20;
  }

}

/* @layer order (declared at the top of the file) decides ties here, not physical position. */
@layer responsive {
  @media (min-width: 1800px) {
    :root {
      --font-scale: 20px;
      --main-width: 1820px;
      --card-menu-min: 320px;
    }
  }

  @media (min-width: 900px) {
    table {
      width: 100%;
    }
  }

  @media (max-width: 700px) {
    body>header {
      grid-template-columns: minmax(0, 1fr);
    }

    .logo {
      display: none;
    }

    h1 {
      font-size: clamp(1.05rem, 5.5vw, 1.6rem);
    }

    .subtitle {
      margin-top: 2px;
      font-size: 0.72rem;
      line-height: 1.2;
    }

    :root {
      --card-menu-min: 45%;
    }

    /* A location card carries only a name, so it takes the full row rather than halving the tap target. */
    .card-menu:has(.choice-card) {
      --card-menu-min: 100%;
    }

    .header-actions {
      gap: 6px;
      flex-wrap: nowrap;
    }

    /* min-width:0 lets a flex child shrink below its text width, so long labels wrap in place instead of the row wrapping to a new line. */
    .header-actions>* {
      flex: 1 1 0;
      min-width: 0;
      min-height: 44px;
      padding: 4px 6px;
      font-size: 0.72rem;
      line-height: 1.15;
      white-space: normal;
    }

    .setting-row,
    .continue {
      grid-template-columns: 1fr;
    }

    .top {
      grid-template-columns: minmax(96px, 0.45fr) minmax(0, 1fr);
    }

    .button-row>* {
      flex: 1 1 160px;
    }

    .scan-route-strip {
      grid-template-columns: 1fr;
    }

    .tab-strip {
      gap: 6px;
      border-bottom: 0;
    }

    /* Base flex:1 1 190px needs ~760px for 4 tabs; a smaller basis lets several share a row instead of one-per-row. */
    .tab-button,
    .tab-button.active {
      min-height: 46px;
      flex: 1 1 70px;
      padding: 0 6px;
      border: 2px solid var(--color-ink);
      border-radius: var(--radius-md);
      font-size: 0.68rem;
      margin-bottom: 0;
    }

    .tabbed-panel {
      gap: 10px;
    }

    .tabbed-panel .panel {
      border-top: 5px solid var(--color-primary-dark);
      border-radius: var(--radius-md);
    }

    th,
    td {
      overflow-wrap: anywhere;
    }
  }

  @media (hover: none) and (pointer: coarse) {
    .info-tip {
      width: 1.8rem;
      height: 1.8rem;
    }

    /* keeps the circle small in the header while the tap target stays 44px */
    .info-tip::before {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 44px;
      height: 44px;
      transform: translate(-50%, -50%);
      content: "";
    }

    .icon-button-sm {
      width: 44px;
      height: 44px;
    }
  }


  @media (orientation: landscape) and (max-height: 560px) {

    /* Every rem font-size derives from this one token, so one cut shrinks the whole app. */
    :root {
      --font-scale: 14px;
    }

    body>header {
      min-height: 0;
      padding: 4px 12px;
    }

    h1 {
      font-size: clamp(1rem, 3vw, 1.3rem);
    }

    h2 {
      font-size: clamp(0.95rem, 2.2vw, 1.15rem);
    }

    .tab-strip {
      gap: 6px;
    }

    .tab-button,
    .tab-button.active {
      min-height: 34px;
      padding: 0 10px;
      font-size: 0.78rem;
    }

    .header-actions {
      gap: 4px;
    }

    .header-actions>* {
      min-height: 32px;
      padding: 2px 8px;
      font-size: 0.7rem;
    }

    .panel-header {
      padding: 8px 12px;
      gap: 6px;
    }

    .panel-body {
      padding: 10px 12px;
    }

    .page,
    body>main {
      padding: 6px 0;
    }

    .choice {
      min-height: 40px;
      padding: 6px;
      font-size: clamp(0.85rem, 2vw, 1.05rem);
    }

    .continue {
      margin-top: 6px;
      padding: 8px;
    }

    .continue .success-button {
      min-height: 40px;
      font-size: 1rem;
    }

    .history-pagination {
      margin: 8px 0;
    }

    .history-pagination .success-button {
      min-height: 36px;
      padding: 0 12px;
      font-size: 0.85rem;
    }

    .subtitle,
    .unit {
      display: none;
    }

    .quantity-main {
      display: grid;
      gap: 8px;
    }

    .quantity-panel {
      display: grid;
      grid-template-columns: minmax(11rem, 0.8fr) 1fr;
      gap: 10px;
      padding: 10px;
    }

    .top {
      grid-template-columns: 1fr;
      padding: 0;
      border: 0;
      background: transparent;
    }

    .photo {
      display: none;
    }

    .name {
      height: 100%;
      display: grid;
      align-items: center;
      padding: 0 8px;
      font-size: clamp(1.15rem, 3.4vw, 1.7rem);
      line-height: 1.05;
    }

    .controls {
      gap: 10px;
    }

    .step,
    .count {
      min-height: clamp(72px, 22svh, 100px);
      font-size: clamp(2.8rem, 8vw, 4.6rem);
    }

    .quantity-actions {
      grid-column: 2;
      gap: 10px;
      margin-top: 10px;
    }

    .reset,
    .submit {
      min-height: clamp(44px, 10svh, 54px);
      font-size: clamp(1rem, 3vw, 1.35rem);
    }

    /* Smaller than the unconditional base fix above, which also has to serve the taller kiosk/laptop. */
    .admin-stack {
      gap: 4px;
    }

    .admin-stack .step {
      min-height: clamp(22px, 6svh, 32px);
      font-size: clamp(0.9rem, 3.5vw, 1.3rem);
    }

    .helper {
      margin-bottom: 6px;
    }

    .pin-display {
      min-height: 46px;
      font-size: clamp(1.3rem, 4vw, 1.8rem);
    }

    /* order:1 moves Clear/Login after digit "0"; every other key keeps order:0, so DOM order (1..9, 0) holds among them. */
    .keypad {
      grid-template-columns: repeat(10, 1fr);
      gap: 6px;
      margin-top: 8px;
    }

    .key {
      min-height: clamp(36px, 14svh, 60px);
      font-size: clamp(1.05rem, 2.6vw, 1.5rem);
    }

    .clear,
    .login {
      grid-column: span 5;
      order: 1;
      min-height: clamp(36px, 10svh, 52px);
      font-size: clamp(0.95rem, 2.2vw, 1.3rem);
    }
  }

}

@layer print {
  @media print {
    body {
      display: block;
      height: auto;
      overflow: visible;
    }

    body>main {
      overflow: visible;
    }

    body:has(.label-sheet)>*:not(main),
    body:has(.label-sheet) .flash-container,
    body:has(.label-sheet) .loading-overlay {
      display: none !important;
    }

    body:has(.label-sheet),
    body:has(.label-sheet).admin-screen {
      padding: 0;
      background: white;
    }

    body:has(.label-sheet).admin-screen::before {
      display: none;
    }

    body:has(.label-sheet)>main {
      width: 100%;
      padding: 0;
    }

    .label-sheet {
      grid-template-columns: repeat(2, 3.375in);
      gap: 0.12in;
      justify-content: start;
    }

    body.printing-report>*:not(main),
    body.printing-report>main>*:not(.print-only),
    body.printing-report .flash-container,
    body.printing-report .loading-overlay {
      display: none !important;
    }

    body.printing-report .print-only {
      display: block;
    }

    body.printing-report {
      background: white;
    }

    body.printing-report.admin-screen {
      border: 0;
      padding: 0;
    }

    body.printing-report.admin-screen::before {
      display: none;
    }

    body.printing-report>main {
      width: 100%;
      padding: 0;
    }

    body.printing-report .table-wrap {
      overflow: visible;
    }

    body.printing-report table {
      width: 100%;
      table-layout: fixed;
    }

    body.printing-report .panel {
      border: 0;
      box-shadow: none;
    }

    @page portrait-report {
      size: portrait;
    }

    @page landscape-report {
      size: landscape;
    }

    /* The page name sits on the body so every page of one report shares an orientation. */
    body.printing-report:has(.report-sheet-portrait) {
      page: portrait-report;
    }

    body.printing-report:has(.report-sheet-landscape) {
      page: landscape-report;
    }

    .report-sheet :is(th, td) {
      padding: 4px;
      color: black;
      line-height: 1.2;
      overflow-wrap: anywhere;
      white-space: normal;
      font-size: 11pt;
    }

    .report-sheet-dense :is(th, td) {
      padding: 2px;
      font-size: 6.5pt;
    }

    body.printing-report .print-title {
      margin-bottom: 18px;
      color: black;
    }

    body.printing-report .print-title h1 {
      margin-bottom: 8px;
      color: black;
      font-size: 18pt;
    }

    body.printing-report .print-kv-grid {
      display: grid;
      gap: 4px;
    }

    body.printing-report .print-kv-row {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      gap: 6px;
      align-items: baseline;
      color: black;
      font-size: 11pt;
    }

    body.printing-report .print-kv-label {
      font-weight: 700;
    }

    body.printing-report .print-kv-value {
      overflow-wrap: anywhere;
    }
  }
}
