/* ============================================================
   OrderBridge PWA — Design System v4
   ──────────────────────────────────────────────────────────
   TOKENS
   • --bg / --surface / --surface-2 / --surface-3  backgrounds
   • --text / --text-muted / --text-dim             typography
   • --border / --border-mid / --border-hi          borders
   • --color-primary  fixed #2B6FED                 interactive blue (buttons, FAB, focus)
   • --brand-primary  tenant CI color               large surfaces (header, login bg) — set by applyBranding()
   • --brand-surface-tint                           accent tint for cards
   • --brand-logo-url / --brand-name                white-label
   • --green / --amber / --red (+ -pale variants)   semantic
   • --header-h / --nav-h / --fab-size              layout
   • --r-sm/md/lg/xl/pill                           border radii
   • --ease-spring / --ease-out                     motion
   • --safe-t/b/l/r                                 notch/home-bar
   Fonts : Outfit (UI) · IBM Plex Mono (data)
   ============================================================ */

/* ─── Design tokens ──────────────────────────────────────────── */
:root {
  /* Brand — runtime-overridable */
  --color-primary:      #2B6FED;          /* fixed interactive blue — never changed by tenant */
  --brand-primary:      #2B6FED;          /* tenant CI color — applied to header/login bg */
  --brand-surface-tint: rgba(43, 111, 237, 0.09);
  --brand-logo-url:     none;
  --brand-name:         'OrderBridge';

  /* Backgrounds */
  --bg:        #0F1117;
  --surface:   #161B27;
  --surface-2: #1C2236;
  --surface-3: #242944;

  /* Text */
  --text:       #F0F2F7;
  --text-muted: rgba(240, 242, 247, 0.52);
  --text-dim:   rgba(240, 242, 247, 0.28);

  /* Borders */
  --border:     rgba(255, 255, 255, 0.07);
  --border-mid: rgba(255, 255, 255, 0.13);
  --border-hi:  rgba(255, 255, 255, 0.22);

  /* Semantic */
  --green:      #22C55E;
  --green-pale: rgba(34, 197, 94,  0.12);
  --amber:      #F59E0B;
  --amber-pale: rgba(245, 158, 11, 0.12);
  --red:        #EF4444;
  --red-pale:   rgba(239, 68,  68, 0.12);

  /* Shadows */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.45), 0 1px 10px rgba(0,0,0,0.28);
  --shadow-fab: 0 6px 28px rgba(43, 111, 237, 0.45);

  /* Radii */
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   20px;
  --r-xl:   26px;
  --r-pill: 999px;

  /* Typography */
  --font-ui:   'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Layout */
  --header-h: 56px;
  --nav-h:    64px;
  --fab-size: 64px;

  /* Motion */
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out:    cubic-bezier(0.00, 0.00, 0.20, 1);

  /* Safe areas */
  --safe-t: env(safe-area-inset-top,    0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left,   0px);
  --safe-r: env(safe-area-inset-right,  0px);
}

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html {
  height: 100%;
  overscroll-behavior: none;
  color-scheme: dark;
}
body {
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: var(--font-ui); cursor: pointer; }
input, button { appearance: none; -webkit-appearance: none; }

/* ─── Logo mark (shared) ────────────────────────────────────── */
.logo-mark {
  display: flex;
  align-items: center;
  color: var(--color-primary);
  flex-shrink: 0;
}
.logo-mark svg rect { fill: currentColor; }
.logo-mark--sm svg { width: 28px; height: 28px; }

/* Logo in login card → tenant brand color; logo in header → white on brand bg */
.login-logo .logo-mark { color: var(--brand-primary); }
.app-header .logo-mark { color: rgba(255, 255, 255, 0.95); }

.logo-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}


/* ══════════════════════════════════════════════════════════════
   LOGIN SCREEN
══════════════════════════════════════════════════════════════ */
.screen--login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--brand-primary);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    calc(var(--safe-t) + 24px)
    max(24px, var(--safe-r))
    calc(var(--safe-b) + 24px)
    max(24px, var(--safe-l));
}
.screen--login[hidden] { display: none; }

