/* stockAI — Material Design 3 (Material You)
 *
 * A workshop tool wearing Google's design system. Everything below is built on
 * MD3 system tokens (`--md-sys-*`) rather than loose values, so a change here
 * follows through every page.
 *
 * The colour scheme is a real MD3 tonal palette generated with
 * material-color-utilities from the seed the program has always used —
 * emerald #34d399, "in stock" — using the Vibrant scheme so the green keeps
 * its chroma instead of being flattened into a corporate sage. Light and dark
 * are both complete; the browser picks by `prefers-color-scheme`, and
 * `prefers-contrast: more` swaps in the high-contrast pair.
 *
 * The class names are the ones the templates already use. No Jinja was
 * rewritten to make this work — each existing class is mapped onto the MD3
 * component it was always trying to be:
 *
 *   .topbar     → top app bar (small)      .card       → card (filled/outlined)
 *   .btn        → button, 5 variants       .item       → list item
 *   label.field → filled text field        .authcard   → elevated card
 *   .pill/.chip → chip                     .searchwrap → search bar
 *   .qty        → connected button group   .bar-track  → linear progress
 *   .banner     → inline banner            #lightbox   → full-screen dialog
 *   .dropzone   → outlined drop target     .seg        → segmented button
 *
 * The rules it keeps, in the order they matter:
 *   1. legible in a workshop  - MD3 type scale, every pair over 4.5:1
 *   2. reachable by a thumb   - 48dp targets on touch, 8dp spacing system
 *   3. quiet                  - MD3 emphasized easing, and no motion at all
 *                               for anyone whose system asked for none
 */

/* ==========================================================================
   1. COLOR — MD3 tonal palettes, seed #34d399, Vibrant scheme
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* ---- light, standard contrast ---- */
  --md-sys-color-primary: #006C4B;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #44FFBA;
  --md-sys-color-on-primary-container: #005137;
  --md-sys-color-secondary: #3A665C;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #BDECDF;
  --md-sys-color-on-secondary-container: #214E45;
  --md-sys-color-tertiary: #1A6968;
  --md-sys-color-on-tertiary: #FFFFFF;
  --md-sys-color-tertiary-container: #A8EFED;
  --md-sys-color-on-tertiary-container: #00504F;
  --md-sys-color-error: #BA1A1A;
  --md-sys-color-on-error: #FFFFFF;
  --md-sys-color-error-container: #FFDAD6;
  --md-sys-color-on-error-container: #93000A;
  --md-sys-color-surface: #EFFDF3;
  --md-sys-color-on-surface: #131E18;
  --md-sys-color-surface-variant: #D6E7DB;
  --md-sys-color-on-surface-variant: #3B4A42;
  --md-sys-color-surface-dim: #D0DDD4;
  --md-sys-color-surface-bright: #EFFDF3;
  --md-sys-color-surface-container-lowest: #FFFFFF;
  --md-sys-color-surface-container-low: #EAF7ED;
  --md-sys-color-surface-container: #E4F1E7;
  --md-sys-color-surface-container-high: #DEEBE2;
  --md-sys-color-surface-container-highest: #D9E6DC;
  --md-sys-color-outline: #6B7B71;
  --md-sys-color-outline-variant: #BACBBF;
  --md-sys-color-inverse-surface: #27332C;
  --md-sys-color-inverse-on-surface: #E7F4EA;
  --md-sys-color-inverse-primary: #00E2A0;
  --md-sys-color-scrim: #000000;
  --md-sys-color-shadow: #000000;

  /* Warning has no MD3 role — error covers "wrong", nothing covers "careful".
     Derived from the same tonal method so it belongs to the scheme. */
  --md-sys-color-warning: #7A5900;
  --md-sys-color-on-warning: #FFFFFF;
  --md-sys-color-warning-container: #FFDF9A;
  --md-sys-color-on-warning-container: #5C4200;
}

@media (prefers-color-scheme: dark) {
  :root {
    --md-sys-color-primary: #00E2A0;
    --md-sys-color-on-primary: #003825;
    --md-sys-color-primary-container: #005137;
    --md-sys-color-on-primary-container: #44FFBA;
    --md-sys-color-secondary: #A1D0C4;
    --md-sys-color-on-secondary: #04372F;
    --md-sys-color-secondary-container: #214E45;
    --md-sys-color-on-secondary-container: #BDECDF;
    --md-sys-color-tertiary: #8CD3D1;
    --md-sys-color-on-tertiary: #003736;
    --md-sys-color-tertiary-container: #00504F;
    --md-sys-color-on-tertiary-container: #A8EFED;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-on-error-container: #FFDAD6;
    --md-sys-color-surface: #0B1610;
    --md-sys-color-on-surface: #D9E6DC;
    --md-sys-color-surface-variant: #3B4A42;
    --md-sys-color-on-surface-variant: #BACBBF;
    --md-sys-color-surface-dim: #0B1610;
    --md-sys-color-surface-bright: #303C35;
    --md-sys-color-surface-container-lowest: #06100B;
    --md-sys-color-surface-container-low: #131E18;
    --md-sys-color-surface-container: #17221C;
    --md-sys-color-surface-container-high: #212C26;
    --md-sys-color-surface-container-highest: #2C3731;
    --md-sys-color-outline: #84958A;
    --md-sys-color-outline-variant: #3B4A42;
    --md-sys-color-inverse-surface: #D9E6DC;
    --md-sys-color-inverse-on-surface: #27332C;
    --md-sys-color-inverse-primary: #006C4B;

    --md-sys-color-warning: #EEC148;
    --md-sys-color-on-warning: #402D00;
    --md-sys-color-warning-container: #5C4200;
    --md-sys-color-on-warning-container: #FFDF9A;
  }
}

/* A workshop is lit badly or lit too well. Anyone whose system asks for more
   contrast gets the MD3 high-contrast pair rather than a filter over the top. */
