/* =========================================================================
   spesaFamiglia — Material 3 Expressive
   Mobile-first. No framework, no webfont, no build step.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Design tokens
   ------------------------------------------------------------------------- */

:root {
  /* --- Colour: light scheme (source hue = fresh basil green) --- */
  --primary:            #1E6B3C;
  --on-primary:         #FFFFFF;
  --primary-container:  #A6F4BE;
  --on-primary-container:#00210F;

  --secondary:          #4F6353;
  --on-secondary:       #FFFFFF;
  --secondary-container:#D2E8D4;
  --on-secondary-container:#0D1F13;

  /* Expressive schemes lean on a contrasting tertiary — warm amber here. */
  --tertiary:           #8B5000;
  --on-tertiary:        #FFFFFF;
  --tertiary-container: #FFDCBE;
  --on-tertiary-container:#2C1700;

  --error:              #BA1A1A;
  --on-error:           #FFFFFF;
  --error-container:    #FFDAD6;
  --on-error-container: #410002;

  --surface:            #F6FBF3;
  --on-surface:         #171D18;
  --on-surface-variant: #414942;
  --outline:            #717971;
  --outline-variant:    #C1C9C0;

  --surface-lowest:     #FFFFFF;
  --surface-low:        #F0F6EE;
  --surface-c:          #EBF1E8;
  --surface-high:       #E5EBE2;
  --surface-highest:    #DFE5DD;

  --inverse-surface:    #2C322D;
  --inverse-on-surface: #EDF3EA;
  --inverse-primary:    #8BD9A5;

  --scrim-rgb: 0 0 0;

  /* --- Shape: Expressive = generous, near-organic radii --- */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-2xl: 36px;
  --r-full: 999px;

  /* --- Elevation --- */
  --e1: 0 1px 3px rgb(0 0 0 / .12), 0 1px 2px rgb(0 0 0 / .08);
  --e2: 0 2px 6px rgb(0 0 0 / .14), 0 1px 2px rgb(0 0 0 / .08);
  --e3: 0 6px 16px rgb(0 0 0 / .16), 0 2px 4px rgb(0 0 0 / .08);
  --e4: 0 12px 32px rgb(0 0 0 / .20), 0 4px 8px rgb(0 0 0 / .10);

  /* --- Motion: Expressive springs, slightly overshooting --- */
  --spring:      420ms cubic-bezier(.34, 1.45, .5, 1);
  --spring-fast: 280ms cubic-bezier(.34, 1.42, .5, 1);
  --standard:    200ms cubic-bezier(.2, 0, 0, 1);
  --emphasized:  350ms cubic-bezier(.2, 0, 0, 1);

  /* --- Layout --- */
  --nav-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --font: "Roboto Flex", "Roboto", -apple-system, BlinkMacSystemFont,
          "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary:            #8BD9A5;
    --on-primary:         #00391D;
    --primary-container:  #00522C;
    --on-primary-container:#A6F4BE;

    --secondary:          #B6CCB8;
    --on-secondary:       #223526;
    --secondary-container:#384B3C;
    --on-secondary-container:#D2E8D4;

    --tertiary:           #FFB871;
    --on-tertiary:        #4A2800;
    --tertiary-container: #6A3C00;
    --on-tertiary-container:#FFDCBE;

    --error:              #FFB4AB;
    --on-error:           #690005;
    --error-container:    #93000A;
    --on-error-container: #FFDAD6;

    --surface:            #0F150F;
    --on-surface:         #DFE5DD;
    --on-surface-variant: #C1C9C0;
    --outline:            #8B938B;
    --outline-variant:    #414942;

    --surface-lowest:     #0A0F0A;
    --surface-low:        #171D18;
    --surface-c:          #1B211C;
    --surface-high:       #252B26;
    --surface-highest:    #303631;

    --inverse-surface:    #DFE5DD;
    --inverse-on-surface: #2C322D;
    --inverse-primary:    #1E6B3C;
  }
}

/* -------------------------------------------------------------------------
   2. Reset & base
   ------------------------------------------------------------------------- */

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

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font);
  background: var(--surface);
  color: var(--on-surface);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