/* Noise overlay */
.login-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.login-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 32px 28px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.50);
}

/* Logo row */
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Hero */
.login-hero { display: flex; flex-direction: column; gap: 6px; }
.login-greeting {
  font-size: clamp(36px, 10vw, 48px);
  font-weight: 300;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}
.login-sub {
  font-size: 15px;
  color: var(--text-muted);
}

/* Form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Floating label field */
.field-wrap {
  position: relative;
}
.field-wrap--sm .field-input {
  height: 52px;
  font-size: 14px;
}
.field-input {
  width: 100%;
  height: 60px;
  background: var(--surface);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-md);
  padding: 22px 16px 8px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input--mono {
  font-family: var(--font-mono);
  font-size: 15px;
  padding-right: 48px;
}
.field-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(43, 111, 237, 0.18);
}
/* Floating label — sits at middle, floats up on focus/filled */
.field-label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  color: var(--text-muted);
  pointer-events: none;
  transition: top 0.15s, transform 0.15s, font-size 0.15s, color 0.15s, letter-spacing 0.15s;
}
.field-wrap--sm .field-label { font-size: 14px; }
.field-input:focus ~ .field-label,
.field-input:not(:placeholder-shown) ~ .field-label {
  top: 11px;
  transform: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary);
}

/* Password eye toggle */
.field-eye {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: color 0.12s;
}
.field-eye:hover { color: var(--text-muted); }

/* Login error */
.login-error {
  font-size: 13px;
  color: var(--red);
  background: var(--red-pale);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  text-align: center;
}
.login-error.shake { animation: shake 0.38s ease; }

/* Login CTA */
.login-cta {
  height: 58px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--color-primary);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  box-shadow: 0 4px 22px rgba(43, 111, 237, 0.42);
  transition: filter 0.14s, transform 0.10s;
}
.login-cta:active { transform: scale(0.97); filter: brightness(0.85); }
.login-cta:disabled { opacity: 0.6; }

/* Button inline spinner */
.btn-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Attribution */
.login-attribution {
  position: relative;
  z-index: 1;
  margin-top: 20px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.40);
  letter-spacing: 0.04em;
  text-align: center;
}


/* ══════════════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════════════ */
.app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* Top header */
.app-header {
  flex-shrink: 0;
  height: calc(var(--header-h) + var(--safe-t));
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left:  max(16px, var(--safe-l));
  padding-right: max(16px, var(--safe-r));
  background: var(--brand-primary);
  border-bottom: 1px solid rgba(0,0,0,0.15);
}
.app-header__brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
.app-header__name {
  font-size: 17px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: -0.01em;
}
.tenant-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 3px 9px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
}

/* Screen slot */
.app-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* Tab screens — stacked, active one fades in */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease-out);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* Screen sub-header (History, Profile) */
.screen-hdr {
  flex-shrink: 0;
  padding: 20px 16px 12px;
}
.screen-hdr__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}


/* ══════════════════════════════════════════════════════════════
   BOTTOM NAV + FAB
══════════════════════════════════════════════════════════════ */
.bottom-nav {
  flex-shrink: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  padding-left:  max(0px, var(--safe-l));
  padding-right: max(0px, var(--safe-r));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
}
.nav-btn--scan { color: var(--color-primary); }

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  height: 100%;
  padding: 0 4px;
  color: var(--text-dim);
  transition: color 0.15s;
  position: relative;
}
.nav-btn.active { color: var(--color-primary); }
.nav-btn__ico-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-btn__lbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nav-cart-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 17px;
  height: 17px;
  background: var(--red);
  color: #fff;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--surface);
}

/* FAB */
.fab {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) * 0.42 + var(--safe-b));
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-fab);
  z-index: 10;
  transition: transform 0.14s, filter 0.14s;
}
.fab:active { transform: translateX(-50%) scale(0.91); filter: brightness(0.85); }