@media (prefers-contrast: more) {
  :root {
    --md-sys-color-primary: #003321;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #005439;
    --md-sys-color-on-primary-container: #FFFFFF;
    --md-sys-color-secondary: #00332B;
    --md-sys-color-secondary-container: #245147;
    --md-sys-color-on-secondary-container: #FFFFFF;
    --md-sys-color-tertiary: #003232;
    --md-sys-color-tertiary-container: #005252;
    --md-sys-color-on-tertiary-container: #FFFFFF;
    --md-sys-color-error: #600004;
    --md-sys-color-error-container: #98000A;
    --md-sys-color-on-error-container: #FFFFFF;
    --md-sys-color-on-surface: #000000;
    --md-sys-color-on-surface-variant: #000000;
    --md-sys-color-surface-dim: #AFBCB3;
    --md-sys-color-surface-container-low: #E7F4EA;
    --md-sys-color-surface-container: #D9E6DC;
    --md-sys-color-surface-container-high: #CBD8CE;
    --md-sys-color-surface-container-highest: #BDCAC0;
    --md-sys-color-outline: #212F28;
    --md-sys-color-outline-variant: #3D4D44;
    --md-sys-color-warning-container: #FFDF9A;
    --md-sys-color-on-warning-container: #3B2A00;
  }
}

@media (prefers-color-scheme: dark) and (prefers-contrast: more) {
  :root {
    --md-sys-color-primary: #BAFFDB;
    --md-sys-color-on-primary: #000000;
    --md-sys-color-primary-container: #00DD9D;
    --md-sys-color-on-primary-container: #000E07;
    --md-sys-color-secondary: #CAFAED;
    --md-sys-color-secondary-container: #9ECCC0;
    --md-sys-color-on-secondary-container: #000E0B;
    --md-sys-color-tertiary: #B5FDFB;
    --md-sys-color-tertiary-container: #88CFCD;
    --md-sys-color-on-tertiary-container: #000E0E;
    --md-sys-color-error: #FFECE9;
    --md-sys-color-error-container: #FFAEA4;
    --md-sys-color-on-error-container: #220001;
    --md-sys-color-on-surface: #FFFFFF;
    --md-sys-color-on-surface-variant: #FFFFFF;
    --md-sys-color-surface-bright: #47534C;
    --md-sys-color-surface-container-lowest: #000000;
    --md-sys-color-surface-container-low: #17221C;
    --md-sys-color-surface-container: #27332C;
    --md-sys-color-surface-container-high: #323E37;
    --md-sys-color-surface-container-highest: #3E4942;
    --md-sys-color-outline: #E3F4E8;
    --md-sys-color-outline-variant: #B6C7BB;
    --md-sys-color-warning: #FFE9B4;
    --md-sys-color-warning-container: #CFA53A;
    --md-sys-color-on-warning-container: #120C00;
  }
}

/* ==========================================================================
   2. TYPOGRAPHY — the MD3 type scale
   ========================================================================== */

:root {
  --md-ref-typeface-brand: "Roboto Flex", "Roboto", -apple-system,
      BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --md-ref-typeface-plain: var(--md-ref-typeface-brand);
  /* Part numbers, article numbers, barcodes and label text are data: they get
     a face where 0 and O are not a matter of opinion. */
  --md-ref-typeface-mono: "Roboto Mono", ui-monospace, SFMono-Regular,
      "SF Mono", Menlo, Consolas, monospace;

  --md-sys-typescale-display-large: 400 57px/64px var(--md-ref-typeface-brand);
  --md-sys-typescale-display-medium: 400 45px/52px var(--md-ref-typeface-brand);
  --md-sys-typescale-display-small: 400 36px/44px var(--md-ref-typeface-brand);
  --md-sys-typescale-headline-large: 400 32px/40px var(--md-ref-typeface-brand);
  --md-sys-typescale-headline-medium: 400 28px/36px var(--md-ref-typeface-brand);
  --md-sys-typescale-headline-small: 400 24px/32px var(--md-ref-typeface-brand);
  --md-sys-typescale-title-large: 400 22px/28px var(--md-ref-typeface-brand);
  --md-sys-typescale-title-medium: 500 16px/24px var(--md-ref-typeface-plain);
  --md-sys-typescale-title-small: 500 14px/20px var(--md-ref-typeface-plain);
  --md-sys-typescale-body-large: 400 16px/24px var(--md-ref-typeface-plain);
  --md-sys-typescale-body-medium: 400 14px/20px var(--md-ref-typeface-plain);
  --md-sys-typescale-body-small: 400 12px/16px var(--md-ref-typeface-plain);
  --md-sys-typescale-label-large: 500 14px/20px var(--md-ref-typeface-plain);
  --md-sys-typescale-label-medium: 500 12px/16px var(--md-ref-typeface-plain);
  --md-sys-typescale-label-small: 500 11px/16px var(--md-ref-typeface-plain);

  /* Expressive emphasis: same size, more weight. */
  --md-sys-typescale-title-large-emphasized: 500 22px/28px var(--md-ref-typeface-brand);
  --md-sys-typescale-headline-small-emphasized: 500 24px/32px var(--md-ref-typeface-brand);
  --md-sys-typescale-label-large-emphasized: 700 14px/20px var(--md-ref-typeface-plain);

  --md-sys-typescale-title-medium-tracking: .15px;
  --md-sys-typescale-body-large-tracking: .5px;
  --md-sys-typescale-body-medium-tracking: .25px;
  --md-sys-typescale-body-small-tracking: .4px;
  --md-sys-typescale-label-large-tracking: .1px;
  --md-sys-typescale-label-medium-tracking: .5px;
}

/* ==========================================================================
   3. SHAPE, ELEVATION, MOTION, SPACING
   ========================================================================== */

