/* ═══════════════════════════════════════════════════════════════
   PRODUCTION ADAPTATION (stocktake. PWA)
   This file is the Claude Design system (scan-styles.css) ported
   verbatim, with the canvas/iOS-frame scaffolding swapped for a
   real full-viewport PWA shell + safe-area insets. The chosen skin
   is `.theme-industrial` (applied on <body>); the :root defaults
   below are the original "Refined Emerald" reference and are kept
   only so the design tokens cascade correctly.
   ═══════════════════════════════════════════════════════════════ */
html { background: #0d1217; }
body.sf-app {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
/* Each top-level "screen" fills the viewport; only one is visible at a time */
body.sf-app .sf-screen,
body.sf-app .sf-set,
body.sf-app .sf-auth { height: 100vh; height: 100dvh; }

/* CRITICAL: the legacy styles.css styles #page-scan/#page-config at ID
   specificity (display:grid, align-items:start, max-width, animation, etc.),
   which hijacks the new single-screen layout. These ID+class selectors
   (specificity 1,2,1) re-assert the sf- flex column and beat the old rules. */
body.sf-app #page-scan.sf-screen,
body.sf-app #page-config.sf-set {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  width: auto;
  max-width: none;
  animation: none;
  padding-left: 0;
  padding-right: 0;
}

/* This is a PHONE app. On anything wider than a phone, centre it in a
   phone-width column so the single-screen layout never spreads/breaks. */
@media (min-width: 520px) {
  html, body.sf-app { background: #07090c; }
  body.sf-app #page-scan.sf-screen,
  body.sf-app #page-config.sf-set,
  body.sf-app #authGate.sf-auth {
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
    border-left: 1px solid rgba(255,255,255,.06);
    border-right: 1px solid rgba(255,255,255,.06);
    box-shadow: 0 0 80px rgba(0,0,0,.5);
  }
  /* Fixed overlays centre on the same phone column */
  body.sf-app .sf-drawer-back,
  body.sf-app .sf-drawer,
  body.sf-app .sf-cam {
    left: 50%;
    right: auto;
    margin-left: -230px;
    width: 460px;
  }
}
/* Prefer the real device safe-area insets, but keep a realistic floor so the UI
   never slides under the status bar / home indicator. Some iOS WebView contexts
   (incl. the Capacitor shell) report env(safe-area-inset-*) as 0 even with
   viewport-fit=cover; a 12px floor then let content bleed into the status bar.
   47px ≈ status-bar height, 34px ≈ home indicator — env() expands past these on
   notched / Dynamic Island devices. */
body.sf-app .sf-screen,
body.sf-app .sf-set {
  padding-top: max(env(safe-area-inset-top), 47px);
  padding-bottom: max(env(safe-area-inset-bottom), 34px);
}
body.sf-app .sf-auth {
  padding-top: calc(max(env(safe-area-inset-top), 47px) + 8px);
  padding-bottom: max(env(safe-area-inset-bottom), 34px);
}
body.sf-app .sf-cam-top { padding-top: calc(max(env(safe-area-inset-top), 47px) + 8px); }
body.sf-app .sf-cam-bottom { padding-bottom: calc(max(env(safe-area-inset-bottom), 34px) + 8px); }
/* The Recent drawer + camera overlay are positioned against the body shell */
body.sf-app .sf-drawer-back,
body.sf-app .sf-drawer,
body.sf-app .sf-cam { position: fixed; }

    :root {
      /* Brand palette — keeping StockFlow emerald, refined */
      --brand-50:  #effdf7;
      --brand-100: #c7f7e4;
      --brand-200: #90edcc;
      --brand-300: #52ddb0;
      --brand-400: #1ec993;
      --brand-500: #07ab79;
      --brand-600: #058860;
      --brand-700: #066d4c;
      --brand-800: #075640;
      --brand-900: #054535;

      /* Neutrals */
      --ink-900: #0b1c17;
      --ink-800: #1a2b25;
      --ink-700: #334b43;
      --ink-600: #4f6962;
      --ink-500: #6b827b;
      --ink-400: #9aaca6;
      --ink-300: #c5d2cc;
      --ink-200: #e1e8e4;
      --ink-150: #ecf1ee;
      --ink-100: #f1f6f3;
      --ink-50:  #f7faf8;
      --ink-25:  #fbfdfc;

      /* Semantic */
      --amber-soft: #fef3c7;
      --amber-mid:  #f59e0b;
      --amber-deep: #b45309;
      --red-soft:   #fee2e2;
      --red-mid:    #ef4444;
      --red-deep:   #b91c1c;

      /* Type */
      --font-sans: 'Inter', -apple-system, system-ui, sans-serif;
      --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
    }

    html, body {
      margin: 0;
      font-family: var(--font-sans);
      background:
        radial-gradient(ellipse 50% 30% at 50% 0%, rgba(5,136,96,.10) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 50% 100%, rgba(7,86,64,.08) 0%, transparent 65%),
        #eef2f0;
      color: var(--ink-900);
      -webkit-font-smoothing: antialiased;
      min-height: 100vh;
    }

    .stage {
      min-height: 100vh;
      display: grid;
      place-items: center;
      padding: 32px 16px 64px;
    }

    /* ─── Phone screen layout ─────────────────────────────────── */
    .sf-screen {
      height: 100%;
      display: flex;
      flex-direction: column;
      background: linear-gradient(180deg, #f7faf8 0%, #eef2f0 100%);
      padding-top: 47px;   /* iOS status bar */
      padding-bottom: 34px; /* home indicator */
      box-sizing: border-box;
      color: var(--ink-900);
      font-family: var(--font-sans);
      position: relative;
    }

    /* ─── Header ──────────────────────────────────────────────── */
    .sf-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 18px 12px;
      gap: 12px;
    }
    .sf-brand {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
    }
    .sf-wordmark-name {
      font-size: 17px;
      font-weight: 700;
      letter-spacing: -0.02em;
      color: var(--ink-900);
      line-height: 1.1;
    }
    .sf-wordmark-sub {
      display: flex;
      align-items: center;
      gap: 5px;
      font-size: 11px;
      font-weight: 500;
      color: var(--ink-500);
      letter-spacing: 0.01em;
      margin-top: 1px;
    }
    .sf-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--ink-400);
      flex-shrink: 0;
    }
    .sf-dot-online {
      background: var(--brand-500);
      box-shadow: 0 0 0 2px rgba(7,171,121,.18);
    }
    .sf-tally {
      display: flex;
      align-items: baseline;
      gap: 5px;
      padding: 6px 12px 7px;
      border-radius: 999px;
      background: #fff;
      border: 1px solid var(--ink-200);
      cursor: pointer;
      font-family: var(--font-sans);
      transition: transform 100ms, box-shadow 100ms;
    }
    .sf-tally:active { transform: scale(0.97); }
    .sf-tally-num {
      font-family: var(--font-mono);
      font-size: 17px;
      font-weight: 600;
      color: var(--brand-700);
      letter-spacing: -0.02em;
      line-height: 1;
    }
    .sf-tally-lbl {
      font-size: 11px;
      font-weight: 500;
      color: var(--ink-500);
      letter-spacing: 0.01em;
    }

    /* ─── Status strip ───────────────────────────────────────── */
    .sf-status {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 16px 12px;
      gap: 10px;
    }
    .sf-mode-seg {
      display: flex;
      background: var(--ink-100);
      border-radius: 11px;
      padding: 3px;
      gap: 2px;
    }
    .sf-mode-btn {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 7px 11px;
      border: 0;
      background: transparent;
      border-radius: 8px;
      cursor: pointer;
      font-family: var(--font-sans);
      font-size: 12.5px;
      font-weight: 600;
      color: var(--ink-500);
      letter-spacing: -0.005em;
      transition: all 120ms;
    }
    .sf-mode-btn.active {
      background: #fff;
      color: var(--ink-900);
      box-shadow: 0 1px 2px rgba(11,28,23,.05), 0 0 0 0.5px var(--ink-200);
    }
    .sf-mode-icon {
      width: 16px;
      height: 16px;
      display: grid;
      place-items: center;
    }
    .sf-mode-icon svg { width: 16px; height: 16px; }

    .sf-status-right {
      display: flex;
      gap: 4px;
    }
    .sf-icon-btn {
      width: 36px;
      height: 36px;
      display: grid;
      place-items: center;
      border-radius: 10px;
      border: 0;
      background: transparent;
      color: var(--ink-500);
      cursor: pointer;
      transition: all 120ms;
    }
    .sf-icon-btn:hover { background: var(--ink-100); color: var(--ink-700); }
    .sf-icon-btn.on {
      background: var(--amber-soft);
      color: var(--amber-deep);
    }
    .sf-icon-btn svg { width: 19px; height: 19px; }

    /* ─── Product zone ──────────────────────────────────────── */
    .sf-product {
      margin: 0 16px 12px;
      padding: 14px 16px;
      border-radius: 16px;
      background: #fff;
      border: 1px solid var(--ink-200);
      min-height: 96px;
      flex: 1 1 auto;        /* absorb vertical slack on big phones */
      display: flex;
      flex-direction: column;
      justify-content: center;
      gap: 7px;
      box-shadow: 0 1px 2px rgba(11,28,23,.03);
    }
    .sf-product-idle {
      display: flex;
      flex-direction: row;
      align-items: center;
      gap: 14px;
      cursor: pointer;
      background: linear-gradient(180deg, #fff, var(--ink-50));
      border-style: dashed;
      border-color: var(--ink-300);
      transition: all 150ms;
      text-align: left;
      font-family: inherit;
    }
    .sf-product-idle:hover {
      border-color: var(--brand-400);
      background: linear-gradient(180deg, #fff, var(--brand-50));
    }
    .sf-product-idle-icon {
      color: var(--ink-400);
      flex-shrink: 0;
    }
    .sf-product-idle-title {
      font-size: 16px;
      font-weight: 600;
      color: var(--ink-800);
      letter-spacing: -0.015em;
    }
    .sf-product-idle-sub {
      font-size: 12.5px;
      color: var(--ink-500);
      margin-top: 2px;
    }

    .sf-product-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }
    .sf-pill {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 8px 3px 6px;
      border-radius: 999px;
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.005em;
    }
    .sf-pill svg { width: 12px; height: 12px; }
    .sf-pill-found {
      background: var(--brand-50);
      color: var(--brand-700);
      box-shadow: inset 0 0 0 1px var(--brand-200);
    }
    .sf-pill-unknown {
      background: var(--amber-soft);
      color: var(--amber-deep);
      box-shadow: inset 0 0 0 1px #fcd34d;
    }
    .sf-pill-dup {
      background: var(--amber-soft);
      color: var(--amber-deep);
      box-shadow: inset 0 0 0 1px #fcd34d;
    }
    .sf-product-bc {
      font-family: var(--font-mono);
      font-size: 11.5px;
      color: var(--ink-500);
      letter-spacing: 0.01em;
      font-weight: 500;
    }
    .sf-product-desc {
      font-size: 16px;
      font-weight: 600;
      color: var(--ink-900);
      letter-spacing: -0.015em;
      line-height: 1.25;
      text-wrap: balance;
      overflow: hidden;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
    .sf-product-desc-muted {
      color: var(--ink-600);
      font-weight: 500;
    }
    .sf-product-meta {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 12.5px;
      font-weight: 500;
      color: var(--ink-700);
      flex-wrap: wrap;
    }
    .sf-meta-lbl {
      font-size: 10px;
      font-weight: 600;
      color: var(--ink-400);
      letter-spacing: 0.06em;
      text-transform: uppercase;
      margin-right: 4px;
    }
    .sf-meta-divider {
      width: 1px;
      height: 10px;
      background: var(--ink-200);
    }
    .sf-meta-cat {
      padding: 2px 7px;
      border-radius: 5px;
      background: var(--ink-100);
      font-size: 11px;
      font-weight: 600;
      color: var(--ink-600);
      letter-spacing: -0.005em;
    }
    .sf-meta-cat-warn {
      background: var(--amber-soft);
      color: var(--amber-deep);
    }

    .sf-product-unknown,
    .sf-product-dup {
      background: linear-gradient(180deg, #fffbf2, #fff);
      border-color: #fcd34d;
    }

    /* ─── Qty readout ───────────────────────────────────────── */
    .sf-qty {
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      align-items: center;
      gap: 10px;
      padding: 4px 16px 12px;
    }
    .sf-qty-center {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 2px;
      min-width: 110px;
    }
    .sf-qty-label {
      font-family: var(--font-mono);
      font-size: 9px;
      font-weight: 600;
      color: var(--ink-400);
      letter-spacing: 0.22em;
      line-height: 1;
    }
    .sf-qty-value {
      font-family: var(--font-mono);
      font-size: 60px;
      font-weight: 600;
      color: var(--ink-900);
      letter-spacing: -0.045em;
      line-height: 1;
      text-align: center;
      font-variant-numeric: tabular-nums;
      transition: color 150ms;
    }
    .sf-qty-value[data-zero="true"] {
      color: var(--ink-300);
    }
    .sf-qty-chip {
      padding: 7px 12px;
      border-radius: 999px;
      border: 1px solid var(--ink-200);
      background: #fff;
      cursor: pointer;
      font-family: var(--font-sans);
      font-size: 13px;
      font-weight: 600;
      color: var(--ink-700);
      letter-spacing: -0.005em;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 5px;
      transition: all 120ms;
      box-shadow: 0 1px 2px rgba(11,28,23,.04);
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .sf-qty-chip:disabled { opacity: 0.4; cursor: not-allowed; }
    .sf-qty-chip:not(:disabled):hover {
      border-color: var(--brand-400);
      color: var(--brand-700);
    }
    .sf-qty-chip:not(:disabled):active { transform: scale(0.96); }
    .sf-qty-plus {
      justify-self: start;
      font-family: var(--font-mono);
      font-size: 15px;
      color: var(--brand-700);
      background: var(--brand-50);
      border-color: var(--brand-200);
    }
    .sf-qty-plus:not(:disabled):hover {
      background: var(--brand-100);
      border-color: var(--brand-300);
    }
    .sf-note-chip {
      justify-self: end;
      max-width: 130px;
    }
    .sf-note-chip.on {
      background: var(--brand-50);
      border-color: var(--brand-200);
      color: var(--brand-700);
    }
    .sf-note-dot {
      width: 6px; height: 6px; border-radius: 50%;
      background: var(--brand-500);
      flex-shrink: 0;
    }
    .sf-note-text {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 76px;
    }

    /* ─── Numpad ────────────────────────────────────────────── */
    .sf-numpad {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      padding: 0 16px;
      margin-bottom: 12px;
    }
    .sf-key {
      height: 54px;
      border-radius: 12px;
      background: #fff;
      border: 0;
      box-shadow: 0 1px 2px rgba(11,28,23,.06), 0 0.5px 0 rgba(11,28,23,.08), inset 0 -1px 0 var(--ink-150);
      font-family: var(--font-mono);
      font-size: 22px;
      font-weight: 500;
      color: var(--ink-900);
      cursor: pointer;
      transition: all 80ms;
      user-select: none;
      letter-spacing: -0.02em;
    }
    .sf-key:active {
      background: var(--ink-100);
      transform: translateY(1px);
      box-shadow: 0 0 0 rgba(11,28,23,.06), inset 0 1px 2px rgba(11,28,23,.06);
    }
    .sf-key-util {
      background: var(--ink-200);
      color: var(--ink-700);
      font-size: 18px;
      font-weight: 600;
      box-shadow: 0 1px 2px rgba(11,28,23,.05), inset 0 0 0 0.5px rgba(11,28,23,.06), inset 0 -1px 0 rgba(11,28,23,.06);
    }
    .sf-key-util:active {
      background: var(--ink-300);
    }

    /* ─── Action row ────────────────────────────────────────── */
    .sf-action-row {
      display: flex;
      gap: 8px;
      padding: 0 16px;
      margin-bottom: 8px;
    }
    .sf-action {
      flex: 1;
      min-width: 0;
      height: 54px;
      border-radius: 14px;
      border: 0;
      font-family: var(--font-sans);
      font-size: 16px;
      font-weight: 600;
      letter-spacing: -0.01em;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      transition: all 120ms;
      white-space: nowrap;
    }
    .sf-action-primary {
      background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
      color: #fff;
      box-shadow: 0 4px 14px rgba(5,136,96,.30), inset 0 1px 0 rgba(255,255,255,.2);
    }
    .sf-action-primary:hover {
      box-shadow: 0 6px 18px rgba(5,136,96,.36), inset 0 1px 0 rgba(255,255,255,.2);
    }
    .sf-action-primary:active {
      transform: translateY(1px);
      box-shadow: 0 2px 8px rgba(5,136,96,.30), inset 0 1px 0 rgba(255,255,255,.15);
    }
    .sf-action-primary:disabled {
      background: var(--ink-200);
      color: var(--ink-400);
      box-shadow: none;
      cursor: not-allowed;
    }
    .sf-action-ghost {
      background: #fff;
      color: var(--ink-400);
      border: 1px dashed var(--ink-300);
      cursor: default;
    }
    .sf-action-qty {
      font-family: var(--font-mono);
      font-size: 14px;
      font-weight: 600;
      padding: 2px 8px;
      border-radius: 999px;
      background: rgba(255,255,255,.22);
      letter-spacing: -0.01em;
    }
    .sf-action-secondary {
      width: 54px;
      height: 54px;
      border-radius: 14px;
      border: 1px solid var(--ink-200);
      background: #fff;
      color: var(--ink-700);
      cursor: pointer;
      display: grid;
      place-items: center;
      transition: all 120ms;
    }
    .sf-action-secondary:hover { background: var(--ink-50); color: var(--ink-900); }
    .sf-action-secondary svg { width: 20px; height: 20px; }

    /* ─── Bottom nav ────────────────────────────────────────── */
    .sf-nav {
      display: grid;
      /* Auto-size to however many buttons are VISIBLE: operators see 3
         (Scan / Recent / Settings); managers & HQ admins see 4 (the rights-
         gated Manage tab is revealed). A hidden button (display:none) drops
         out of the grid, so auto-flow columns give exactly N equal columns —
         no hard-coded count that wraps the 4th button to a second row. */
      grid-auto-flow: column;
      /* minmax(0,1fr) — not plain 1fr — so every tab is EXACTLY equal width
         regardless of label length; plain 1fr floors each track at its content
         min-width, which makes "Scan" narrower than "Settings". */
      grid-auto-columns: minmax(0, 1fr);
      gap: 2px;
      padding: 8px 12px 0;
      border-top: 1px solid var(--ink-200);
      background: rgba(247, 250, 248, 0.7);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
    }
    .sf-nav-btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 2px;
      padding: 6px 4px 4px;
      border: 0;
      background: transparent;
      color: var(--ink-400);
      font-family: var(--font-sans);
      font-size: 10.5px;
      font-weight: 600;
      letter-spacing: -0.005em;
      cursor: pointer;
      border-radius: 8px;
      transition: color 120ms;
    }
    .sf-nav-btn.active { color: var(--brand-700); }
    .sf-nav-icon { display: grid; place-items: center; }
    .sf-nav-icon svg { width: 22px; height: 22px; }

    /* ─── Compact density (for smaller iPhones) ─────────────── */
    .sf-compact .sf-header { padding: 10px 16px 8px; }
    .sf-compact .sf-status { padding: 0 14px 8px; }
    .sf-compact .sf-product { margin: 0 14px 10px; padding: 11px 14px; min-height: 80px; gap: 5px; }
    .sf-compact .sf-product-desc { font-size: 15px; }
    .sf-compact .sf-qty { padding: 2px 14px 6px; gap: 8px; }
    .sf-compact .sf-qty-value { font-size: 46px; }
    .sf-compact .sf-qty-chip { padding: 6px 10px; font-size: 12px; }
    .sf-compact .sf-numpad { padding: 0 14px; gap: 6px; margin-bottom: 8px; }
    .sf-compact .sf-key { height: 46px; font-size: 19px; }
    .sf-compact .sf-action-row { padding: 0 14px; margin-bottom: 6px; }
    .sf-compact .sf-action, .sf-compact .sf-action-secondary { height: 46px; }
    .sf-compact .sf-nav { padding: 6px 10px 0; }
    .sf-compact .sf-nav-icon svg { width: 20px; height: 20px; }

    /* hide scrollbars inside the phone */
    .sf-screen::-webkit-scrollbar { display: none; }
    .sf-drawer-list::-webkit-scrollbar,
    .sf-set-body::-webkit-scrollbar { width: 4px; }
    .sf-drawer-list::-webkit-scrollbar-thumb,
    .sf-set-body::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 2px; }

    /* ─── Settings screen ───────────────────────────────────── */
    .sf-set {
      height: 100%;
      display: flex; flex-direction: column;
      background: linear-gradient(180deg, var(--ink-50) 0%, var(--ink-100) 100%);
      padding-top: 47px;
      padding-bottom: 34px;
      box-sizing: border-box;
      color: var(--ink-900);
      font-family: var(--font-sans);
    }
    .sf-set-head {
      display: grid;
      grid-template-columns: 36px 1fr 36px;
      align-items: center;
      padding: 12px 16px 8px;
      gap: 8px;
    }
    .sf-set-back, .sf-set-spacer {
      width: 36px; height: 36px;
      border-radius: 999px; border: 0;
      background: rgba(255,255,255,0.7);
      backdrop-filter: blur(10px);
      display: grid; place-items: center;
      cursor: pointer;
      color: var(--ink-700);
      transition: background 120ms;
    }
    .sf-set-back:hover { background: #fff; color: var(--ink-900); }
    .sf-set-back svg { width: 18px; height: 18px; }
    .sf-set-spacer { background: transparent; pointer-events: none; }
    .sf-set-title {
      font-size: 17px;
      font-weight: 700;
      letter-spacing: -0.02em;
      text-align: center;
      color: var(--ink-900);
    }
    .sf-set-body {
      flex: 1;
      overflow-y: auto;
      padding: 4px 14px 24px;
      display: flex; flex-direction: column;
      gap: 18px;
    }
    .sf-set-body > * { flex-shrink: 0; }

    /* Active session hero */
    .sf-set-hero {
      background: linear-gradient(160deg, var(--brand-700) 0%, var(--brand-900) 100%);
      border-radius: 18px;
      padding: 16px 18px;
      color: #fff;
      box-shadow: 0 10px 30px -8px rgba(7,86,64,.45), inset 0 1px 0 rgba(255,255,255,.08);
      position: relative;
      overflow: hidden;
    }
    .sf-set-hero::after {
      content: '';
      position: absolute;
      top: -40%; right: -25%;
      width: 220px; height: 220px;
      background: radial-gradient(circle, rgba(82,221,176,.22), transparent 65%);
      pointer-events: none;
    }
    .sf-set-hero-top {
      display: flex; align-items: flex-start; justify-content: space-between;
      gap: 8px; position: relative; z-index: 1;
    }
    .sf-set-hero-eyebrow {
      font-size: 10px; font-weight: 600;
      color: var(--brand-200);
      letter-spacing: 0.12em; text-transform: uppercase;
    }
    .sf-set-hero-title {
      font-size: 22px; font-weight: 700;
      letter-spacing: -0.025em;
      color: #fff;
      margin-top: 2px;
    }
    .sf-set-hero-pill {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 4px 9px 4px 7px;
      border-radius: 999px;
      background: rgba(255,255,255,0.14);
      font-size: 11px; font-weight: 600;
      letter-spacing: 0.005em;
      backdrop-filter: blur(4px);
    }
    .sf-set-hero-pill .sf-dot {
      background: #6ee7b7;
      box-shadow: 0 0 0 3px rgba(110,231,183,.25);
    }
    .sf-set-hero-stats {
      display: flex; align-items: center; gap: 12px;
      margin: 14px 0 14px;
      position: relative; z-index: 1;
    }
    .sf-set-hero-stats > div:not(.sf-set-hero-vrule) { display: flex; flex-direction: column; gap: 2px; }
    .sf-set-hero-num {
      font-family: var(--font-mono);
      font-size: 22px; font-weight: 600;
      color: #fff;
      letter-spacing: -0.03em;
      line-height: 1;
      font-variant-numeric: tabular-nums;
    }
    .sf-set-hero-lbl {
      font-size: 10.5px; font-weight: 600;
      color: var(--brand-200);
      letter-spacing: 0.05em;
      text-transform: uppercase;
    }
    .sf-set-hero-vrule {
      width: 1px; height: 26px;
      background: rgba(255,255,255,0.16);
    }
    .sf-set-hero-actions {
      display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
      position: relative; z-index: 1;
    }
    .sf-set-act {
      height: 40px; border-radius: 11px; border: 0;
      font-family: inherit; font-size: 13px; font-weight: 600;
      letter-spacing: -0.005em; cursor: pointer;
      transition: all 120ms;
    }
    .sf-set-act-primary {
      background: #fff; color: var(--brand-800);
    }
    .sf-set-act-primary:hover { background: var(--brand-50); }
    .sf-set-act-ghost {
      background: rgba(255,255,255,0.10);
      color: #fff;
      box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
    }
    .sf-set-act-ghost:hover { background: rgba(255,255,255,0.16); }

    /* Setting groups */
    .sf-set-group { display: flex; flex-direction: column; gap: 6px; }
    .sf-set-group-title {
      font-size: 11px; font-weight: 600;
      color: var(--ink-500);
      letter-spacing: 0.08em;
      text-transform: uppercase;
      padding: 0 4px;
    }
    .sf-set-card {
      background: #fff;
      border-radius: 14px;
      border: 1px solid var(--ink-200);
      overflow: hidden;
      box-shadow: 0 1px 2px rgba(11,28,23,.03);
    }
    .sf-set-hint {
      font-size: 11.5px;
      color: var(--ink-500);
      padding: 0 4px;
      line-height: 1.35;
    }

    /* Setting rows */
    .sf-set-row {
      display: flex; align-items: center; justify-content: space-between;
      gap: 12px;
      padding: 12px 14px;
      border-bottom: 1px solid var(--ink-100);
      min-height: 44px;
      box-sizing: border-box;
    }
    .sf-set-card > .sf-set-row:last-child,
    .sf-set-card > .sf-set-action:last-child { border-bottom: 0; }
    .sf-set-row-lbl {
      font-size: 13px;
      font-weight: 500;
      color: var(--ink-600);
      letter-spacing: -0.005em;
      flex-shrink: 0;
    }
    .sf-set-row-val {
      font-size: 13px;
      font-weight: 600;
      color: var(--ink-900);
      letter-spacing: -0.01em;
      text-align: right;
      max-width: 60%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end;
    }
    .sf-set-row-val.mono {
      font-family: var(--font-mono);
      font-size: 12px;
      font-weight: 500;
      letter-spacing: -0.01em;
    }
    .sf-set-badge {
      width: 7px; height: 7px; border-radius: 50%;
      background: var(--brand-500);
      box-shadow: 0 0 0 2px var(--brand-100);
    }
    .sf-set-row-field { flex-direction: column; align-items: stretch; gap: 6px; padding: 12px 14px 14px; }
    .sf-set-row-field .sf-set-row-lbl { font-size: 11px; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
    .sf-set-input {
      width: 100%;
      font-family: var(--font-sans);
      font-size: 14px;
      font-weight: 500;
      color: var(--ink-900);
      background: var(--ink-50);
      border: 1px solid var(--ink-200);
      border-radius: 9px;
      padding: 9px 12px;
      box-sizing: border-box;
      letter-spacing: -0.005em;
      outline: none;
      transition: all 120ms;
    }
    .sf-set-input.mono { font-family: var(--font-mono); font-size: 12px; }
    .sf-set-input:focus { border-color: var(--brand-400); background: #fff; box-shadow: 0 0 0 3px var(--brand-100); }

    .sf-set-row-toggle { padding: 11px 14px; }
    .sf-set-switch {
      position: relative; width: 40px; height: 24px;
      border-radius: 999px; border: 0;
      background: var(--ink-200);
      cursor: pointer;
      transition: background 160ms;
      padding: 0;
    }
    .sf-set-switch[data-on="1"] { background: var(--brand-500); }
    .sf-set-switch-thumb {
      position: absolute;
      top: 2px; left: 2px;
      width: 20px; height: 20px;
      border-radius: 50%;
      background: #fff;
      box-shadow: 0 1px 3px rgba(0,0,0,0.18);
      transition: transform 160ms cubic-bezier(.34,1.4,.64,1);
    }
    .sf-set-switch[data-on="1"] .sf-set-switch-thumb { transform: translateX(16px); }

    .sf-set-action {
      display: flex; align-items: center; justify-content: space-between;
      width: 100%;
      padding: 13px 14px;
      border: 0;
      border-bottom: 1px solid var(--ink-100);
      background: transparent;
      font-family: var(--font-sans);
      font-size: 13.5px;
      font-weight: 600;
      letter-spacing: -0.005em;
      cursor: pointer;
      transition: background 120ms;
    }
    .sf-set-action:hover { background: var(--ink-50); }
    .sf-set-action-primary { color: var(--brand-700); }
    .sf-set-action-quiet   { color: var(--ink-700); }
    .sf-set-action-danger  { color: var(--red-deep); }
    .sf-set-action svg { color: var(--ink-400); }

    .sf-set-foot {
      text-align: center;
      font-size: 11px;
      color: var(--ink-400);
      padding: 6px 0 0;
      letter-spacing: 0.005em;
    }

    /* ─── Recent drawer ─────────────────────────────── */
    .sf-drawer-back {
      position: absolute; inset: 0;
      background: rgba(11,28,23,0.42);
      opacity: 0; pointer-events: none;
      transition: opacity 220ms ease;
      z-index: 30;
    }
    .sf-drawer-back.open { opacity: 1; pointer-events: auto; }

    .sf-drawer {
      position: absolute;
      left: 0; right: 0; bottom: 0;
      max-height: 86%;
      background: #fff;
      border-radius: 20px 20px 0 0;
      box-shadow: 0 -12px 36px rgba(11,28,23,.20);
      transform: translateY(105%);
      transition: transform 280ms cubic-bezier(.22,1,.36,1);
      z-index: 40;
      display: flex; flex-direction: column;
      padding-bottom: 28px;
      overflow: hidden;
    }
    .sf-drawer.open { transform: translateY(0); }

    .sf-drawer-handle {
      width: 38px; height: 4px;
      background: var(--ink-300);
      border-radius: 2px;
      margin: 8px auto 0;
      cursor: pointer;
    }
    .sf-drawer-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      padding: 10px 18px 8px;
      gap: 10px;
    }
    .sf-drawer-title {
      font-size: 18px;
      font-weight: 700;
      letter-spacing: -0.02em;
      color: var(--ink-900);
    }
    .sf-drawer-sub {
      font-size: 12px;
      color: var(--ink-500);
      margin-top: 2px;
      font-weight: 500;
    }
    .sf-drawer-close {
      width: 30px; height: 30px;
      border-radius: 999px;
      border: 0;
      background: var(--ink-100);
      color: var(--ink-600);
      cursor: pointer;
      font-size: 13px;
      display: grid; place-items: center;
      transition: background 120ms;
    }
    .sf-drawer-close:hover { background: var(--ink-200); }

    .sf-stat-row {
      display: flex;
      align-items: stretch;
      gap: 0;
      margin: 6px 16px 14px;
      padding: 12px 6px;
      background: var(--ink-50);
      border-radius: 14px;
      border: 1px solid var(--ink-150);
    }
    .sf-stat {
      flex: 1;
      display: flex; flex-direction: column;
      align-items: center; gap: 2px;
      min-width: 0;
    }
    .sf-stat-num {
      font-family: var(--font-mono);
      font-size: 22px;
      font-weight: 600;
      color: var(--ink-900);
      letter-spacing: -0.03em;
      line-height: 1;
      font-variant-numeric: tabular-nums;
    }
    .sf-stat-num[data-warn="true"] { color: var(--amber-deep); }
    .sf-stat-lbl {
      font-size: 10.5px;
      font-weight: 600;
      color: var(--ink-500);
      letter-spacing: 0.02em;
      text-transform: uppercase;
    }
    .sf-stat-divider {
      width: 1px;
      background: var(--ink-200);
      margin: 4px 0;
    }

    .sf-drawer-list-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 4px 18px 8px;
      font-size: 12px;
      font-weight: 600;
      color: var(--ink-500);
      letter-spacing: 0.02em;
      text-transform: uppercase;
    }
    .sf-link-btn {
      background: none; border: 0;
      font-family: var(--font-sans);
      font-size: 12px;
      font-weight: 600;
      color: var(--brand-700);
      cursor: pointer;
      letter-spacing: -0.005em;
      text-transform: none;
      padding: 4px 6px;
      border-radius: 6px;
    }
    .sf-link-btn:hover { background: var(--brand-50); }

    .sf-drawer-list {
      flex: 1;
      overflow-y: auto;
      padding: 0 16px;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .sf-entry {
      display: grid;
      grid-template-columns: 44px 1fr auto;
      gap: 10px;
      align-items: center;
      padding: 10px 6px;
      border-bottom: 1px solid var(--ink-100);
    }
    .sf-entry:last-child { border-bottom: 0; }
    .sf-entry-time {
      font-family: var(--font-mono);
      font-size: 12px;
      color: var(--ink-500);
      font-weight: 500;
      letter-spacing: -0.01em;
    }
    .sf-entry-body { min-width: 0; }
    .sf-entry-desc {
      font-size: 13.5px;
      font-weight: 600;
      color: var(--ink-900);
      letter-spacing: -0.01em;
      line-height: 1.25;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .sf-entry-meta {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-top: 2px;
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--ink-500);
      flex-wrap: wrap;
    }
    .sf-entry-tag {
      padding: 1px 6px;
      border-radius: 4px;
      font-family: var(--font-sans);
      font-size: 10px;
      font-weight: 600;
      letter-spacing: 0.01em;
    }
    .sf-entry-tag.warn { background: var(--amber-soft); color: var(--amber-deep); }
    .sf-entry-tag.muted { background: var(--ink-100); color: var(--ink-600); }
    .sf-entry-qty {
      font-family: var(--font-mono);
      font-size: 19px;
      font-weight: 600;
      color: var(--ink-900);
      letter-spacing: -0.03em;
      font-variant-numeric: tabular-nums;
      padding-left: 6px;
    }

    .sf-drawer-foot {
      display: flex;
      gap: 8px;
      padding: 12px 16px 0;
      border-top: 1px solid var(--ink-150);
    }
    .sf-foot-btn {
      flex: 1;
      height: 46px;
      border-radius: 12px;
      border: 0;
      font-family: var(--font-sans);
      font-size: 14px;
      font-weight: 600;
      letter-spacing: -0.005em;
      cursor: pointer;
      transition: all 120ms;
    }
    .sf-foot-secondary {
      background: var(--ink-100);
      color: var(--ink-700);
    }
    .sf-foot-secondary:hover { background: var(--ink-150); }
    .sf-foot-primary {
      background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
      color: #fff;
      box-shadow: 0 4px 14px rgba(5,136,96,.30), inset 0 1px 0 rgba(255,255,255,.2);
    }


/* ═══════════════════════════════════════════════════════════════
   THEME OVERLAYS — applied via wrapper class (e.g. <body class="theme-industrial">).
   Default :root above stays "Refined Emerald" so the brand-directions canvas works.
   ═══════════════════════════════════════════════════════════════ */
    /* ─── A · Refined Emerald (current) ─────────────────────── */
    .theme-emerald { /* no overrides — uses scan-styles defaults */ }

    /* ─── B · Industrial Workboot ───────────────────────────── */
    .theme-industrial {
      /* Hi-vis amber brand */
      --brand-50:  #2a2118;
      --brand-100: #3b2c1c;
      --brand-200: #5a3f1f;
      --brand-300: #b07820;
      --brand-400: #d99325;
      --brand-500: #ffae00;
      --brand-600: #e09600;
      --brand-700: #b87600;
      --brand-800: #7e5000;
      --brand-900: #4a2f00;

      /* Dark canvas inks (inverted scale) */
      --ink-25:  #1b2228;
      --ink-50:  #161c22;
      --ink-100: #1f272f;
      --ink-150: #252e38;
      --ink-200: #2d3845;
      --ink-300: #475363;
      --ink-400: #6a7787;
      --ink-500: #8b97a6;
      --ink-600: #b3bdc9;
      --ink-700: #d2d9e2;
      --ink-800: #e8ecf1;
      --ink-900: #f5f7fa;

      --amber-soft: #3a2a0a;
      --amber-deep: #ffd166;

      --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
      --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
    }

    /* Dark-mode surface fixes for hardcoded #fff */
    .theme-industrial .sf-screen {
      background: linear-gradient(180deg, #161c22 0%, #0e1318 100%);
    }
    .theme-industrial .sf-tally,
    .theme-industrial .sf-product,
    .theme-industrial .sf-qty-chip,
    .theme-industrial .sf-key,
    .theme-industrial .sf-mode-btn.active,
    .theme-industrial .sf-action-secondary {
      background: #1f272f;
      color: var(--ink-900);
    }
    .theme-industrial .sf-key {
      box-shadow: 0 1px 2px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.04), inset 0 -1px 0 rgba(0,0,0,.3);
    }
    .theme-industrial .sf-key:active {
      background: #161c22;
      box-shadow: inset 0 1px 3px rgba(0,0,0,.5);
    }
    .theme-industrial .sf-key-util {
      background: #161c22;
      color: var(--ink-500);
    }
    .theme-industrial .sf-product-idle {
      background: linear-gradient(180deg, #1f272f, #161c22);
      border-color: #2d3845;
    }
    .theme-industrial .sf-product-unknown,
    .theme-industrial .sf-product-dup {
      background: linear-gradient(180deg, #2a210e, #1f1808);
      border-color: #5a3f1f;
    }
    .theme-industrial .sf-action-primary {
      background: linear-gradient(180deg, #ffae00, #b87600);
      color: #1a1208;
      box-shadow: 0 4px 14px rgba(255,174,0,.35), inset 0 1px 0 rgba(255,255,255,.3);
    }
    .theme-industrial .sf-action-primary:hover {
      box-shadow: 0 6px 18px rgba(255,174,0,.42), inset 0 1px 0 rgba(255,255,255,.3);
    }
    .theme-industrial .sf-action-qty {
      background: rgba(26,18,8,.20);
      color: #1a1208;
    }
    .theme-industrial .sf-action-ghost {
      background: #1f272f;
      border-color: #2d3845;
    }
    .theme-industrial .sf-nav {
      background: rgba(14,19,24,0.78);
      border-color: #2d3845;
    }
    .theme-industrial .sf-pill-found {
      background: rgba(255,174,0,.12);
      color: var(--brand-500);
      box-shadow: inset 0 0 0 1px rgba(255,174,0,.28);
    }
    .theme-industrial .sf-pill-unknown,
    .theme-industrial .sf-pill-dup {
      background: rgba(255,174,0,.16);
      color: #ffd166;
      box-shadow: inset 0 0 0 1px rgba(255,174,0,.32);
    }
    .theme-industrial .sf-meta-cat { background: #2d3845; color: var(--ink-700); }
    .theme-industrial .sf-meta-cat-warn { background: rgba(255,174,0,.16); color: #ffd166; }
    .theme-industrial .sf-meta-divider { background: #2d3845; }
    .theme-industrial .sf-icon-btn:hover { background: #2d3845; color: var(--ink-700); }
    .theme-industrial .sf-icon-btn.on { background: rgba(255,174,0,.18); color: #ffd166; }
    .theme-industrial .sf-mode-seg { background: #161c22; }
    .theme-industrial .sf-tally-num { color: var(--brand-500); }
    .theme-industrial .sf-qty-plus {
      background: rgba(255,174,0,.12);
      border-color: rgba(255,174,0,.30);
      color: var(--brand-500);
    }
    .theme-industrial .sf-dot-online { background: var(--brand-500); box-shadow: 0 0 0 2px rgba(255,174,0,.18); }

    /* ─── C · Operational SaaS ──────────────────────────────── */
    .theme-saas {
      /* Deep navy brand */
      --brand-50:  #f0f4fa;
      --brand-100: #dce5f3;
      --brand-200: #b3c5e1;
      --brand-300: #7e9bc8;
      --brand-400: #4f72ad;
      --brand-500: #2e5188;
      --brand-600: #1f3a6b;
      --brand-700: #16294f;
      --brand-800: #0f1d3d;
      --brand-900: #0a142a;

      /* Warm cream canvas */
      --ink-25:  #fbf9f5;
      --ink-50:  #f5f1eb;
      --ink-100: #ece6dc;
      --ink-150: #e3ddd1;
      --ink-200: #d3cabb;
      --ink-300: #b3a795;
      --ink-400: #8a7d6a;
      --ink-500: #5e5447;
      --ink-600: #3f3830;
      --ink-700: #2a2520;
      --ink-800: #1a1714;
      --ink-900: #0f0d0a;
    }
    .theme-saas .sf-screen {
      background: linear-gradient(180deg, #fbf9f5 0%, #f1ebdf 100%);
    }
    .theme-saas .sf-action-primary {
      background: linear-gradient(180deg, #2e5188, #16294f);
      color: #fff;
      box-shadow: 0 4px 14px rgba(22,41,79,.30), inset 0 1px 0 rgba(255,255,255,.18);
    }
    .theme-saas .sf-action-primary:hover {
      box-shadow: 0 6px 18px rgba(22,41,79,.38), inset 0 1px 0 rgba(255,255,255,.18);
    }
    .theme-saas .sf-tally-num { color: var(--brand-700); }
    .theme-saas .sf-nav { background: rgba(251,249,245,0.78); }
    .theme-saas .sf-pill-found {
      background: var(--brand-50);
      color: var(--brand-700);
      box-shadow: inset 0 0 0 1px var(--brand-200);
    }
    .theme-saas .sf-dot-online { background: var(--brand-500); box-shadow: 0 0 0 2px rgba(46,81,136,.18); }
    .theme-saas .sf-qty-plus {
      background: var(--brand-50);
      border-color: var(--brand-200);
      color: var(--brand-700);
    }
    .theme-saas .sf-note-chip.on {
      background: var(--brand-50);
      border-color: var(--brand-200);
      color: var(--brand-700);
    }
    .theme-saas .sf-nav-btn.active { color: var(--brand-700); }
    /* Use Instrument Serif for the wordmark in the SaaS direction */
    .theme-saas .sf-wordmark-name {
      font-family: 'Instrument Serif', 'Inter', serif;
      font-size: 22px;
      font-weight: 400;
      letter-spacing: -0.01em;
    }


/* Wordmark period accent for "stocktake." */
.sf-wordmark-name .sf-wordmark-dot { color: var(--brand-500); }

/* ─── Industrial theme — Recent drawer + Settings overrides ─── */
.theme-industrial .sf-drawer {
  background: #1a232c;
  box-shadow: 0 -12px 36px rgba(0,0,0,.55);
}
.theme-industrial .sf-drawer-back { background: rgba(0,0,0,0.55); }
.theme-industrial .sf-drawer-handle { background: #3b4a5a; }
.theme-industrial .sf-drawer-close { background: #2d3845; color: #b3bdc9; }
.theme-industrial .sf-drawer-close:hover { background: #3d4955; color: #f5f7fa; }
.theme-industrial .sf-drawer-title { color: #f5f7fa; }
.theme-industrial .sf-drawer-sub { color: #8b97a6; }
.theme-industrial .sf-stat-row { background: #131a21; border-color: #2d3845; }
.theme-industrial .sf-stat-num { color: #f5f7fa; }
.theme-industrial .sf-stat-num[data-warn="true"] { color: #ffd166; }
.theme-industrial .sf-stat-lbl { color: #8b97a6; }
.theme-industrial .sf-stat-divider { background: #2d3845; }
.theme-industrial .sf-drawer-list-head { color: #8b97a6; }
.theme-industrial .sf-link-btn { color: var(--brand-500); }
.theme-industrial .sf-link-btn:hover { background: rgba(255,174,0,0.08); }
.theme-industrial .sf-entry { border-bottom-color: #232f3a; }
.theme-industrial .sf-entry-time { color: #8b97a6; }
.theme-industrial .sf-entry-desc { color: #f5f7fa; }
.theme-industrial .sf-entry-meta { color: #8b97a6; }
.theme-industrial .sf-entry-tag.muted { background: #2d3845; color: #c4cdd6; }
.theme-industrial .sf-entry-tag.warn { background: rgba(255,174,0,.14); color: #ffd166; }
.theme-industrial .sf-entry-qty { color: #f5f7fa; }
.theme-industrial .sf-drawer-foot { border-top-color: #2d3845; }
.theme-industrial .sf-foot-secondary { background: #232f3a; color: #d2d9e2; }
.theme-industrial .sf-foot-secondary:hover { background: #2d3845; }
.theme-industrial .sf-foot-primary {
  background: linear-gradient(180deg, #ffae00, #b87600);
  color: #1a1208;
  box-shadow: 0 4px 14px rgba(255,174,0,.35), inset 0 1px 0 rgba(255,255,255,.30);
}

/* Settings screen */
.theme-industrial .sf-set { background: linear-gradient(180deg, #161c22 0%, #0e1318 100%); }
.theme-industrial .sf-set-title { color: #f5f7fa; }
.theme-industrial .sf-set-back {
  background: rgba(255,255,255,0.06);
  color: #c4cdd6;
}
.theme-industrial .sf-set-back:hover { background: rgba(255,255,255,0.10); color: #f5f7fa; }
.theme-industrial .sf-set-card { background: #1a232c; border-color: #2d3845; }
.theme-industrial .sf-set-row { border-bottom-color: #232f3a; }
.theme-industrial .sf-set-row-lbl { color: #8b97a6; }
.theme-industrial .sf-set-row-val { color: #f5f7fa; }
.theme-industrial .sf-set-input {
  background: #131a21; border-color: #2d3845; color: #f5f7fa;
}
.theme-industrial .sf-set-input:focus {
  border-color: var(--brand-500);
  background: #0e1318;
  box-shadow: 0 0 0 3px rgba(255,174,0,.18);
}
.theme-industrial .sf-set-group-title { color: #8b97a6; }
.theme-industrial .sf-set-hint { color: #8b97a6; }
.theme-industrial .sf-set-foot { color: #5e6b7a; }
.theme-industrial .sf-set-switch { background: #2d3845; }
.theme-industrial .sf-set-switch[data-on="1"] { background: var(--brand-500); }
.theme-industrial .sf-set-action { border-bottom-color: #232f3a; color: #d2d9e2; }
.theme-industrial .sf-set-action:hover { background: rgba(255,255,255,0.04); }
.theme-industrial .sf-set-action-primary { color: var(--brand-500); }
.theme-industrial .sf-set-action-danger  { color: #ff8b8b; }
.theme-industrial .sf-set-action svg { color: #5e6b7a; }
.theme-industrial .sf-set-badge {
  background: var(--brand-500);
  box-shadow: 0 0 0 2px rgba(255,174,0,.18);
}

/* Settings hero — dark with amber accents (not amber gradient) */
.theme-industrial .sf-set-hero {
  background: linear-gradient(160deg, #1f272f 0%, #0e1318 100%);
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.6),
              inset 0 1px 0 rgba(255,174,0,.18),
              inset 0 0 0 1px rgba(255,174,0,.16);
}
.theme-industrial .sf-set-hero::after {
  background: radial-gradient(circle, rgba(255,174,0,.20), transparent 65%);
}
.theme-industrial .sf-set-hero-eyebrow { color: var(--brand-500); }
.theme-industrial .sf-set-hero-title { color: #f5f7fa; }
.theme-industrial .sf-set-hero-pill {
  background: rgba(255,174,0,.14);
  color: var(--brand-500);
}
.theme-industrial .sf-set-hero-pill .sf-dot {
  background: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(255,174,0,.22);
}
.theme-industrial .sf-set-hero-num { color: #f5f7fa; }
.theme-industrial .sf-set-hero-lbl { color: var(--brand-500); }
.theme-industrial .sf-set-hero-vrule { background: rgba(255,174,0,.20); }
.theme-industrial .sf-set-act-primary {
  background: var(--brand-500);
  color: #1a1208;
}
.theme-industrial .sf-set-act-primary:hover { background: var(--brand-400); }
.theme-industrial .sf-set-act-ghost {
  background: rgba(255,255,255,.06);
  color: #f5f7fa;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}
.theme-industrial .sf-set-act-ghost:hover { background: rgba(255,255,255,.10); }

/* Industrial body bg + scrollbar polish */
.theme-industrial body,
body.theme-industrial {
  background:
    radial-gradient(ellipse 50% 30% at 50% 0%, rgba(255,174,0,.08) 0%, transparent 60%),
    #0d1217;
}


/* ═══════════════════════════════════════════════════════════════
   Auth / Sign-in screen
   ═══════════════════════════════════════════════════════════════ */
.sf-auth {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(47px + 28px) 24px 34px;
  box-sizing: border-box;
  background: linear-gradient(180deg, var(--ink-50) 0%, var(--ink-100) 100%);
  position: relative;
  overflow: hidden;
  gap: 32px;
}

/* hero brand lockup */
.sf-auth-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  margin-top: 8px;
}
.sf-auth-mark {
  width: 80px;
  height: 80px;
  border-radius: 22px;
  background: #1a1208;
  color: var(--brand-500);
  display: grid;
  place-items: center;
  box-shadow:
    inset 0 0 0 1px rgba(255,174,0,.32),
    0 12px 32px -10px rgba(255,174,0,.45),
    0 0 60px -20px rgba(255,174,0,.25);
}
.sf-auth-wordmark {
  font-family: var(--font-sans);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--ink-900);
  line-height: 1;
}
.sf-auth-dot { color: var(--brand-500); }
.sf-auth-tag {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-500);
  max-width: 280px;
  line-height: 1.4;
  text-wrap: pretty;
  margin-top: -2px;
}

/* form */
.sf-auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
}
.sf-auth-mode-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-900);
  margin-bottom: -2px;
}
.sf-auth-mode-sub {
  font-size: 13px;
  color: var(--ink-500);
  margin-top: -8px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.sf-auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sf-auth-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sf-auth-field label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-500);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}
.sf-auth-field input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-900);
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: 12px;
  padding: 13px 14px;
  box-sizing: border-box;
  letter-spacing: -0.005em;
  outline: none;
  transition: all 120ms;
}
.sf-auth-field input::placeholder { color: var(--ink-400); }
.sf-auth-field input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(255,174,0,.18);
}

.sf-auth-plan-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* primary action */
.sf-auth-submit {
  height: 54px;
  border-radius: 14px;
  border: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
  color: #fff;
  box-shadow: 0 6px 18px rgba(5,136,96,.30), inset 0 1px 0 rgba(255,255,255,.18);
  transition: all 120ms;
}
.sf-auth-submit:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(5,136,96,.36), inset 0 1px 0 rgba(255,255,255,.18); }
.sf-auth-submit:active { transform: translateY(0); }
.sf-auth-submit:disabled { opacity: .65; cursor: wait; }

/* biometric (Face ID / Touch ID) sign-in button — outlined secondary */
.sf-auth-biometric {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  background: transparent;
  border: 1.5px solid var(--brand-500);
  border-radius: 12px;
  color: var(--brand-600);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s;
}
.sf-auth-biometric:hover { background: var(--brand-50); }
.sf-auth-biometric:active { transform: scale(.99); }
.sf-auth-biometric:disabled { opacity: .65; cursor: wait; }

/* "or sign in with password" divider between biometric and email/password */
.sf-auth-biometric-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 8px;
  color: var(--ink-400);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.sf-auth-biometric-or::before,
.sf-auth-biometric-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ink-200);
}

.sf-auth-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  animation: sf-auth-spin .9s linear infinite;
}
@keyframes sf-auth-spin { to { transform: rotate(360deg); } }

/* foot links */
.sf-auth-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-500);
}
.sf-auth-foot-text { font-weight: 500; }
.sf-auth-link {
  background: none;
  border: 0;
  padding: 4px 6px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-700);
  letter-spacing: -0.005em;
  border-radius: 6px;
  transition: all 100ms;
}
.sf-auth-link:hover { background: var(--brand-50); }
.sf-auth-link-sm { font-size: 11px; font-weight: 600; padding: 2px 6px; }
.sf-auth-link-arrow { font-family: var(--font-mono); display: inline-block; margin-right: 2px; }

/* footer badge */
.sf-auth-badge {
  display: inline-flex;
  align-self: center;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(11,28,23,0.04);
  border: 1px solid var(--ink-200);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-500);
  letter-spacing: 0.04em;
}
.sf-auth-badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(255,174,0,.18);
}

/* ── Industrial theme — auth screen ──────────────────────────── */
.theme-industrial .sf-auth {
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(255,174,0,.10) 0%, transparent 60%),
    linear-gradient(180deg, #161c22 0%, #0e1318 100%);
}
.theme-industrial .sf-auth-field input {
  background: #1a232c;
  border-color: #2d3845;
  color: #f5f7fa;
}
.theme-industrial .sf-auth-field input::placeholder { color: #5e6b7a; }
.theme-industrial .sf-auth-field input:focus {
  background: #131a21;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(255,174,0,.16);
}
.theme-industrial .sf-auth-submit {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
  color: #1a1208;
  box-shadow: 0 8px 22px rgba(255,174,0,.32), inset 0 1px 0 rgba(255,255,255,.30);
}
.theme-industrial .sf-auth-submit:hover {
  box-shadow: 0 12px 28px rgba(255,174,0,.40), inset 0 1px 0 rgba(255,255,255,.30);
}
.theme-industrial .sf-auth-spinner {
  border-color: rgba(26,18,8,.28);
  border-top-color: #1a1208;
}
.theme-industrial .sf-auth-link {
  color: var(--brand-500);
}
.theme-industrial .sf-auth-link:hover {
  background: rgba(255,174,0,.10);
}
.theme-industrial .sf-auth-badge {
  background: rgba(255,255,255,0.04);
  border-color: #2d3845;
}
.theme-industrial .sf-auth-biometric {
  border-color: var(--brand-500);
  color: var(--brand-400);
}
.theme-industrial .sf-auth-biometric:hover { background: rgba(255,174,0,.08); }
.theme-industrial .sf-auth-biometric-or { color: #3d4a57; }
.theme-industrial .sf-auth-biometric-or::before,
.theme-industrial .sf-auth-biometric-or::after { background: #2d3845; }


/* ═══════════════════════════════════════════════════════════════
   Camera scanner overlay
   ═══════════════════════════════════════════════════════════════ */
.sf-cam {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 80;
  color: #fff;
  font-family: var(--font-sans);
  user-select: none;
}

/* Simulated camera feed */
.sf-cam-feed {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, #2c2118 0%, #0e0a05 70%, #060403 100%);
  transition: filter 200ms;
  overflow: hidden;
}
.sf-cam-feed[data-torch="1"] {
  filter: brightness(1.35) contrast(1.05) saturate(1.1);
}
.sf-cam-feed-noise {
  position: absolute; inset: -2%;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0px, rgba(255,255,255,.012) 1px, transparent 1px, transparent 2px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0px, rgba(255,255,255,.012) 1px, transparent 1px, transparent 2px);
  opacity: .8;
  animation: sf-cam-noise 6s linear infinite;
}
.sf-cam-feed-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 80% at 50% 50%, transparent 40%, rgba(0,0,0,.6) 100%);
  pointer-events: none;
}
@keyframes sf-cam-noise {
  0%   { transform: translate(0, 0); }
  100% { transform: translate(-4px, 4px); }
}

/* Mock barcode that the viewfinder is "looking at" */
.sf-cam-mock-barcode {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) rotate(-2.5deg);
  width: 64%;
  pointer-events: none;
  opacity: .92;
  animation: sf-cam-pan 8s ease-in-out infinite alternate;
}
@keyframes sf-cam-pan {
  0%   { transform: translate(-50%, -52%) rotate(-3deg); }
  100% { transform: translate(-50%, -48%) rotate(-1.5deg); }
}
.sf-cam-mock-pkg {
  background: linear-gradient(180deg, #f4f1e8 0%, #d9d3c0 100%);
  border-radius: 4px;
  padding: 14px 14px 12px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.65), 0 2px 4px rgba(0,0,0,.4);
}
.sf-cam-mock-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: #1a1208;
  letter-spacing: 0.04em;
  text-align: center;
  margin-bottom: 6px;
}
.sf-cam-mock-bars {
  display: flex; align-items: stretch;
  gap: 1px;
  height: 56px;
  justify-content: center;
}
.sf-cam-mock-bars span {
  background: #0c0c0c;
  display: inline-block;
  height: 100%;
}
.sf-cam-mock-digits {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: #1a1208;
  letter-spacing: 0.18em;
  text-align: center;
  margin-top: 6px;
}

/* Dim mask with viewfinder cut-out */
.sf-cam-mask {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  background:
    radial-gradient(ellipse 56% 32% at 50% 50%, transparent 0%, transparent 56%, rgba(0,0,0,.62) 100%);
}

.sf-cam-viewfinder {
  position: relative;
  width: 78%;
  aspect-ratio: 1 / 1;
  max-width: 320px;
  max-height: 320px;
}

/* Corner reticle */
.sf-cam-corner {
  position: absolute;
  width: 28px; height: 28px;
  border: 3px solid var(--brand-500);
  border-radius: 4px;
}
.sf-cam-corner.tl { top: 0; left: 0;   border-right: 0; border-bottom: 0; }
.sf-cam-corner.tr { top: 0; right: 0;  border-left: 0;  border-bottom: 0; }
.sf-cam-corner.bl { bottom: 0; left: 0;  border-right: 0; border-top: 0; }
.sf-cam-corner.br { bottom: 0; right: 0; border-left: 0;  border-top: 0; }

/* Animated scan line */
.sf-cam-scanline {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 8%;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--brand-500) 50%, transparent 100%);
  box-shadow: 0 0 14px var(--brand-500), 0 0 32px rgba(255,174,0,.5);
  opacity: 0;
  animation: sf-cam-scan 2.2s cubic-bezier(.4,0,.6,1) infinite;
}
.sf-cam-scanline.on { opacity: 1; }
@keyframes sf-cam-scan {
  0%, 100% { transform: translateY(0); opacity: .9; }
  50%      { transform: translateY(290px); opacity: .9; }
}

/* "Code locked" indicator appears once detected */
.sf-cam-lock {
  position: absolute;
  bottom: -36px;
  left: 50%;
  transform: translate(-50%, 4px);
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--brand-500);
  color: #1a1208;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: all 220ms ease;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(255,174,0,.4);
}
.sf-cam-lock.on { opacity: 1; transform: translate(-50%, 0); }

/* Top + bottom chrome */
.sf-cam-top, .sf-cam-bottom {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  padding: 14px 16px;
}
.sf-cam-top {
  padding-top: calc(47px + 12px); /* iOS status bar */
  justify-content: space-between;
  gap: 12px;
}
.sf-cam-bottom {
  margin-top: auto;
  padding-bottom: calc(34px + 18px); /* home indicator */
  flex-direction: column;
  gap: 14px;
}

.sf-cam-iconbtn {
  width: 40px; height: 40px;
  border-radius: 999px;
  border: 0;
  background: rgba(255,255,255,0.10);
  color: #fff;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: grid; place-items: center;
  cursor: pointer;
  transition: all 120ms;
}
.sf-cam-iconbtn:hover { background: rgba(255,255,255,0.18); }

.sf-cam-hint {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  padding: 8px 14px;
  background: rgba(0,0,0,0.4);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  letter-spacing: -0.005em;
  animation: sf-cam-hint-in 280ms ease both;
}
@keyframes sf-cam-hint-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Live + auto-detect indicator */
.sf-cam-mode {
  display: inline-flex; align-items: center;
  gap: 7px;
  align-self: center;
  padding: 5px 12px 5px 9px;
  border-radius: 999px;
  background: rgba(0,0,0,0.5);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.sf-cam-mode-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,.32);
  animation: sf-cam-pulse 1.4s ease-in-out infinite;
}
@keyframes sf-cam-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 3px rgba(239,68,68,.32); }
  50%      { opacity: .55; box-shadow: 0 0 0 5px rgba(239,68,68,.18); }
}

.sf-cam-actions {
  display: flex; gap: 10px;
  width: 100%;
}

.sf-cam-torch {
  display: inline-flex; align-items: center;
  gap: 6px;
  height: 50px;
  padding: 0 18px;
  border-radius: 14px;
  border: 0;
  background: rgba(255,255,255,0.10);
  color: #fff;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 120ms;
}
.sf-cam-torch:hover { background: rgba(255,255,255,0.18); }
.sf-cam-torch.on {
  background: var(--brand-500);
  color: #1a1208;
  box-shadow: 0 4px 14px rgba(255,174,0,.35);
}

.sf-cam-cancel {
  flex: 1;
  height: 50px;
  border-radius: 14px;
  border: 0;
  background: rgba(255,255,255,0.10);
  color: #fff;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 120ms;
}
.sf-cam-cancel:hover { background: rgba(255,255,255,0.18); }


/* ═══════════════════════════════════════════════════════════════
   PRODUCTION EXTRAS — wiring the design to the real app
   ═══════════════════════════════════════════════════════════════ */

/* The quantity readout is a real <input id="qty"> in production (the numpad +
   barcode logic in app.js drives its .value). Style it AS the big mono display
   from the mockup instead of a boxed input. */
/* ID-level so it beats the legacy `#qty {…}` boxed-input rule in styles.css */
#qty.sf-qty-value {
  border: 0;
  background: transparent;
  padding: 0;
  width: 100%;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
  caret-color: var(--brand-500);
  font-family: var(--font-mono);
  font-size: 60px;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
  text-align: center;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}
.sf-compact #qty.sf-qty-value { font-size: 46px; }
#qty.sf-qty-value:focus { box-shadow: none; border: 0; }
#qty.sf-qty-value::-webkit-outer-spin-button,
#qty.sf-qty-value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Only one top-level screen visible at a time (driven by [hidden]) */
.sf-screen[hidden], .sf-set[hidden], .sf-auth[hidden], .sf-cam[hidden] { display: none !important; }

/* The product zone holds either the idle prompt OR the found-product card;
   app.js toggles [hidden] on #current, so collapse it cleanly when hidden. */
.sf-product[hidden] { display: none !important; }

/* The legacy #miniProduct banner is redundant in the new design (the product
   card shows the same info). app.js's showBanner() wipes our sr-only class and
   sets "banner banner-info", so hide it unconditionally. */
body.sf-app #miniProduct { display: none !important; }

/* The product name/description. The legacy cascade was collapsing it to 0px
   height (display:flow-root). Re-assert the design's clamped multi-line title
   at id-or-better specificity with an explicit min-height so it never collapses. */
body.sf-app #current .sf-product-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 20px;
  height: auto;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink-900);
}

/* Error / status banners floated above the shell */
body.sf-app .sf-banner {
  position: fixed;
  left: 12px; right: 12px;
  top: calc(max(env(safe-area-inset-top), 12px) + 8px);
  z-index: 90;
  padding: 11px 14px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
body.sf-app .sf-banner[hidden] { display: none !important; }
.sf-banner-error { background: #3a1414; color: #ffb4b4; box-shadow: inset 0 0 0 1px rgba(248,113,113,.4), 0 8px 24px rgba(0,0,0,.4); }
.sf-banner-info  { background: #13202c; color: #9fd0ff; box-shadow: inset 0 0 0 1px rgba(96,165,250,.32), 0 8px 24px rgba(0,0,0,.4); }
.sf-banner-success { background: #0f2a1f; color: #6ee7b7; box-shadow: inset 0 0 0 1px rgba(52,211,153,.4), 0 8px 24px rgba(0,0,0,.4); }

/* Screen-reader-only helper (kept from prod) */
.sf-app .sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Settings: allow real inputs/selects to adopt the field look */
.sf-set-input::placeholder { color: var(--ink-400); }
select.sf-set-input { cursor: pointer; }

/* A scrollable settings group list with the same card treatment */
.sf-set-stack { display: flex; flex-direction: column; gap: 2px; }

/* Auth lock: app.js adds body.auth-locked when signed out — hide the app
   screens (the old markup hid .topbar/main/.bottom-nav which no longer exist). */
body.auth-locked.sf-app #page-scan,
body.auth-locked.sf-app #page-config { display: none !important; }

/* The auth gate + camera overlay are full-viewport fixed layers */
body.sf-app #authGate.sf-auth {
  position: fixed;
  inset: 0;
  z-index: 70;
}
body.sf-app #authGate.sf-auth[hidden] { display: none !important; }

/* Settings is a pushed screen shown only when its tab is active */
body.sf-app #page-config.sf-set[hidden] { display: none !important; }
body.sf-app #page-scan.sf-screen[hidden] { display: none !important; }

/* The legacy entry backdrop is unused in the single-screen layout */
body.sf-app #entryBackdrop { display: none !important; }

/* Mode segment: the manual-entry ("Type") button shares sf-mode-btn styling */
.sf-mode-btn[aria-pressed="true"] { /* handled via .active toggle in app.js */ }

/* ═══════════════════════════════════════════════════════════════
   Operator pop-ups (unknown item + duplicate) as sf- bottom sheets.
   Pure scoped restyle of the legacy markup — no id/behaviour changes.
   ═══════════════════════════════════════════════════════════════ */
body.sf-app #notFoundSheet,
body.sf-app #duplicateSheet {
  position: fixed; inset: 0; z-index: 85;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: rgba(0,0,0,0.55);
  padding: 0;
  font-family: var(--font-sans);
}
body.sf-app #notFoundSheet[hidden],
body.sf-app #duplicateSheet[hidden] { display: none !important; }

body.sf-app .not-found-panel {
  background: #1a232c;
  border: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 36px rgba(0,0,0,.55);
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 18px 16px calc(max(env(safe-area-inset-bottom), 14px) + 12px);
  max-height: 92vh;
  overflow-y: auto;
  color: var(--ink-900);
  animation: sf-sheet-up 280ms cubic-bezier(.22,1,.36,1);
}
@keyframes sf-sheet-up { from { transform: translateY(12%); opacity: .6; } to { transform: translateY(0); opacity: 1; } }

body.sf-app .not-found-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
body.sf-app .not-found-header strong { font-size: 18px; font-weight: 700; letter-spacing: -.02em; color: var(--ink-900); }
body.sf-app .not-found-panel .helper { font-size: 12.5px; color: var(--ink-500); line-height: 1.4; margin-top: 4px; }
body.sf-app #notFoundSheet .btn-quiet,
body.sf-app #duplicateSheet .btn-quiet {
  border: 0; background: var(--ink-100); color: var(--ink-600);
  width: 30px; height: 30px; border-radius: 999px; padding: 0;
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
body.sf-app #notFoundSheet .btn-quiet:hover { background: var(--ink-200); }

body.sf-app .not-found-code {
  display: inline-block; margin-top: 12px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--brand-500);
  background: rgba(255,174,0,.12);
  box-shadow: inset 0 0 0 1px rgba(255,174,0,.28);
  padding: 5px 11px; border-radius: 999px;
}

body.sf-app #notFoundSheet .entry-grid,
body.sf-app #duplicateSheet .entry-grid { display: grid; gap: 12px; margin-top: 14px; }
body.sf-app #notFoundSheet .entry-grid.spaced { grid-template-columns: 1fr 1.4fr; }
body.sf-app #notFoundSheet .field { display: flex; flex-direction: column; gap: 6px; }
body.sf-app #notFoundSheet .field label,
body.sf-app #duplicateSheet .field label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  color: var(--ink-500); letter-spacing: 0.08em; text-transform: uppercase;
}
body.sf-app #notFoundSheet .field input {
  width: 100%; box-sizing: border-box;
  font-family: var(--font-sans); font-size: 16px; font-weight: 500;
  color: var(--ink-900); background: #131a21;
  border: 1px solid var(--ink-200); border-radius: 11px;
  padding: 11px 13px; outline: none; transition: all 120ms;
}
body.sf-app #notFoundSheet .field input:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(255,174,0,.16); }

/* Keypad inside the unknown-item sheet → sf- keys */
body.sf-app #notFoundSheet .numpad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-top: 14px;
}
body.sf-app #notFoundSheet .numpad .btn {
  height: 52px; border-radius: 12px; border: 0;
  background: #1f272f; color: var(--ink-900);
  font-family: var(--font-mono); font-size: 21px; font-weight: 500;
  letter-spacing: -.02em; cursor: pointer; min-height: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.04);
  transition: all 80ms;
}
body.sf-app #notFoundSheet .numpad .btn:active { background: #161c22; transform: translateY(1px); }

body.sf-app #notFoundSheet .toolbar,
body.sf-app #duplicateSheet .toolbar { display: flex; gap: 8px; margin-top: 12px; }
body.sf-app #notFoundSheet .entry-actions { margin-top: 14px; }

/* Buttons inside the sheets */
body.sf-app #notFoundSheet .btn-primary,
body.sf-app #duplicateSheet .btn-primary {
  width: 100%; height: 52px; border-radius: 14px; border: 0;
  font-family: var(--font-sans); font-size: 16px; font-weight: 600; cursor: pointer;
  background: linear-gradient(180deg, #ffae00, #b87600); color: #1a1208;
  box-shadow: 0 4px 14px rgba(255,174,0,.35), inset 0 1px 0 rgba(255,255,255,.3);
}
body.sf-app #notFoundSheet .btn-secondary,
body.sf-app #duplicateSheet .btn-secondary {
  height: 48px; padding: 0 16px; border-radius: 12px; border: 0;
  background: #232f3a; color: var(--ink-700);
  font-family: var(--font-sans); font-size: 14px; font-weight: 600; cursor: pointer;
}
body.sf-app #duplicateSheet .entry-grid.spaced { grid-template-columns: 1fr; gap: 8px; }
body.sf-app #duplicateSheet .btn-primary { background: linear-gradient(180deg, #ffae00, #b87600); }
/* Prominent "Rescan instead" sits right under the scanned code so the
   misread-correction path is one tap away — never below the keypad fold. */
body.sf-app #notFoundSheet .not-found-rescan {
  width: 100%;
  margin-top: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink-800);
}
body.sf-app #notFoundSheet .not-found-rescan svg { flex-shrink: 0; }
/* ── Animated boot splash (pulsing/glowing stocktake mark) ──
   Covers the screen while the app boots; matches the native launch image's dark
   ground so the static→animated handoff is seamless. */
#bootSplash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: #100b04;
  opacity: 1;
  transition: opacity 360ms ease;
}
#bootSplash.boot-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
#bootSplash .boot-logo {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  animation: boot-pulse 1.4s ease-in-out infinite;
  will-change: transform, filter;
}
#bootSplash .boot-logo svg { display: block; }
@keyframes boot-pulse {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 10px rgba(255,174,0,.22)); }
  50%      { transform: scale(1.07); filter: drop-shadow(0 0 30px rgba(255,174,0,.55)); }
}
@media (prefers-reduced-motion: reduce) {
  #bootSplash .boot-logo { animation: none; filter: drop-shadow(0 0 16px rgba(255,174,0,.35)); }
}

body.sf-app #notFoundSheet .not-found-photo-area { margin-top: 14px; }
body.sf-app #notFoundSheet .not-found-suggestions,
body.sf-app #notFoundSheet .stack-list,
body.sf-app #duplicateSheet .stack-list { margin-top: 10px; }
body.sf-app #duplicateSheet .stack-list > div { font-size: 14px; color: var(--ink-800); }
body.sf-app #notFoundSheet .not-found-photo-preview { max-width: 100%; border-radius: 12px; margin-top: 8px; }

/* ── Scan-tools popover (camera fallbacks) ── */
.sf-tools-panel {
  margin: -4px 16px 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--ink-100);
  border: 1px solid var(--ink-200);
  display: flex; flex-direction: column; gap: 10px;
}
.sf-tools-panel[hidden] { display: none; }
.sf-tools-hint { font-size: 12px; color: var(--ink-500); line-height: 1.4; }

/* ── Barcode scan input ──
   Off-screen but focusable by default (so Bluetooth wedge scanners + camera
   results land in it). Becomes a visible field when "Type" mode is active. */
.sf-scan-input-wrap {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%);
}
.sf-typing .sf-scan-input-wrap {
  position: static;
  width: auto; height: auto;
  overflow: visible;
  clip: auto; clip-path: none;
  padding: 0 16px 10px;
}
.sf-scan-input-wrap #scanInput {
  width: 100%; box-sizing: border-box;
  font-family: var(--font-mono); font-size: 16px; font-weight: 500;
  color: var(--ink-900); background: var(--ink-100);
  border: 1px solid var(--ink-200); border-radius: 12px;
  padding: 12px 14px; outline: none; transition: all 120ms;
  letter-spacing: 0.01em;
}
.sf-scan-input-wrap #scanInput::placeholder { color: var(--ink-400); }
.sf-scan-input-wrap #scanInput:focus { border-color: var(--brand-500); background: var(--ink-50); box-shadow: 0 0 0 3px rgba(255,174,0,.16); }

/* ── Note field under the qty readout ── */
.sf-note-wrap { padding: 0 16px 10px; }
.sf-note-wrap[hidden] { display: none; }
.sf-note-wrap input {
  width: 100%; box-sizing: border-box;
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  color: var(--ink-900); background: var(--ink-100);
  border: 1px solid var(--ink-200); border-radius: 11px;
  padding: 11px 13px; outline: none; transition: all 120ms;
}
.sf-note-wrap input::placeholder { color: var(--ink-400); }
.sf-note-wrap input:focus { border-color: var(--brand-500); background: var(--ink-50); box-shadow: 0 0 0 3px rgba(255,174,0,.16); }

/* ── Action qty badge default visibility ── */
.sf-action-qty[hidden] { display: none; }

/* Disabled primary action in the industrial theme (the theme override otherwise
   keeps it amber even when app.js disables it at qty 0). */
.theme-industrial .sf-action-primary:disabled {
  background: #1f272f;
  color: var(--ink-400);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Idle action row: hide the back button, render the primary as a single
   full-width dashed "ghost" prompt (matches the design's idle state). */
.sf-action-row.sf-action-idle .sf-action-secondary { display: none; }
.theme-industrial .sf-action-row.sf-action-idle .sf-action-primary,
.sf-action-row.sf-action-idle .sf-action-primary {
  background: #1f272f;
  color: var(--ink-400);
  border: 1px dashed var(--ink-300);
  box-shadow: none;
  cursor: default;
}

/* ── Recent drawer: scrollable counts table ── */
.sf-recent-body { width: 100%; }
.sf-table-wrap { width: 100%; overflow-x: auto; }
.sf-counts-table { width: 100%; border-collapse: collapse; font-family: var(--font-sans); }
.sf-counts-table thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  color: var(--ink-400);
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 6px 8px; border-bottom: 1px solid var(--ink-200);
  white-space: nowrap;
}
.sf-counts-table thead th.right, .sf-counts-table tbody td.right { text-align: right; }
.sf-counts-table tbody td {
  font-size: 13px; color: var(--ink-800);
  padding: 9px 8px; border-bottom: 1px solid var(--ink-100);
  white-space: nowrap;
}
.sf-counts-table tbody tr:last-child td { border-bottom: 0; }
.sf-counts-table .btn-danger {
  background: rgba(248,113,113,.14); color: #ff9b9b;
  border: 0; border-radius: 7px; padding: 5px 10px;
  font-family: var(--font-sans); font-size: 12px; font-weight: 600; cursor: pointer;
}
.sf-counts-table .btn-danger:hover { background: rgba(248,113,113,.24); }

/* ── Columns popover inside the drawer ── */
.sf-cols-panel {
  margin: 0 16px 8px; padding: 12px 14px;
  background: var(--ink-100); border: 1px solid var(--ink-200); border-radius: 12px;
}
.sf-cols-panel[hidden] { display: none; }
.sf-cols-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; }
.sf-cols-grid label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--ink-700);
}
.sf-cols-grid input { accent-color: var(--brand-500); }

/* ── Diagnostics log box in Settings ── */
.sf-logbox {
  font-family: var(--font-mono);
  font-size: 11px; line-height: 1.5;
  color: var(--ink-600);
  background: #0b1117;
  border: 1px solid var(--ink-200);
  border-radius: 12px;
  padding: 12px;
  max-height: 220px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}

/* ── Cleared-archive list items in Settings ── */
.sf-set-stack .archive-item,
.sf-set-stack > div {
  font-size: 13px; color: var(--ink-700);
}

/* ── Camera overlay: real scanner container ── */
.sf-cam-container {
  position: absolute; inset: 0;
  z-index: 1;
  display: grid; place-items: center;
  overflow: hidden;
}
.sf-cam-container video, .sf-cam-container canvas { max-width: 100%; max-height: 100%; }
.sf-cam-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  align-self: center;
  font-family: var(--font-sans); font-size: 12px; font-weight: 500;
  color: rgba(255,255,255,.75);
}
.sf-cam-toggle input { accent-color: var(--brand-500); }
.sf-cam-torch.btn-active { background: var(--brand-500); color: #1a1208; box-shadow: 0 4px 14px rgba(255,174,0,.35); }

/* ── Scan-idle affordance ─────────────────────────────────────────
   The idle prompt is the primary action on first open, but it read as a
   status card. Brand-coloured dashed border + chevron + a soft pulse make
   it unmistakably tappable. */
.sf-product-idle {
  border-style: dashed;
  border-color: var(--brand-400);
  cursor: pointer;
}
.sf-product-idle .sf-product-idle-icon { color: var(--brand-500); }
.sf-product-idle-go {
  margin-left: auto;
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-500);
  color: #1a1208;
  box-shadow: 0 4px 12px rgba(255,174,0,.30);
}
.theme-industrial .sf-product-idle {
  border-color: rgba(255,174,0,.55);
  animation: sfIdlePulse 2.8s ease-in-out infinite;
}
@keyframes sfIdlePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,174,0,.22); }
  50%      { box-shadow: 0 0 0 8px rgba(255,174,0,0); }
}
@media (prefers-reduced-motion: reduce) {
  .theme-industrial .sf-product-idle { animation: none; }
}