/* Pulsing ring around FAB */
.fab__ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(43, 111, 237, 0.40);
  animation: fabRing 2.6s ease-in-out infinite;
}
@keyframes fabRing {
  0%, 100% { transform: scale(1);    opacity: 0.55; }
  50%       { transform: scale(1.16); opacity: 0; }
}


/* ══════════════════════════════════════════════════════════════
   CART SCREEN
══════════════════════════════════════════════════════════════ */
.screen--cart { overflow: hidden; }

/* Empty state */
.cart-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 28px 48px;
  text-align: center;
}
.cart-empty__art { opacity: 0.90; }
.cart-empty__title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.cart-empty__sub {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Cart with items */
.cart-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 0;
  min-height: 0;
}
.cart-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 10px;
}
.cart-top-bar__count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cart-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 16px;
}

/* Cart item — swipe to reveal delete */
.cart-item {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  min-height: 72px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.cart-item__delete-reveal {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.cart-item__del-btn {
  background: none;
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.cart-item__inner {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  min-height: 72px;
  transition: transform 0.25s var(--ease-spring);
}
.cart-item__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cart-item__sap {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-primary);
  letter-spacing: 0.04em;
  opacity: 0.85;
}
.cart-item__name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-item__ctrl {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.qty-mini-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border-mid);
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.10s, transform 0.08s;
}
.qty-mini-btn:not(:disabled):active { background: var(--color-primary); border-color: var(--color-primary); transform: scale(0.88); }
.qty-mini-btn:disabled { opacity: 0.32; cursor: default; }
.qty-mini-val {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
  color: var(--text);
  font-feature-settings: 'tnum';
}

/* Submit CTA bar — sticky bottom of cart screen */
.cart-cta-bar {
  flex-shrink: 0;
  padding: 12px 16px calc(16px + var(--safe-b));
  background: var(--bg);
  border-top: 1px solid var(--border);
}


/* ══════════════════════════════════════════════════════════════
   HISTORY SCREEN
══════════════════════════════════════════════════════════════ */
.history-body {
  flex: 1;
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.history-empty {
  font-size: 15px;
  color: var(--text-muted);
  padding: 40px 0;
  text-align: center;
}

.history-group { display: flex; flex-direction: column; gap: 8px; }
.history-group__date {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 2px;
}
.history-timeline { display: flex; flex-direction: column; gap: 6px; }

/* Order card */
.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s;
}
.order-card:active { border-color: var(--border-hi); }

.order-card__hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
  gap: 10px;
}
.order-card__id { display: flex; flex-direction: column; gap: 2px; }
.order-card__sap {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}
.order-card__ref {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.order-card__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.order-card__chevron {
  color: var(--text-dim);
  transition: transform 0.22s var(--ease-spring);
}
.order-card.expanded .order-card__chevron { transform: rotate(180deg); }

.order-card__meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 16px 14px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.4;
}
.order-card__meta span:last-child {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* Expandable body */
.order-card__body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  flex-direction: column;
  gap: 8px;
}
.order-card.expanded .order-card__body { display: flex; }