:root {
  --md-sys-shape-corner-none: 0px;
  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-large-increased: 20px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-extra-large-increased: 32px;
  --md-sys-shape-corner-extra-extra-large: 48px;
  --md-sys-shape-corner-full: 9999px;

  /* MD3 elevation is tonal first: the surface-container ramp carries it, and
     these shadows only add the separation a busy background needs. */
  --md-sys-elevation-level0: none;
  --md-sys-elevation-level1: 0 1px 2px 0 rgba(0, 0, 0, .30), 0 1px 3px 1px rgba(0, 0, 0, .15);
  --md-sys-elevation-level2: 0 1px 2px 0 rgba(0, 0, 0, .30), 0 2px 6px 2px rgba(0, 0, 0, .15);
  --md-sys-elevation-level3: 0 1px 3px 0 rgba(0, 0, 0, .30), 0 4px 8px 3px rgba(0, 0, 0, .15);
  --md-sys-elevation-level4: 0 2px 3px 0 rgba(0, 0, 0, .30), 0 6px 10px 4px rgba(0, 0, 0, .15);
  --md-sys-elevation-level5: 0 4px 4px 0 rgba(0, 0, 0, .30), 0 8px 12px 6px rgba(0, 0, 0, .15);

  /* MD3 state layer opacities */
  --md-sys-state-hover-opacity: 8%;
  --md-sys-state-focus-opacity: 10%;
  --md-sys-state-pressed-opacity: 10%;
  --md-sys-state-dragged-opacity: 16%;
  --md-sys-state-disabled-container-opacity: 12%;
  --md-sys-state-disabled-content-opacity: 38%;

  --md-sys-motion-easing-emphasized: cubic-bezier(.2, 0, 0, 1);
  --md-sys-motion-easing-emphasized-decelerate: cubic-bezier(.05, .7, .1, 1);
  --md-sys-motion-easing-emphasized-accelerate: cubic-bezier(.3, 0, .8, .15);
  --md-sys-motion-easing-standard: cubic-bezier(.2, 0, 0, 1);
  --md-sys-motion-easing-standard-decelerate: cubic-bezier(0, 0, 0, 1);
  --md-sys-motion-easing-standard-accelerate: cubic-bezier(.3, 0, 1, 1);
  --md-sys-motion-duration-short4: 200ms;
  --md-sys-motion-duration-medium1: 250ms;
  --md-sys-motion-duration-medium2: 300ms;
  --md-sys-motion-duration-long2: 500ms;

  /* MD3 8dp spacing system */
  --md-sys-spacing-1: 4px;
  --md-sys-spacing-2: 8px;
  --md-sys-spacing-3: 12px;
  --md-sys-spacing-4: 16px;
  --md-sys-spacing-6: 24px;
  --md-sys-spacing-8: 32px;
  --md-sys-spacing-10: 40px;

  /* Large window class: content stops at a readable measure rather than
     stretching to the edge of a 32" monitor. */
  --md-page-max: 1040px;
  --md-top-app-bar-height: 64px;
}

/* ---- legacy aliases -------------------------------------------------------
 * A handful of templates carry inline `style="color:var(--slate-700)"` and
 * friends. Rather than edit twelve files to chase them, the old names are
 * kept and pointed at their MD3 equivalents, so nothing renders as an
 * unstyled default while the markup stays untouched.
 */
:root {
  --slate-950: var(--md-sys-color-surface);
  --slate-900: var(--md-sys-color-surface-container-low);
  --slate-850: var(--md-sys-color-surface-container);
  --slate-800: var(--md-sys-color-surface-container-high);
  --slate-750: var(--md-sys-color-surface-container-highest);
  --slate-700: var(--md-sys-color-outline-variant);
  --slate-600: var(--md-sys-color-outline);
  --slate-400: var(--md-sys-color-on-surface-variant);
  --slate-300: var(--md-sys-color-on-surface-variant);
  --slate-200: var(--md-sys-color-on-surface);
  --slate-050: var(--md-sys-color-on-surface);
  --bg: var(--md-sys-color-surface);
  --bg-sunken: var(--md-sys-color-surface-container-lowest);
  --surface: var(--md-sys-color-surface-container-low);
  --surface-2: var(--md-sys-color-surface-container);
  --surface-3: var(--md-sys-color-surface-container-high);
  --line: var(--md-sys-color-outline-variant);
  --line-strong: var(--md-sys-color-outline);
  --text: var(--md-sys-color-on-surface);
  --text-2: var(--md-sys-color-on-surface-variant);
  --muted: var(--md-sys-color-on-surface-variant);
  --accent: var(--md-sys-color-primary);
  --accent-strong: var(--md-sys-color-primary);
  --accent-ink: var(--md-sys-color-on-primary);
  --accent-soft: var(--md-sys-color-primary-container);
  --accent-line: var(--md-sys-color-primary);
  --good: var(--md-sys-color-primary);
  --warn: var(--md-sys-color-warning);
  --bad: var(--md-sys-color-error);
  --info: var(--md-sys-color-tertiary);
  --radius-sm: var(--md-sys-shape-corner-small);
  --radius: var(--md-sys-shape-corner-medium);
  --radius-lg: var(--md-sys-shape-corner-large);
  --radius-pill: var(--md-sys-shape-corner-full);
  --font: var(--md-ref-typeface-plain);
  --mono: var(--md-ref-typeface-mono);
  --page: var(--md-page-max);
  --space-1: var(--md-sys-spacing-1);
  --space-2: var(--md-sys-spacing-2);
  --space-3: var(--md-sys-spacing-3);
  --space-4: var(--md-sys-spacing-4);
  --space-5: var(--md-sys-spacing-6);
  --space-6: var(--md-sys-spacing-8);
  --fast: var(--md-sys-motion-duration-short4);
  --base: var(--md-sys-motion-duration-medium2);
  --ease: var(--md-sys-motion-easing-standard);
  --shadow-1: var(--md-sys-elevation-level1);
  --shadow-2: var(--md-sys-elevation-level2);
  --shadow-3: var(--md-sys-elevation-level3);
}

/* ==========================================================================
   4. BASELINE
   ========================================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-large);
  letter-spacing: var(--md-sys-typescale-body-large-tracking);
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--md-sys-color-primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

/* One visible focus style for everything, and never taken away: this gets used
   with a label in one hand and a keyboard in the other. */
:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
  border-radius: var(--md-sys-shape-corner-small);
}
:focus:not(:focus-visible) { outline: none; }
::selection {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

/* first tab stop on every page */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  padding: 14px 24px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font: var(--md-sys-typescale-label-large);
  border-radius: 0 0 var(--md-sys-shape-corner-large) 0;
  box-shadow: var(--md-sys-elevation-level3);
}
.skip:focus { left: 0; }

/* ==========================================================================
   5. TOP APP BAR (MD3 small) + navigation
   ========================================================================== */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--md-sys-spacing-2);
  min-height: var(--md-top-app-bar-height);
  padding: var(--md-sys-spacing-2) max(var(--md-sys-spacing-4), env(safe-area-inset-right))
           var(--md-sys-spacing-2) max(var(--md-sys-spacing-4), env(safe-area-inset-left));
  /* MD3: an app bar over scrolled content rises to surface-container. Without
     a scroll listener, the tonal step is taken up front — it reads as the
     same elevation the spec asks for and never flickers. */
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}

.brand {
  display: inline-flex; align-items: center; gap: var(--md-sys-spacing-2);
  font: var(--md-sys-typescale-title-large-emphasized);
  color: var(--md-sys-color-on-surface);
}
.brand:hover { text-decoration: none; color: var(--md-sys-color-on-surface); }
.brand svg { color: var(--md-sys-color-primary); flex: 0 0 auto; }