ul { list-style: none; margin: 0; padding: 0; }

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* --- Type scale ------------------------------------------------------- */
.type-display    { font-size: clamp(2.25rem, 9vw, 3rem); line-height: 1.08; font-weight: 800; letter-spacing: -.03em; margin: 0; }
.type-display-sm { font-size: clamp(1.75rem, 7vw, 2.25rem); line-height: 1.15; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.type-title-lg   { font-size: 1.5rem;  line-height: 1.25; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.type-title      { font-size: 1.125rem; line-height: 1.35; font-weight: 700; letter-spacing: -.005em; margin: 0; }
.type-body-lg    { font-size: 1rem;    line-height: 1.5; font-weight: 400; margin: 0; }
.type-body       { font-size: .9375rem; line-height: 1.45; font-weight: 400; margin: 0; }
.type-label      { font-size: .8125rem; line-height: 1.4; font-weight: 500; letter-spacing: .01em; margin: 0; }
.mono            { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.dim             { color: var(--on-surface-variant); }
.warn            { color: var(--tertiary); }
.accent          { color: var(--primary); }

/* -------------------------------------------------------------------------
   3. Buttons
   ------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border-radius: var(--r-full);
  font-size: .9375rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  transition: background-color var(--standard), color var(--standard),
              border-radius var(--spring-fast), transform var(--spring-fast),
              box-shadow var(--standard);
}
/* Expressive signature: pressing morphs the shape from pill toward square. */
.btn:active { transform: scale(.96); border-radius: var(--r-md); }
.btn:disabled { opacity: .38; pointer-events: none; }
.btn svg { flex: none; }

.btn--filled   { background: var(--primary); color: var(--on-primary); box-shadow: var(--e1); }
.btn--filled:active { box-shadow: none; }
.btn--tonal    { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn--outlined { border: 1px solid var(--outline-variant); color: var(--primary); }
.btn--text     { color: var(--primary); padding: 0 16px; }
.btn--danger   { color: var(--error); }
.btn--grow     { flex: 1; }
.btn--xl       { min-height: 60px; font-size: 1.0625rem; width: 100%; border-radius: var(--r-xl); }
.btn--xl:active { border-radius: var(--r-md); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  color: var(--on-surface-variant);
  transition: background-color var(--standard), transform var(--spring-fast);
}
.icon-btn:active { background: color-mix(in srgb, var(--on-surface) 10%, transparent); transform: scale(.9); }

/* -------------------------------------------------------------------------
   4. Boot screen
   ------------------------------------------------------------------------- */

.boot {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-content: center; justify-items: center; gap: 28px;
  background: var(--surface);
}
.boot__mark {
  width: 88px; height: 88px;
  display: grid; place-items: center;
  border-radius: var(--r-2xl);
  background: var(--primary-container);
  color: var(--on-primary-container);
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { transform: scale(1) } 50% { transform: scale(1.07) } }
.boot__spinner {
  width: 34px; height: 34px;
  border: 3.5px solid var(--outline-variant);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* -------------------------------------------------------------------------
   5. Login
   ------------------------------------------------------------------------- */

.screen--login {
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column;
  background: var(--surface);
  overflow: auto;
}

.login__art {
  position: relative;
  flex: 1 1 42vh;
  min-height: 240px;
  display: grid; place-items: center;
  overflow: hidden;
  border-radius: 0 0 var(--r-2xl) var(--r-2xl);
  background: var(--primary-container);
}
.blob { position: absolute; border-radius: 48% 52% 60% 40% / 55% 45% 55% 45%; filter: blur(2px); opacity: .55; }
.blob--a { width: 62vw; height: 62vw; background: var(--primary); top: -18%; left: -16%; animation: drift 16s ease-in-out infinite; }
.blob--b { width: 48vw; height: 48vw; background: var(--tertiary-container); bottom: -14%; right: -12%; animation: drift 21s ease-in-out infinite reverse; }
.blob--c { width: 34vw; height: 34vw; background: var(--secondary-container); top: 45%; left: 8%; animation: drift 27s ease-in-out infinite; }
@keyframes drift {
  0%,100% { transform: translate(0,0) rotate(0deg) }
  33%     { transform: translate(6%, -8%) rotate(120deg) }
  66%     { transform: translate(-7%, 5%) rotate(240deg) }
}
.login__icon {
  position: relative;
  width: 116px; height: 116px;
  display: grid; place-items: center;
  border-radius: var(--r-2xl);
  background: var(--surface-lowest);
  color: var(--primary);
  box-shadow: var(--e3);
}

.login__body { padding: 32px 24px calc(32px + var(--safe-b)); display: grid; gap: 16px; justify-items: start; }
.login__sub  { color: var(--on-surface-variant); max-width: 34ch; }
.login__gsi  { margin-top: 12px; min-height: 44px; align-self: stretch; display: flex; justify-content: center; }
.login__note { color: var(--on-surface-variant); }
.login__error {
  align-self: stretch;
  background: var(--error-container); color: var(--on-error-container);
  padding: 14px 18px; border-radius: var(--r-md);
  font-size: .9375rem; margin: 0;
}

/* -------------------------------------------------------------------------
   6. App shell
   ------------------------------------------------------------------------- */

.app { display: flex; flex-direction: column; height: 100%; }

.appbar {
  padding: calc(var(--safe-t) + 12px) 8px 8px 20px;
  background: var(--surface);
  flex: none;
}
.appbar__row { display: flex; align-items: center; gap: 12px; }
.appbar__title { flex: 1; }
.appbar__sub { color: var(--on-surface-variant); padding-right: 20px; min-height: 1.2em; }

.avatar-btn {
  position: relative;
  width: 44px; height: 44px; flex: none;
  border-radius: var(--r-full);
  overflow: hidden;
  background: var(--primary-container);
  color: var(--on-primary-container);
  display: grid; place-items: center;
  transition: transform var(--spring-fast);
}
.avatar-btn:active { transform: scale(.9); }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.avatar-btn__initial { font-weight: 700; font-size: 1.0625rem; }

.content { flex: 1; position: relative; min-height: 0; }

.page { position: absolute; inset: 0; display: flex; flex-direction: column; }
.page--scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(var(--nav-h) + var(--safe-b) + 24px);
}
.page[hidden] { display: none; }
.page:not([hidden]) { animation: pageIn var(--emphasized) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }

/* -------------------------------------------------------------------------
   7. Bottom navigation
   ------------------------------------------------------------------------- */

.navbar {
  flex: none;
  display: flex;
  justify-content: space-around;
  align-items: start;
  gap: 4px;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 10px 8px var(--safe-b);
  background: var(--surface-c);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: 0 -1px 0 var(--outline-variant);
  position: relative; z-index: 20;
}
.nav {
  flex: 1 1 0;
  display: grid; justify-items: center; gap: 4px;
  padding: 0;
  color: var(--on-surface-variant);
  min-width: 0;
}
.nav__pill {
  position: relative;
  display: grid; place-items: center;
  width: 66px; height: 34px;
  border-radius: var(--r-full);
  transition: background-color var(--standard), width var(--spring);
}
.nav__label { font-size: .75rem; font-weight: 600; letter-spacing: .01em; }
.nav[aria-selected="true"] { color: var(--on-secondary-container); }
.nav[aria-selected="true"] .nav__pill { background: var(--secondary-container); }
.nav[aria-selected="true"] .nav__label { color: var(--on-surface); }
.nav:active .nav__pill { transform: scale(.92); }

.nav__badge {
  position: absolute; top: -2px; right: 10px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  background: var(--error); color: var(--on-error);
  font-size: .6875rem; font-weight: 700;
  border: 2px solid var(--surface-c);
}

/* -------------------------------------------------------------------------
   8. Scanner
   ------------------------------------------------------------------------- */

.scanner {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  overflow: hidden;
  border-radius: var(--r-xl);
  margin: 0 12px;
}
#video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

/* Dimmed surround + clear scan window, drawn with one element per side. */
.scanner__mask { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scanner__window {
  position: relative;
  width: min(84%, 420px);
  aspect-ratio: 5 / 3;
  border-radius: var(--r-lg);
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / .48);
}
.corner {
  position: absolute; width: 34px; height: 34px;
  border: 4px solid #fff;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / .5));
}
.corner--tl { top: -2px; left: -2px;  border-right: 0; border-bottom: 0; border-radius: var(--r-lg) 0 0 0; }
.corner--tr { top: -2px; right: -2px; border-left: 0;  border-bottom: 0; border-radius: 0 var(--r-lg) 0 0; }
.corner--bl { bottom: -2px; left: -2px;  border-right: 0; border-top: 0; border-radius: 0 0 0 var(--r-lg); }
.corner--br { bottom: -2px; right: -2px; border-left: 0;  border-top: 0; border-radius: 0 0 var(--r-lg) 0; }

.laser {
  position: absolute; left: 8%; right: 8%; top: 50%;
  height: 3px; border-radius: var(--r-full);
  background: linear-gradient(90deg, transparent, var(--inverse-primary), transparent);
  box-shadow: 0 0 14px 2px color-mix(in srgb, var(--inverse-primary) 60%, transparent);
  animation: sweep 2.6s cubic-bezier(.6,0,.4,1) infinite;
}
@keyframes sweep {
  0%,100% { transform: translateY(-46px); opacity: .35 }
  50%     { transform: translateY(46px);  opacity: 1 }
}

/* Success flash when a code is accepted */
.scanner.is-hit .scanner__window { animation: hit var(--spring) both; }
.scanner.is-hit .corner { border-color: var(--inverse-primary); }
@keyframes hit { 0% { transform: scale(1) } 45% { transform: scale(1.06) } 100% { transform: scale(1) } }

.scanner__hint {
  position: absolute; left: 0; right: 0; bottom: 96px;
  text-align: center; color: #fff;
  text-shadow: 0 1px 4px rgb(0 0 0 / .7);
  padding: 0 24px;
  pointer-events: none;
}

.scanner__tools {
  position: absolute; top: 14px; right: 14px;
  display: grid; gap: 10px;
}
.tool-btn {
  width: 50px; height: 50px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  background: rgb(0 0 0 / .42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  transition: transform var(--spring-fast), background-color var(--standard);
}
.tool-btn:active { transform: scale(.88); }
.tool-btn.is-on { background: var(--primary-container); color: var(--on-primary-container); }

.scanner__zoom { position: absolute; left: 16px; right: 16px; bottom: 60px; }
.scanner__zoom input {
  width: 100%;
  accent-color: var(--inverse-primary);
  background: transparent;
}

.scanner__blocked {
  position: absolute; inset: 0;
  display: grid; align-content: center; justify-items: center; gap: 12px;
  padding: 32px 28px;
  text-align: center;
  background: var(--surface);
  color: var(--on-surface);
}
.scanner__blocked svg { color: var(--tertiary); }
.scanner__blocked p { color: var(--on-surface-variant); max-width: 34ch; }
.scanner__blocked .btn { margin-top: 6px; }

.scan-footer {
  flex: none;
  display: grid; place-items: center;
  padding: 14px 16px calc(10px);
}
.pill-count {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 0 22px;
  border-radius: var(--r-full);
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  font-weight: 600;
  transition: transform var(--spring-fast), border-radius var(--spring-fast);
}
.pill-count:active { transform: scale(.95); border-radius: var(--r-md); }
.pill-count.is-bump { animation: bump var(--spring) both; }
@keyframes bump { 0% { transform: scale(1) } 40% { transform: scale(1.14) } 100% { transform: scale(1) } }

/* -------------------------------------------------------------------------
   9. Item list
   ------------------------------------------------------------------------- */

.list-head { display: flex; gap: 12px; padding: 8px 4px 18px; }
.stat {
  flex: 1;
  padding: 18px 20px;
  border-radius: var(--r-xl);
  background: var(--primary-container);
  color: var(--on-primary-container);
  display: grid; gap: 2px;
}
.stat--alt { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.stat__num { font-size: 2.25rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat__lbl { font-size: .8125rem; font-weight: 600; opacity: .8; }

.items { display: grid; gap: 8px; }

.item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--r-lg);
  background: var(--surface-c);
  animation: itemIn var(--spring) both;
}
@keyframes itemIn { from { opacity: 0; transform: translateY(-8px) scale(.97) } to { opacity: 1; transform: none } }
.item.is-leaving { animation: itemOut var(--emphasized) both; }
@keyframes itemOut { to { opacity: 0; transform: translateX(-30px) scale(.95); height: 0; margin-top: -8px; padding-block: 0 } }

.item__thumb {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  background: var(--surface-highest);
  color: var(--on-surface-variant);
  display: grid; place-items: center;
  overflow: hidden;
  flex: none;
}
.item__thumb img { width: 100%; height: 100%; object-fit: cover; }

.item__text { min-width: 0; }
.item__name {
  font-size: .9375rem; font-weight: 600; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item__code { font-size: .75rem; color: var(--on-surface-variant); margin: 2px 0 0; }

.item__qty {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface-lowest);
  border-radius: var(--r-full);
  padding: 3px;
}
.item__qty button {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  color: var(--primary);
  transition: background-color var(--standard), transform var(--spring-fast);
}
.item__qty button:active { background: var(--primary-container); transform: scale(.86); }
.item__qty output {
  min-width: 26px; text-align: center;
  font-weight: 700; font-variant-numeric: tabular-nums;
}

.list-actions { display: grid; gap: 6px; padding: 22px 0 0; }

.empty {
  display: grid; place-content: center; justify-items: center; gap: 10px;
  padding: 56px 24px; text-align: center;
}
.empty__icon {
  width: 92px; height: 92px;
  display: grid; place-items: center;
  border-radius: var(--r-2xl);
  background: var(--surface-c);
  color: var(--on-surface-variant);
  margin-bottom: 6px;
}
.empty p { color: var(--on-surface-variant); max-width: 30ch; }
.empty .btn { margin-top: 10px; }

/* -------------------------------------------------------------------------
   10. History
   ------------------------------------------------------------------------- */

.history { display: grid; gap: 8px; padding-top: 8px; }
.trip {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--surface-c);
  text-align: left;
  transition: transform var(--spring-fast), border-radius var(--spring-fast);
}
.trip:active { transform: scale(.98); border-radius: var(--r-md); }
.trip__date { font-weight: 700; font-size: .9375rem; }
.trip__meta { font-size: .8125rem; color: var(--on-surface-variant); margin-top: 2px; }
.trip__count {
  display: grid; place-items: center;
  min-width: 52px; height: 52px; padding: 0 10px;
  border-radius: var(--r-md);
  background: var(--primary-container); color: var(--on-primary-container);
  font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
   11. FAB
   ------------------------------------------------------------------------- */

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  z-index: 25;
  display: none;
  align-items: center; gap: 10px;
  height: 60px; padding: 0 24px;
  border-radius: var(--r-xl);
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-weight: 700; font-size: 1rem;
  box-shadow: var(--e3);
  transition: transform var(--spring), border-radius var(--spring-fast), box-shadow var(--standard);
}
.fab.is-visible { display: inline-flex; animation: fabIn var(--spring) both; }
.fab:active { transform: scale(.94); border-radius: var(--r-lg); box-shadow: var(--e1); }
@keyframes fabIn { from { opacity: 0; transform: scale(.7) translateY(20px) } to { opacity: 1; transform: none } }

/* -------------------------------------------------------------------------
   12. Scrim, sheets, dialog
   ------------------------------------------------------------------------- */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgb(var(--scrim-rgb) / .42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade var(--standard) both;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  position: fixed; z-index: 50;
  left: 0; right: 0; bottom: 0;
  max-height: 92vh; overflow-y: auto;
  padding: 8px 20px calc(24px + var(--safe-b));
  background: var(--surface-low);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  box-shadow: var(--e4);
  display: grid; gap: 18px;
  animation: sheetIn var(--spring) both;
}
@keyframes sheetIn { from { transform: translateY(100%) } to { transform: none } }
.sheet.is-closing { animation: sheetOut var(--emphasized) both; }
@keyframes sheetOut { to { transform: translateY(100%) } }

.sheet__grip {
  width: 36px; height: 4px; border-radius: var(--r-full);
  background: var(--outline-variant);
  justify-self: center; margin: 4px 0 2px;
}
.sheet__head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; }
.sheet__thumb {
  width: 56px; height: 56px;
  border-radius: var(--r-md);
  background: var(--primary-container); color: var(--on-primary-container);
  display: grid; place-items: center; overflow: hidden;
}
.sheet__thumb img { width: 100%; height: 100%; object-fit: cover; }
.sheet__titles { min-width: 0; }
.sheet__titles h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet__titles p { color: var(--on-surface-variant); margin-top: 2px; }

.sheet__actions { display: flex; gap: 10px; align-items: center; }
.sheet__actions--stack { flex-direction: column; align-items: stretch; }

/* Text field (M3 filled) */
.field { display: grid; gap: 6px; }
.field__label { font-size: .8125rem; font-weight: 600; color: var(--on-surface-variant); padding-left: 4px; }
.field input {
  width: 100%;
  min-height: 56px;
  padding: 0 18px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-md);
  background: var(--surface-lowest);
  transition: border-color var(--standard), box-shadow var(--standard);
}
.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

/* Big quantity stepper */
.stepper {
  display: grid;
  grid-template-columns: 68px 1fr 68px;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--r-xl);
  background: var(--surface-c);
}
.stepper__btn {
  width: 68px; height: 68px;
  display: grid; place-items: center;
  border-radius: var(--r-lg);
  background: var(--surface-lowest);
  color: var(--primary);
  transition: transform var(--spring-fast), background-color var(--standard), border-radius var(--spring-fast);
}
.stepper__btn:active { transform: scale(.9); border-radius: var(--r-full); background: var(--primary-container); color: var(--on-primary-container); }
.stepper__btn:disabled { opacity: .35; pointer-events: none; }
.stepper__value { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.stepper__value input {
  width: 100%; max-width: 110px;
  border: 0; background: transparent; text-align: center;
  font-size: 2.75rem; font-weight: 800; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.stepper__value input::-webkit-outer-spin-button,
.stepper__value input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper__value input:focus { outline: none; }
.stepper__unit { font-size: .9375rem; font-weight: 600; color: var(--on-surface-variant); }

.account { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px; }
.account img { width: 60px; height: 60px; border-radius: var(--r-full); background: var(--surface-highest); }
.account p { overflow: hidden; text-overflow: ellipsis; }

.dialog {
  position: fixed; z-index: 60;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 400px);
  padding: 26px 26px 18px;
  border-radius: var(--r-xl);
  background: var(--surface-high);
  box-shadow: var(--e4);
  display: grid; gap: 12px;
  animation: dialogIn var(--spring) both;
}
@keyframes dialogIn { from { opacity: 0; transform: translate(-50%,-46%) scale(.9) } to { opacity: 1; transform: translate(-50%,-50%) scale(1) } }
.dialog p { color: var(--on-surface-variant); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }

/* -------------------------------------------------------------------------
   13. Done screen
   ------------------------------------------------------------------------- */

.done {
  position: fixed; inset: 0; z-index: 70;
  overflow-y: auto;
  padding: calc(var(--safe-t) + 40px) 22px calc(28px + var(--safe-b));
  background: var(--surface);
  display: grid; align-content: start; justify-items: center; gap: 14px;
  text-align: center;
  animation: pageIn var(--emphasized) both;
}
.done__badge {
  width: 108px; height: 108px;
  display: grid; place-items: center;
  border-radius: var(--r-2xl);
  background: var(--primary-container); color: var(--on-primary-container);
  animation: pop var(--spring) both;
}
@keyframes pop { 0% { transform: scale(.4) rotate(-12deg); opacity: 0 } 100% { transform: none; opacity: 1 } }
.receipt {
  width: 100%;
  max-height: 42vh; overflow: auto;
  margin: 10px 0 0;
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--surface-c);
  color: var(--on-surface-variant);
  font-size: .75rem; line-height: 1.5;
  text-align: left;
  white-space: pre;
}
.done__actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.done .btn--xl { margin-top: 10px; }

/* -------------------------------------------------------------------------
   14. Snackbar
   ------------------------------------------------------------------------- */

.snackbar {
  position: fixed; z-index: 100;
  left: 16px; right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transition: bottom var(--emphasized);
  margin: 0 auto; max-width: 480px;
  padding: 16px 20px;
  border-radius: var(--r-md);
  background: var(--inverse-surface);
  color: var(--inverse-on-surface);
  font-size: .9375rem; font-weight: 500;
  box-shadow: var(--e3);
  animation: snackIn var(--spring) both;
}
@keyframes snackIn { from { opacity: 0; transform: translateY(24px) scale(.94) } to { opacity: 1; transform: none } }
.snackbar.is-error { background: var(--error-container); color: var(--on-error-container); }

/* Ride above the extended FAB instead of burying it. */
body.has-fab .snackbar { bottom: calc(var(--nav-h) + var(--safe-b) + 92px); }

/* -------------------------------------------------------------------------
   15. Larger screens — keep it phone-shaped, just centred
   ------------------------------------------------------------------------- */

@media (min-width: 720px) {
  body { background: var(--surface-highest); }
  .app, .screen--login, .done {
    max-width: 480px;
    margin-inline: auto;
    inset-inline: 0;
    box-shadow: var(--e2);
    background: var(--surface);
  }
  .fab { right: max(16px, calc(50vw - 240px + 16px)); }
  .sheet, .snackbar { max-width: 480px; margin-inline: auto; }
}

/* -------------------------------------------------------------------------
   16. Reduced motion
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .laser { display: none; }
}