.order-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}
.odr__lbl { color: var(--text-muted); }
.odr__val {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: var(--r-pill);
}
.status-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.status-badge--delivered { color: var(--green); background: var(--green-pale); }
.status-badge--shipping  { color: #3B82F6; background: rgba(59,  130, 246, 0.12); }
.status-badge--confirmed { color: #8B5CF6; background: rgba(139,  92, 246, 0.12); }
.status-badge--cancelled { color: #EF4444; background: rgba(239,  68,  68, 0.12); }
.status-badge--pending   { color: #6B7280; background: rgba(107, 114, 128, 0.12); }

/* Load / error state (history + generic) */
.load-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 24px;
  color: var(--text-muted);
  font-size: 15px;
  text-align: center;
}
.load-state svg { color: var(--red); }


/* ══════════════════════════════════════════════════════════════
   PROFILE SCREEN
══════════════════════════════════════════════════════════════ */
.screen--profile {
  padding-bottom: calc(var(--safe-b) + 24px);
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px 24px;
}
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand-surface-tint);
  border: 2px solid rgba(43, 111, 237, 0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--color-primary);
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.profile-user { min-width: 0; }
.profile-user__name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}
.profile-user__email {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-section {
  margin-bottom: 8px;
}
.settings-section__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 16px 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row--toggle { border-bottom: 1px solid var(--border); }
.settings-row__ico {
  width: 30px;
  height: 30px;
  background: var(--surface-2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.settings-row__label {
  flex: 1;
  font-size: 15px;
  color: var(--text);
}
.settings-row__value {
  font-size: 14px;
  color: var(--text-muted);
}
.settings-row__value--green { color: var(--green); }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__track {
  width: 48px;
  height: 28px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  border: 1.5px solid var(--border-mid);
  position: relative;
  transition: background 0.22s, border-color 0.22s;
}
.toggle input:checked ~ .toggle__track {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  transition: transform 0.22s var(--ease-spring);
}
.toggle input:checked ~ .toggle__track .toggle__thumb { transform: translateX(20px); }

/* Logout */
.profile-logout-wrap {
  padding: 24px 16px 8px;
}
.logout-btn {
  width: 100%;
  height: 52px;
  border: 1.5px solid rgba(239, 68, 68, 0.40);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--red);
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.14s, border-color 0.14s;
}
.logout-btn:active {
  background: var(--red-pale);
  border-color: var(--red);
}


/* ══════════════════════════════════════════════════════════════
   SCANNER MODAL
══════════════════════════════════════════════════════════════ */
.scanner-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  visibility: hidden;
  transition:
    transform 0.42s var(--ease-spring),
    visibility 0s linear 0.42s;
}
.scanner-modal.is-open {
  transform: translateY(0);
  visibility: visible;
  transition:
    transform 0.42s var(--ease-spring),
    visibility 0s linear 0s;
}

/* Modal header */
.scanner-modal__hdr {
  position: relative;
  z-index: 20;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding:
    calc(var(--safe-t) + 12px)
    max(16px, var(--safe-r))
    12px
    max(16px, var(--safe-l));
  background: rgba(10, 12, 18, 0.82);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.scanner-modal__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Batch mode toggle */
.batch-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.batch-toggle input { display: none; }
.batch-toggle__pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.10);
  border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: var(--r-pill);
  padding: 6px 12px 6px 8px;
  transition: background 0.18s, border-color 0.18s;
}
.batch-toggle input:checked ~ .batch-toggle__pill {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.45);
}
.batch-toggle__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.18s, box-shadow 0.18s;
}
.batch-toggle input:checked ~ .batch-toggle__pill .batch-toggle__dot {
  background: var(--green);
  box-shadow: 0 0 8px 2px rgba(34, 197, 94, 0.60);
}
.batch-toggle__lbl {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.batch-toggle input:checked ~ .batch-toggle__pill .batch-toggle__lbl { color: var(--green); }
.batch-count {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* Close button */
.scanner-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, transform 0.08s;
}
.scanner-close:active { background: rgba(255,255,255,0.16); transform: scale(0.91); }

/* Viewport */
.scanner-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;   /* iOS: flex-child height-100% fix */
  height: 60vh;    /* Fallback wenn flex nicht greift */
}
.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Scan overlay */
.scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  pointer-events: none;
}
.scan-frame {
  position: relative;
  width: min(260px, 68vw);
  aspect-ratio: 1;
  border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(8, 10, 16, 0.72);
}
/* Corner brackets */
.sc {
  position: absolute;
  width: 28px;
  height: 28px;
  animation: cornerPulse 2s ease-in-out infinite;
}
.sc--tl { top: -2px; left: -2px;  border-top: 3px solid var(--color-primary); border-left:  3px solid var(--color-primary); border-radius: 4px 0 0 0; }
.sc--tr { top: -2px; right: -2px; border-top: 3px solid var(--color-primary); border-right: 3px solid var(--color-primary); border-radius: 0 4px 0 0; animation-delay: 0.15s; }
.sc--bl { bottom: -2px; left: -2px;  border-bottom: 3px solid var(--color-primary); border-left:  3px solid var(--color-primary); border-radius: 0 0 0 4px; animation-delay: 0.30s; }
.sc--br { bottom: -2px; right: -2px; border-bottom: 3px solid var(--color-primary); border-right: 3px solid var(--color-primary); border-radius: 0 0 4px 0; animation-delay: 0.45s; }
@keyframes cornerPulse {
  0%, 100% { opacity: 0.55; }
  50%       { opacity: 1;    }
}
/* Scan success */
.scan-frame--ok .sc { border-color: var(--green); animation: none; opacity: 1; filter: drop-shadow(0 0 4px rgba(34,197,94,0.70)); }
.scan-frame--ok .scan-beam { background: linear-gradient(90deg, transparent, rgba(34,197,94,0.40), var(--green), rgba(34,197,94,0.40), transparent); box-shadow: 0 0 14px 4px rgba(34,197,94,0.55); }