.topbar nav {
  display: flex; align-items: center; gap: var(--md-sys-spacing-1); flex-wrap: wrap;
}
/* On a wide window the wrapper should not exist at all. */
.navlinks { display: contents; }

/* MD3 text button, sized as a navigation destination */
.navlink {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 10px 16px;
  border: none; border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  color: var(--md-sys-color-on-surface-variant);
  background: transparent;
  transition: color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
              background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
/* state layer */
.navlink::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; background: currentColor; opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.navlink:hover { color: var(--md-sys-color-on-surface); text-decoration: none; }
.navlink:hover::before { opacity: .08; }
.navlink:active::before { opacity: .1; }

/* The current destination: MD3 secondary-container pill. */
.navlink.active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

/* Scan is why the phone is out of the pocket — MD3 filled button. */
.navlink.primary {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font: var(--md-sys-typescale-label-large-emphasized);
  box-shadow: var(--md-sys-elevation-level0);
}
.navlink.primary:hover {
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-level1);
}
.navlink.primary::before { background: var(--md-sys-color-on-primary); }

main {
  max-width: var(--md-page-max); margin: 0 auto;
  padding: var(--md-sys-spacing-6) var(--md-sys-spacing-4) 80px;
}

.foot {
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-small);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  padding: 0 var(--md-sys-spacing-4)
           calc(var(--md-sys-spacing-8) + env(safe-area-inset-bottom));
}

/* ==========================================================================
   6. TYPE IN CONTENT
   ========================================================================== */

h1 {
  font: var(--md-sys-typescale-headline-small-emphasized);
  color: var(--md-sys-color-on-surface);
  margin: 0 0 var(--md-sys-spacing-4);
}
h2 {
  font: var(--md-sys-typescale-title-medium);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
  color: var(--md-sys-color-on-surface);
  margin: 0 0 var(--md-sys-spacing-3);
}
p { margin: 0 0 var(--md-sys-spacing-3); }

code, pre, .mono { font-family: var(--md-ref-typeface-mono); }
code {
  font-size: .9em;
  color: var(--md-sys-color-on-surface);
}

.muted { color: var(--md-sys-color-on-surface-variant); }
.small {
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
}

/* ==========================================================================
   7. CARDS (MD3 filled card + elevated variant)
   ========================================================================== */

.card {
  background: var(--md-sys-color-surface-container-low);
  border: none;
  border-radius: var(--md-sys-shape-corner-medium);
  padding: var(--md-sys-spacing-4);
  margin-bottom: var(--md-sys-spacing-4);
  box-shadow: var(--md-sys-elevation-level0);
}

.row { display: flex; gap: var(--md-sys-spacing-3); flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.grow { flex: 1 1 180px; }

/* ==========================================================================
   8. TEXT FIELDS
   --------------------------------------------------------------------------
   `label.field` wraps a <span> caption and then the control — exactly the
   shape of an MD3 *filled* text field, so that is what it becomes: tinted
   container, small label above the value, and an underline that thickens to
   the primary colour on focus. Bare inputs elsewhere get the *outlined*
   variant.
   ========================================================================== */

/* ---- outlined text field (the default) ---- */
input[type=text], input[type=number], input[type=search], input[type=password],
input:not([type]), select, textarea {
  width: 100%;
  min-height: 56px;
  padding: 16px;
  font: var(--md-sys-typescale-body-large);
  letter-spacing: var(--md-sys-typescale-body-large-tracking);
  color: var(--md-sys-color-on-surface);
  background: transparent;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  transition: border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
              background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
input::placeholder, textarea::placeholder {
  color: var(--md-sys-color-on-surface-variant); opacity: 1;
}
input:hover, select:hover, textarea:hover { border-color: var(--md-sys-color-on-surface); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);   /* the 2dp focus outline */
}
input:disabled, select:disabled, textarea:disabled {
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
  border-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
}

/* data, not prose */
input[name=model], input[name=barcode], input[name=article_no], input[name=query] {
  font-family: var(--md-ref-typeface-mono);
}
textarea { resize: vertical; min-height: 96px; line-height: 24px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
  background-size: 20px;
  padding-right: 44px;
  cursor: pointer;
}

/* ---- filled text field ---- */
label.field {
  display: block;
  position: relative;
  margin-bottom: var(--md-sys-spacing-4);
  background: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-extra-small) var(--md-sys-shape-corner-extra-small) 0 0;
  border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
  padding: 8px 16px 0;
  transition: background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
              border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
label.field:hover { border-bottom-color: var(--md-sys-color-on-surface); }
label.field:focus-within {
  border-bottom-color: var(--md-sys-color-primary);
  box-shadow: inset 0 -1px 0 0 var(--md-sys-color-primary);  /* 2dp active indicator */
}
label.field > span {
  display: block;
  font: var(--md-sys-typescale-body-small);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 0;
}
label.field:focus-within > span { color: var(--md-sys-color-primary); }
label.field > input, label.field > textarea, label.field > select {
  min-height: 32px;
  padding: 2px 0 8px;
  border: none; border-radius: 0;
  background: transparent;
}
label.field > input:hover, label.field > textarea:hover, label.field > select:hover {
  border: none;
}
label.field > input:focus, label.field > textarea:focus, label.field > select:focus {
  border: none; box-shadow: none;
}
label.field > textarea { min-height: 88px; padding-bottom: 12px; }
label.field > select { padding-right: 32px; background-position: right 0 center; }

/* Sign-in and Accounts wrap a text node, not a span. Those stay outlined, but
   the caption gets MD3 label styling and a little air. */
.authcard label, .card > form > label {
  display: block;
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 0 var(--md-sys-spacing-4);
}

/* Checkboxes and radios in the app's colour, not the browser's blue.
   Several templates carry an inline `style="width:auto"` on these, and an
   inline style beats any stylesheet rule — so the size is set with min-width
   and min-height, which `width:auto` cannot undo. */
input[type=checkbox], input[type=radio] {
  accent-color: var(--md-sys-color-primary);
  min-width: 20px; min-height: 20px; cursor: pointer;
  border: none; padding: 0; margin: 0;
  flex: 0 0 auto;
}
@media (pointer: coarse) {
  input[type=checkbox], input[type=radio] { min-width: 24px; min-height: 24px; }
}

fieldset.bare, .bare { border: 0; padding: 0; margin: 0; min-width: 0; }
.bare:disabled { opacity: .75; }

/* ==========================================================================
   9. BUTTONS (MD3: outlined / filled / text / tonal, corner-full)
   ========================================================================== */

.btn {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 10px 24px;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  border: 1px solid var(--md-sys-color-outline);
  background: transparent;
  color: var(--md-sys-color-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
              border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
              box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
/* MD3 state layer: a tint of the label colour, not a different background */
.btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; background: currentColor; opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.btn:hover { text-decoration: none; }
.btn:hover::before { opacity: .08; }
.btn:focus-visible::before { opacity: .1; }
.btn:active::before { opacity: .1; }
.btn:focus-visible { border-color: var(--md-sys-color-primary); }

/* filled */
.btn.primary {
  background: var(--md-sys-color-primary);
  border-color: transparent;
  color: var(--md-sys-color-on-primary);
}
.btn.primary:hover { box-shadow: var(--md-sys-elevation-level1); }
.btn.primary:active { box-shadow: var(--md-sys-elevation-level0); }

/* text */
.btn.ghost {
  background: transparent; border-color: transparent;
  color: var(--md-sys-color-primary);
  padding-left: 12px; padding-right: 12px;
}

/* error, as a tonal button */
.btn.danger {
  background: var(--md-sys-color-error-container);
  border-color: transparent;
  color: var(--md-sys-color-on-error-container);
}
.btn.danger:hover { box-shadow: var(--md-sys-elevation-level1); }

.btn.block { width: 100%; }

/* MD3 extra-small button — the quantity steppers */
.btn.tiny {
  min-height: 32px; min-width: 32px; padding: 6px 12px;
  font: var(--md-sys-typescale-label-large);
  border-radius: var(--md-sys-shape-corner-full);
}

.btn:disabled, .btn[disabled] {
  cursor: not-allowed; box-shadow: none;
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
  border-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
}
.btn.primary:disabled, .btn.danger:disabled {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
}
.btn:disabled::before { opacity: 0 !important; }

/* A finger is not a mouse: MD3 asks for a 48dp touch target. Where a control
   is meant to stay visually small — the quantity steppers in a list row — the
   target is grown past the button instead of the button being grown, which is
   what Material Web's own `--md-*-touch-target` does. */
@media (pointer: coarse) {
  .btn { min-height: 48px; }
  .btn.tiny { min-height: 40px; min-width: 40px; }
  .btn.tiny::after {
    content: ""; position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: max(100%, 48px); height: 48px;
  }
  .navlink { min-height: 48px; }
}

/* MD3 text button, rendered from a <button> that is really a link */
.linkish {
  position: relative; isolation: isolate;
  background: none; border: 0; cursor: pointer;
  min-height: 40px; padding: 10px 12px;
  color: var(--md-sys-color-primary);
  font: var(--md-sys-typescale-label-large);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  border-radius: var(--md-sys-shape-corner-full);
  transition: background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.linkish::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; background: currentColor; opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.linkish:hover { text-decoration: none; }
.linkish:hover::before { opacity: .08; }
@media (pointer: coarse) { .linkish { min-height: 48px; } }

/* ==========================================================================
   10. CHIPS (MD3 assist / filter chip)
   ========================================================================== */

.pill, .chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 6px 12px;
  border-radius: var(--md-sys-shape-corner-small);
  font: var(--md-sys-typescale-label-large);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  background: transparent;
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
}
.pill.good {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: transparent;
}
.pill.warn {
  background: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-on-warning-container);
  border-color: transparent;
}
.pill.bad {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-color: transparent;
}
/* the clickable part-number chips on the review page */
code.pill { font-family: var(--md-ref-typeface-mono); font-size: 13px; }
code.pill:hover {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

/* ==========================================================================
   11. BANNERS
   --------------------------------------------------------------------------
   MD3 has no inline banner. This is the closest honest thing: a filled card in
   the matching container role, with a leading bar so anyone who does not read
   the colour still gets the message.
   ========================================================================== */

.banner {
  position: relative;
  padding: var(--md-sys-spacing-4);
  padding-left: calc(var(--md-sys-spacing-4) + 4px);
  border-radius: var(--md-sys-shape-corner-medium);
  margin-bottom: var(--md-sys-spacing-4);
  border: none;
  border-left: 4px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
}
.banner strong { color: var(--md-sys-color-on-surface); font-weight: 500; }
.banner code { color: var(--md-sys-color-on-surface); }

/* primary-container in this scheme is a very saturated mint — right for a
   chip, a highlighter pen across the full width of the page. The banner takes
   the softer secondary container and keeps the primary colour in its bar. */
.banner.good {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-left-color: var(--md-sys-color-primary);
}
.banner.good strong, .banner.good code { color: var(--md-sys-color-on-secondary-container); }

.banner.bad, .banner.error {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-left-color: var(--md-sys-color-error);
}
.banner.bad strong, .banner.error strong,
.banner.bad code, .banner.error code { color: var(--md-sys-color-on-error-container); }

.banner.warn {
  background: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-on-warning-container);
  border-left-color: var(--md-sys-color-warning);
}
.banner.warn strong, .banner.warn a { color: var(--md-sys-color-on-warning-container); }

/* a run still going, shown on every page so it cannot be lost */
/* A run in progress is not a result, so it takes the third container role and
   stays visually apart from "identified" and "went wrong". */
.banner.running-job {
  display: flex; align-items: center; gap: var(--md-sys-spacing-3); flex-wrap: wrap;
  background: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
  border-left-color: var(--md-sys-color-tertiary);
}
.banner.running-job strong { color: var(--md-sys-color-on-tertiary-container); }
.banner.running-job .btn {
  margin-left: auto;
  color: var(--md-sys-color-on-tertiary-container);
  border-color: var(--md-sys-color-on-tertiary-container);
}

.warn-text { color: var(--md-sys-color-warning); font-weight: 500; }

/* ==========================================================================
   12. SEARCH BAR + TOOLBAR
   ========================================================================== */

.toolbar {
  position: sticky; top: var(--md-top-app-bar-height); z-index: 10;
  display: flex; gap: var(--md-sys-spacing-2); flex-wrap: wrap;
  margin: 0 0 var(--md-sys-spacing-4);
  padding: var(--md-sys-spacing-2) 0;
  background: linear-gradient(var(--md-sys-color-surface) 76%, transparent);
}
.toolbar .grow { flex: 1 1 280px; }

/* MD3 search bar: full round, tonal, no outline */
.searchwrap { position: relative; display: block; }
.searchwrap svg {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px;
  color: var(--md-sys-color-on-surface-variant); pointer-events: none;
}
.searchwrap input, .toolbar input[type=search] {
  min-height: 56px;
  background: var(--md-sys-color-surface-container-high);
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  padding: 16px 24px;
}
/* Specificity, not order: the rule above also matches as
   `.toolbar input[type=search]` (0,2,1), which outranks a bare
   `.searchwrap input` (0,1,1) and would leave the icon sitting on the text. */
.toolbar .searchwrap input, .searchwrap input[type=search] { padding-left: 52px; }
.searchwrap input:hover, .toolbar input[type=search]:hover {
  border: none;
  background: var(--md-sys-color-surface-container-highest);
}
.searchwrap input:focus, .toolbar input[type=search]:focus {
  border: none; box-shadow: none;
  background: var(--md-sys-color-surface-container-highest);
  outline: 3px solid var(--md-sys-color-primary); outline-offset: -3px;
}

/* the two dropdowns beside it read as filter chips, not text fields */
.toolbar select {
  min-height: 48px;
  padding: 12px 44px 12px 16px;
  border-radius: var(--md-sys-shape-corner-small);
  border: 1px solid var(--md-sys-color-outline);
  font: var(--md-sys-typescale-label-large);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  background-color: transparent;
  background-position: right 12px center;
}
.toolbar .btn { min-height: 48px; }

.stats {
  display: flex; gap: var(--md-sys-spacing-6); flex-wrap: wrap;
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  margin: 0 0 var(--md-sys-spacing-4);
  padding-bottom: var(--md-sys-spacing-3);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.stats span { font-variant-numeric: tabular-nums; }
.stats strong {
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-title-medium);
}

/* ==========================================================================
   13. LIST ITEMS (MD3 list, three-line, in a filled container)
   ========================================================================== */

.rows { display: flex; flex-direction: column; gap: var(--md-sys-spacing-2); }

.item {
  position: relative; isolation: isolate;
  display: flex; align-items: center; gap: var(--md-sys-spacing-4); width: 100%;
  background: var(--md-sys-color-surface-container-low);
  border: none;
  border-radius: var(--md-sys-shape-corner-medium);
  padding: var(--md-sys-spacing-2) var(--md-sys-spacing-4) var(--md-sys-spacing-2) var(--md-sys-spacing-2);
  transition: background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
              box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.item:hover {
  background: var(--md-sys-color-surface-container);
  box-shadow: var(--md-sys-elevation-level1);
}
.item:focus-within { outline: 2px solid var(--md-sys-color-primary); outline-offset: 1px; }

.rowshot {
  flex: 0 0 auto; width: 112px; height: 84px;
  border-radius: var(--md-sys-shape-corner-small); overflow: hidden;
  background: var(--md-sys-color-surface-container-highest);
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-in; line-height: 0;
  transition: box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.rowshot:hover { box-shadow: inset 0 0 0 2px var(--md-sys-color-primary); }
.rowshot img { width: 100%; height: 100%; object-fit: cover; }
.rowshot.empty-shot {
  color: var(--md-sys-color-outline); cursor: default;
  background: var(--md-sys-color-surface-container);
}
.rowshot.empty-shot:hover { box-shadow: none; }

.item .body {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; gap: var(--md-sys-spacing-1);
}
.item .name {
  display: block;
  font: var(--md-sys-typescale-title-medium);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
  color: var(--md-sys-color-on-surface);
}
.item .name:hover { color: var(--md-sys-color-primary); text-decoration: none; }
.item .meta {
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
}
.item .meta code { font-size: 13px; color: var(--md-sys-color-on-surface); }

.chips { display: flex; flex-wrap: wrap; gap: var(--md-sys-spacing-1); margin-top: 2px; }
.chips .pill, .chips .chip {
  min-height: 24px; padding: 2px 8px;
  font: var(--md-sys-typescale-label-medium);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  background: var(--md-sys-color-surface-container-high);
  border-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
}

/* MD3 connected button group */
.rowqty { flex: 0 0 auto; display: flex; align-items: center; gap: var(--md-sys-spacing-2); }
.qty {
  display: flex; align-items: center; gap: 2px;
  background: var(--md-sys-color-surface-container-high);
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  padding: 4px;
}
.qty form { display: inline-flex; }
.qty .btn.tiny {
  border-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
}
.qty .btn.tiny:hover { color: var(--md-sys-color-primary); }
.qty .n {
  min-width: 32px; text-align: center;
  font: var(--md-sys-typescale-title-medium);
  font-family: var(--md-ref-typeface-mono);
  font-variant-numeric: tabular-nums;
  color: var(--md-sys-color-on-surface);
}

.item.binned { opacity: .62; }
.item.binned .name {
  text-decoration: line-through;
  text-decoration-color: var(--md-sys-color-on-surface-variant);
}

.empty {
  text-align: center;
  padding: var(--md-sys-spacing-10) var(--md-sys-spacing-4);
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-large);
  border: 1px dashed var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface-container-lowest);
}
.empty svg { color: var(--md-sys-color-outline-variant); }

/* your own article number: the thing you actually look for on a shelf */
.artno {
  display: inline-block; padding: 2px 8px; margin-right: 6px;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-family: var(--md-ref-typeface-mono);
  font-size: 12px; font-weight: 500;
  vertical-align: 1px;
}

/* MD3 large badge */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; margin-left: 2px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
  font: var(--md-sys-typescale-label-small);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.navlink.active .badge { background: var(--md-sys-color-error); }

/* ==========================================================================
   14. DETAIL / REVIEW — panes, photos, key-value
   ========================================================================== */

/* MD3 supporting-pane layout: two panes at Medium and up, one at Compact. */
.two {
  display: grid; gap: var(--md-sys-spacing-4);
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
}
@media (max-width: 839px) { .two { grid-template-columns: 1fr; } }

/* fit-content, not block: the photo caps at 360px, and a full-width anchor
   would leave the expand button stranded in the empty space beside it once
   the layout drops to one column. */
.shot {
  display: block; width: fit-content; max-width: 100%;
  position: relative; line-height: 0; cursor: zoom-in;
}
.shot .photo, .photo {
  width: 100%; max-width: 360px; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--md-sys-shape-corner-medium);
  border: none;
  background: var(--md-sys-color-surface-container-highest);
  transition: box-shadow var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized),
              transform var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
}
.shot:hover .photo {
  box-shadow: var(--md-sys-elevation-level2);
  transform: scale(1.01);
}
/* MD3 filled tonal icon button, floated over the image */
.shot::after {
  content: ""; position: absolute; right: 12px; bottom: 12px;
  width: 40px; height: 40px; border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-secondary-container) center / 20px no-repeat
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23214E45' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='15 3 21 3 21 9'/><polyline points='9 21 3 21 3 15'/><line x1='21' y1='3' x2='14' y2='10'/><line x1='3' y1='21' x2='10' y2='14'/></svg>");
  box-shadow: var(--md-sys-elevation-level1);
}
@media (prefers-color-scheme: dark) {
  .shot::after {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23BDECDF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='15 3 21 3 21 9'/><polyline points='9 21 3 21 3 15'/><line x1='21' y1='3' x2='14' y2='10'/><line x1='3' y1='21' x2='10' y2='14'/></svg>");
  }
}
.shot-caption {
  font: var(--md-sys-typescale-body-small);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  color: var(--md-sys-color-on-surface-variant);
  margin: var(--md-sys-spacing-2) 0 0;
}