/* Scan beam */
.scan-beam {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(43,111,237,0.30) 15%, var(--color-primary) 50%, rgba(43,111,237,0.30) 85%, transparent 100%);
  box-shadow: 0 0 10px 3px rgba(43,111,237,0.50);
  border-radius: 2px;
  animation: beamMove 2.4s ease-in-out infinite;
}
@keyframes beamMove {
  0%   { top: 6px;              opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { top: calc(100% - 8px); opacity: 0; }
}

.scan-label {
  font-size: 13px;
  color: rgba(240, 242, 247, 0.55);
  text-shadow: 0 1px 4px rgba(0,0,0,0.80);
}

/* No camera fallback */
.no-cam {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 15px;
  text-align: center;
  padding: 24px;
}

/* Scanner footer */
.scanner-footer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding:
    12px
    max(16px, var(--safe-r))
    calc(var(--safe-b) + 12px)
    max(16px, var(--safe-l));
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 42%;
}
.scanner-manual-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.manual-input {
  flex: 1;
  height: 44px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  padding: 0 18px;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.manual-input::placeholder { color: var(--text-dim); font-family: var(--font-ui); }
.manual-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(43,111,237,0.14);
}
.scanner-recent__hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.scanner-recent__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Recent items */
.recent-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ri {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  min-height: 52px;
  transition: background 0.12s;
}
.ri:active { background: rgba(255,255,255,0.05); }
.ri__ico {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.ri__body { flex: 1; min-width: 0; }
.ri__name { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri__code { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.ri__arr  { color: var(--text-dim); flex-shrink: 0; display: flex; align-items: center; }
.recent-empty { font-size: 13px; color: var(--text-dim); padding: 4px 8px; }


/* ══════════════════════════════════════════════════════════════
   DETAIL BOTTOM SHEET
══════════════════════════════════════════════════════════════ */
.detail-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  z-index: 10;
  max-height: 72vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.38s var(--ease-spring);
}
.detail-sheet.is-open { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-mid);
  border-radius: var(--r-pill);
  margin: 12px auto 4px;
  cursor: pointer;
}

/* Sheet loading / error states */
.sheet-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 36px 24px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}
.sheet-state--err svg { color: var(--red); }

/* Sheet material content */
.sheet-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 6px 20px 28px;
}
.sheet-mat-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.sheet-mat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  background: var(--brand-surface-tint);
  border: 1px solid rgba(43,111,237,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  flex-shrink: 0;
}
.sheet-mat-info { flex: 1; min-width: 0; }
.sheet-mat-sap {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-primary);
  letter-spacing: 0.04em;
  opacity: 0.85;
  margin-bottom: 4px;
}
.sheet-mat-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

/* Sheet actions: qty + CTA side by side */
.sheet-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}


/* ══════════════════════════════════════════════════════════════
   SHARED COMPONENTS
══════════════════════════════════════════════════════════════ */

/* Availability badge */
.avail-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--green);
  background: var(--green-pale);
  border: 1px solid rgba(34,197,94,0.22);
  padding: 4px 10px 4px 8px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  white-space: nowrap;
}
.avail-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