.kv {
  display: grid; grid-template-columns: 128px 1fr;
  gap: var(--md-sys-spacing-2) var(--md-sys-spacing-3);
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
}
.kv dt { color: var(--md-sys-color-on-surface-variant); }
.kv dd { margin: 0; word-break: break-word; color: var(--md-sys-color-on-surface); }

pre.ocr {
  white-space: pre-wrap; word-break: break-word;
  background: var(--md-sys-color-surface-container-lowest);
  border: none;
  border-radius: var(--md-sys-shape-corner-small);
  padding: var(--md-sys-spacing-3);
  font-family: var(--md-ref-typeface-mono);
  font-size: 12px; line-height: 1.6;
  color: var(--md-sys-color-on-surface-variant);
  max-height: 240px; overflow: auto;
}

details summary {
  cursor: pointer;
  color: var(--md-sys-color-primary);
  font: var(--md-sys-typescale-label-large);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  padding: var(--md-sys-spacing-2) 0;
  min-height: 40px; display: flex; align-items: center;
}
details summary:hover { color: var(--md-sys-color-primary); text-decoration: underline; }
@media (pointer: coarse) { details summary { min-height: 48px; } }

/* ==========================================================================
   15. FULL-SCREEN DIALOG (the lightbox)
   ========================================================================== */

#lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: color-mix(in srgb, var(--md-sys-color-scrim) 60%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--md-sys-spacing-6);
  cursor: zoom-out;
  animation: md-fade var(--md-sys-motion-duration-medium1)
             var(--md-sys-motion-easing-emphasized-decelerate);
}
#lightbox[hidden] { display: none; }
#lightbox img {
  max-width: 100%; max-height: calc(100dvh - 140px); object-fit: contain;
  border-radius: var(--md-sys-shape-corner-extra-large);
  cursor: default;
  box-shadow: var(--md-sys-elevation-level5);
}
/* MD3 filled tonal icon button */
#lightbox-close {
  position: absolute; top: 16px; right: 16px;
  width: 48px; height: 48px;
  border-radius: var(--md-sys-shape-corner-full);
  border: none;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--md-sys-elevation-level1);
  transition: background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
#lightbox-close:hover { background: var(--md-sys-color-secondary); color: var(--md-sys-color-on-secondary); }
#lightbox-bar {
  position: absolute; bottom: 20px; left: 0; right: 0; text-align: center;
  font: var(--md-sys-typescale-label-large);
}
#lightbox-bar a { color: var(--md-sys-color-inverse-primary); }
@media (prefers-color-scheme: dark) { #lightbox-bar a { color: var(--md-sys-color-primary); } }

/* ==========================================================================
   16. SCAN — drop target, previews
   ========================================================================== */

.dropzone {
  display: block; position: relative;
  border: 2px dashed var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: var(--md-sys-spacing-8) var(--md-sys-spacing-4);
  text-align: center;
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-large);
  cursor: pointer;
  transition: border-color var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized),
              background-color var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
}
.dropzone strong { color: var(--md-sys-color-on-surface); font-weight: 500; }
.dropzone:hover, .dropzone.hot {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container-high);
}
.dropzone.hot { border-style: solid; }
.dropzone .icon {
  display: block; color: var(--md-sys-color-primary);
  line-height: 0; margin-bottom: var(--md-sys-spacing-3);
}
.dropzone .icon svg { width: 48px; height: 48px; }
.dropzone input { display: none; }

#preview-strip {
  display: flex; flex-wrap: wrap; gap: var(--md-sys-spacing-2);
  justify-content: center; align-items: center;
  margin-top: var(--md-sys-spacing-4);
}
#preview-strip img {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: var(--md-sys-shape-corner-small);
  border: none;
  box-shadow: var(--md-sys-elevation-level1);
}

/* MD3 segmented button — where the vision model runs */
.modelswitch {
  margin: var(--md-sys-spacing-4) 0 var(--md-sys-spacing-1);
  padding-top: var(--md-sys-spacing-4);
  border-top: 1px solid var(--md-sys-color-outline-variant);
}
.seg {
  display: inline-flex; flex-wrap: wrap;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
}
.seg label {
  min-height: 40px;
  display: inline-flex; align-items: center;
  padding: 10px 20px;
  cursor: pointer;
  font: var(--md-sys-typescale-label-large);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  color: var(--md-sys-color-on-surface);
  border-right: 1px solid var(--md-sys-color-outline);
  transition: background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.seg label:last-of-type { border-right: none; }
.seg label:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent); }
.seg label.on {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg label:focus-within { outline: 3px solid var(--md-sys-color-primary); outline-offset: -3px; }
@media (pointer: coarse) { .seg label { min-height: 48px; } }

/* the five pieces of work, and where each one happens */
.where {
  width: 100%; border-collapse: collapse;
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
}
.where td {
  padding: var(--md-sys-spacing-3) var(--md-sys-spacing-3) var(--md-sys-spacing-3) 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  vertical-align: middle;
}
.where tr:last-child td { border-bottom: 0; }
.where td:first-child { font-weight: 500; white-space: nowrap; color: var(--md-sys-color-on-surface); }
.where td:nth-child(2) { width: 1%; white-space: nowrap; }
.where td:last-child { color: var(--md-sys-color-on-surface-variant); }
@media (max-width: 599px) {
  .where td:last-child { display: none; }   /* the detail is the first to go */
}

/* ==========================================================================
   17. PROGRESS (MD3 linear + circular)
   ========================================================================== */

.bar-track {
  position: relative;
  height: 4px; border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-secondary-container);
  border: none; overflow: hidden;
  margin: var(--md-sys-spacing-4) 0 0;
}
.bar-fill {
  height: 100%;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  transition: width var(--md-sys-motion-duration-long2) var(--md-sys-motion-easing-emphasized);
}
/* MD3 stop indicator at the end of the track */
.bar-track::after {
  content: ""; position: absolute; right: 0; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--md-sys-color-primary);
}

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: currentColor;
  border-right-color: currentColor;
  animation: md-spin 1.2s var(--md-sys-motion-easing-standard) infinite;
  display: inline-block;
  vertical-align: -4px;
}
@keyframes md-spin { to { transform: rotate(360deg); } }
@keyframes md-fade { from { opacity: 0 } to { opacity: 1 } }