/* Stock chips */
.stock-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stock-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stock-chip__val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  font-feature-settings: 'tnum';
}
.stock-chip__lbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Qty stepper */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.qty-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--border-mid);
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.10s, border-color 0.10s, transform 0.08s;
}
.qty-btn:not(:disabled):active { background: var(--color-primary); border-color: var(--color-primary); transform: scale(0.87); }
.qty-btn:disabled { opacity: 0.32; cursor: default; }
.qty-val {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  min-width: 34px;
  text-align: center;
  font-feature-settings: 'tnum';
  letter-spacing: -0.02em;
}

/* CTA button */
.cta-btn {
  height: 56px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  box-shadow: 0 4px 20px rgba(43,111,237,0.40);
  transition: filter 0.14s, transform 0.10s;
  width: 100%;
}
.cta-btn:active { transform: scale(0.97); filter: brightness(0.85); }
.cta-btn--success { background: var(--green) !important; box-shadow: 0 4px 18px rgba(34,197,94,0.38) !important; }
.cta-btn--flex { flex: 1; width: auto; }

/* Outline / ghost buttons */
.outline-btn {
  height: 40px;
  padding: 0 20px;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 14px;
  transition: border-color 0.12s, color 0.12s;
}
.outline-btn:active { border-color: var(--border-hi); color: var(--text); }
.outline-btn--accent { border-color: var(--color-primary); color: var(--color-primary); }
.outline-btn--accent:active { background: var(--brand-surface-tint); }

.ghost-btn {
  height: 44px;
  padding: 0 22px;
  border-radius: var(--r-pill);
  border: 1.5px solid rgba(43,111,237,0.35);
  background: var(--brand-surface-tint);
  color: var(--color-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.12s;
}
.ghost-btn:active { background: rgba(43,111,237,0.18); }

.ghost-pill-btn {
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  border: 1.5px solid rgba(43,111,237,0.32);
  background: rgba(43,111,237,0.14);
  color: var(--color-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
  transition: background 0.12s;
}
.ghost-pill-btn:active { background: rgba(43,111,237,0.26); }

.text-btn {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 2px;
  transition: color 0.12s;
}
.text-btn:hover  { color: var(--text); }
.text-btn--danger { color: var(--red); }
.text-btn--danger:active { opacity: 0.75; }

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-mid);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}


/* ══════════════════════════════════════════════════════════════
   KEYFRAME ANIMATIONS
══════════════════════════════════════════════════════════════ */
@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { opacity: 1;   transform: scale(1);    }
  50%       { opacity: 0.5; transform: scale(0.75); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0);   }
  20%       { transform: translateX(-7px); }
  60%       { transform: translateX(7px);  }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0);     }
}


/* ══════════════════════════════════════════════════════════════
   ORDER ITEMS LIST  (inside history card .order-card__body)
══════════════════════════════════════════════════════════════ */
.order-card__pos-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
}

.order-items-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 220px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--r-md) var(--r-md);
}

.order-item-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}
.order-item-row:last-child { border-bottom: none; }

.oir__no {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.oir__name {
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.oir__qty {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.73rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
}


/* ══════════════════════════════════════════════════════════════
   TOAST  (global, bottom-center)
══════════════════════════════════════════════════════════════ */
.pwa-toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(360px, calc(100vw - 32px));
}

.pwa-toast {
  background: var(--surface-3);
  border: 1px solid var(--border-hi);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 10px 16px;
  border-radius: var(--r-md);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
  text-align: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.pwa-toast--visible {
  opacity: 1;
  transform: translateY(0);
}
.pwa-toast--update {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.pwa-toast__reload {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}


/* ══════════════════════════════════════════════════════════════
   LANGUAGE SWITCHER
══════════════════════════════════════════════════════════════ */
.lang-switcher {
  display: flex;
  gap: 4px;
}

.lang-btn {
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.lang-btn--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.lang-btn:not(.lang-btn--active):hover {
  background: var(--surface-3);
  color: var(--text);
}

/* red value variant for disconnected state */
.settings-row__value--red {
  color: var(--red);
}