/* batch progress headline */
#headline {
  font: var(--md-sys-typescale-headline-small-emphasized) !important;
  color: var(--md-sys-color-on-surface);
  font-variant-numeric: tabular-nums;
}
#panel { background: var(--md-sys-color-surface-container); }

/* ==========================================================================
   18. LOGS
   ========================================================================== */

#logbox {
  font-family: var(--md-ref-typeface-mono);
  font-size: 12px; line-height: 1.6;
  color: var(--md-sys-color-on-surface-variant);
}
#logbox span { display: block; }
#logbox .lg-warn { color: var(--md-sys-color-warning); }
#logbox .lg-err { color: var(--md-sys-color-error); }

/* ==========================================================================
   19. DESTRUCTIVE AREA
   ========================================================================== */

/* MD3 uses the error container for something that has gone wrong *now*. This
   section is always on the page, so it is an outlined container in the error
   colour instead — present, unmissable, and not shouting at you while you
   count stock. The button inside it carries the full emphasis. */
.danger-zone {
  margin-top: var(--md-sys-spacing-8);
  padding: var(--md-sys-spacing-4);
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-error);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
}
.danger-zone h2 {
  margin: 0 0 var(--md-sys-spacing-1);
  color: var(--md-sys-color-error);
  font: var(--md-sys-typescale-title-medium);
}
.danger-zone .muted { color: var(--md-sys-color-on-surface-variant); }
.danger-zone .btn.danger {
  background: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
}

/* ==========================================================================
   20. ACCOUNTS / AUTH
   ========================================================================== */

.whoami {
  display: flex; align-items: center; gap: var(--md-sys-spacing-1);
  margin-left: var(--md-sys-spacing-2);
}
/* MD3 input chip, standing in for an avatar */
.who {
  display: inline-flex; align-items: center;
  min-height: 32px; padding: 6px 12px;
  font: var(--md-sys-typescale-label-large);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  background: transparent;
}

/* MD3 elevated card, at dialog radius */
.authcard {
  max-width: 440px; margin: 8vh auto 0;
  padding: var(--md-sys-spacing-6);
  background: var(--md-sys-color-surface-container-low);
  border: none;
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-level1);
}
.authcard h1 { margin-top: 0; font: var(--md-sys-typescale-headline-small-emphasized); }
.authcard label input[type=text], .authcard label input:not([type=checkbox]) {
  display: block; width: 100%; margin-top: var(--md-sys-spacing-2);
}
.authcard label.check, label.check {
  display: flex; align-items: center; gap: var(--md-sys-spacing-3);
  min-height: 48px;
}
.authcard label.check input, label.check input { width: auto; margin: 0; }
.authcard .btn { width: 100%; }
.authcard .btn + .btn { margin-top: var(--md-sys-spacing-2); }

/* ==========================================================================
   21. RESPONSIVE — MD3 window size classes
   --------------------------------------------------------------------------
   Compact  < 600dp   one pane, nav scrolls in its own lane
   Medium   600–839   two panes appear
   Expanded 840–1199  full layout
   Large    1200+     content stops at --md-page-max, it does not stretch
   ========================================================================== */

@media (max-width: 599px) {
  main { padding: var(--md-sys-spacing-4) var(--md-sys-spacing-4) 72px; }
  h1 { font: var(--md-sys-typescale-title-large-emphasized); }

  .topbar {
    padding: var(--md-sys-spacing-2) var(--md-sys-spacing-2);
    flex-wrap: wrap;
    min-height: 56px;
  }
  .brand { font: var(--md-sys-typescale-title-medium); padding-left: 4px; }

  /* Links scroll sideways in their own lane; Scan and Sign out keep their
     place, because a nav that grows a third row pushes the stock off screen
     and a Scan button that scrolls away is a Scan button you cannot press. */
  .topbar nav {
    width: 100%;
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center; gap: var(--md-sys-spacing-1);
  }
  .navlinks {
    display: flex; flex-wrap: nowrap; gap: var(--md-sys-spacing-1);
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px; padding-right: var(--md-sys-spacing-3); min-width: 0;
    /* a link cut off at the edge fades out, so it reads as "there is more this
       way" rather than as a broken word */
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
  }
  .navlinks::-webkit-scrollbar { display: none; }
  .navlink { white-space: nowrap; flex: 0 0 auto; padding: 10px 14px; }

  .whoami { margin-left: 0; flex: 0 0 auto; }
  .whoami .who { display: none; }   /* the name is on the Accounts page anyway */

  .toolbar { position: static; }
  .toolbar select { flex: 1 1 42%; width: auto !important; }
  .toolbar .btn { flex: 1 1 120px; }
  .searchwrap { flex-basis: 100%; }

  /* A two-line product name makes the body taller than the thumbnail, and a
     centred thumbnail then floats beside the middle of the title. Top-align
     them so the picture starts where the name does. */
  .item {
    flex-wrap: wrap; align-items: flex-start;
    gap: var(--md-sys-spacing-3);
    padding: var(--md-sys-spacing-3);
  }
  .rowshot { width: 80px; height: 64px; }
  .item .body { flex: 1 1 55%; }
  .rowqty { margin-left: auto; align-self: center; }

  .kv { grid-template-columns: 104px 1fr; }
  .authcard { margin-top: var(--md-sys-spacing-4); padding: var(--md-sys-spacing-4); }
  .danger-zone { padding: var(--md-sys-spacing-3); }
}

/* Large / extra-large: MD3 says do not stretch text to the window edge. */
@media (min-width: 1200px) {
  main { padding-left: var(--md-sys-spacing-6); padding-right: var(--md-sys-spacing-6); }
}

/* ==========================================================================
   22. REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .shot:hover .photo { transform: none; }
}
