/* Purchase Helper — web client.
   The look is the Android app's: ui/theme/Color.kt and Theme.kt supply the palette, and the
   Material 3 type scale and corner radii are carried over from the Compose screens. Sized for a
   phone held in one hand: 44px tap targets, safe-area insets, no horizontal scroll at 320px. */

:root {
  /* LightColorScheme in Theme.kt */
  --primary: #334155;
  --on-primary: #ffffff;
  --primary-container: #f1f5f9;
  --on-primary-container: #0f172a;
  --secondary: #0284c7;
  --secondary-container: #e0f2fe;
  --on-secondary-container: #0369a1;
  --tertiary: #0d9488;
  --on-tertiary: #ffffff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --on-surface: #0f172a;
  --surface-variant: #f1f5f9;
  --on-surface-variant: #475569;
  --outline: #94a3b8;
  --outline-variant: #e2e8f0;
  --error: #dc2626;
  --on-error: #ffffff;
  --error-container: #f9dedc;
  --on-error-container: #410e0b;
  /* Hard-coded in ProductCard.kt and ProductDetailDialog.kt for "Partially Completed" */
  --partial: #e65100;
  --partial-bg: #fff3e0;

  --shadow-1: 0 1px 2px rgba(15, 23, 42, .08), 0 1px 3px 1px rgba(15, 23, 42, .06);
  --shadow-3: 0 1px 3px rgba(15, 23, 42, .1), 0 4px 8px 3px rgba(15, 23, 42, .08);
  --scrim: rgba(0, 0, 0, .32);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

/* DarkColorScheme in Theme.kt */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #cbd5e1;
    --on-primary: #0f172a;
    --primary-container: #334155;
    --on-primary-container: #f1f5f9;
    --secondary-container: #1e293b;
    --on-secondary-container: #cbd5e1;
    --bg: #090d16;
    --surface: #131b2e;
    --on-surface: #f1f5f9;
    --surface-variant: #1e293b;
    --on-surface-variant: #94a3b8;
    --outline: #64748b;
    --outline-variant: #334155;
    --on-error: #601410;
    --error-container: #8c1d18;
    --on-error-container: #f9dedc;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-3: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 8px 3px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --primary: #cbd5e1;
  --on-primary: #0f172a;
  --primary-container: #334155;
  --on-primary-container: #f1f5f9;
  --secondary-container: #1e293b;
  --on-secondary-container: #cbd5e1;
  --bg: #090d16;
  --surface: #131b2e;
  --on-surface: #f1f5f9;
  --surface-variant: #1e293b;
  --on-surface-variant: #94a3b8;
  --outline: #64748b;
  --outline-variant: #334155;
  --on-error: #601410;
  --error-container: #8c1d18;
  --on-error-container: #f9dedc;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-3: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 8px 3px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--on-surface);
  font: 14px/20px Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100dvh; overscroll-behavior: none; }
.view[hidden], [hidden] { display: none !important; }
body.app-open { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }

.ic { width: 24px; height: 24px; fill: currentColor; flex: 0 0 auto; display: block; }
.ic.s14 { width: 14px; height: 14px; }
.ic.s16 { width: 16px; height: 16px; }
.ic.s18 { width: 18px; height: 18px; }
.ic.s20 { width: 20px; height: 20px; }
.ic.s22 { width: 22px; height: 22px; }
.ic.s32 { width: 32px; height: 32px; }
.ic.s36 { width: 36px; height: 36px; }
.ic.s44 { width: 44px; height: 44px; }
.ic.s48 { width: 48px; height: 48px; }
.ic.s56 { width: 56px; height: 56px; }

/* Text styles (Material 3 type scale) ------------------------------------ */

.t-headline-s { font-size: 24px; line-height: 32px; font-weight: 700; }
.t-title-l { font-size: 22px; line-height: 28px; font-weight: 700; }
.t-title-m { font-size: 16px; line-height: 24px; font-weight: 700; letter-spacing: .15px; }
.t-body-l { font-size: 16px; line-height: 24px; }
.t-body-m { font-size: 14px; line-height: 20px; }
.t-body-s { font-size: 12px; line-height: 16px; }
.t-label-l { font-size: 14px; line-height: 20px; font-weight: 500; }
.t-label-m { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .5px; }
.t-label-s { font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: .5px; }
.bold { font-weight: 700; }
.semi { font-weight: 600; }
.c-primary { color: var(--primary); }
.c-outline { color: var(--outline); }
.c-secondary { color: var(--secondary); }
.c-tertiary { color: var(--tertiary); }
.c-variant { color: var(--on-surface-variant); }
.c-error { color: var(--error); }
.c-partial { color: var(--partial); }
.center { text-align: center; }

/* Buttons ---------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border-radius: 12px;
  font-size: 14px; font-weight: 500; letter-spacing: .1px;
  white-space: nowrap;
}
.btn.filled { background: var(--primary); color: var(--on-primary); }
.btn.filled:disabled { background: color-mix(in srgb, var(--on-surface) 12%, transparent); color: color-mix(in srgb, var(--on-surface) 38%, transparent); }
.btn.danger { background: var(--error); color: #fff; }
.btn.partial { background: var(--partial); color: #fff; }
.btn.outlined { border: 1px solid var(--outline); color: var(--primary); }
.btn.outlined.danger-text { color: var(--error); border-color: var(--outline); background: none; }
.btn.text { color: var(--primary); padding: 0 12px; }
.btn.text.danger-text { color: var(--error); }
.btn.small { min-height: 32px; font-size: 11px; padding: 0 8px; }
.btn.block { width: 100%; }
.btn .ic { width: 18px; height: 18px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-grid; place-items: center;
  color: var(--on-surface-variant);
  position: relative;
}
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.tint-primary, .icon-btn.is-active { color: var(--primary); }
.icon-btn.tint-error { color: var(--error); }
.icon-btn:active { background: color-mix(in srgb, var(--on-surface) 10%, transparent); }

.badge-dot {
  position: absolute; top: 6px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px;
  background: var(--error); color: #fff;
  font-size: 11px; line-height: 16px; font-weight: 500; text-align: center;
}

/* Form fields (OutlinedTextField) ---------------------------------------- */

.field { display: grid; gap: 4px; min-width: 0; }
.field-label { font-size: 12px; line-height: 16px; color: var(--on-surface-variant); }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: transparent;
  font-size: 16px; /* 16px stops iOS zooming the page on focus */
}
.field textarea { resize: vertical; min-height: 72px; line-height: 22px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border: 2px solid var(--primary); padding: 11px 13px;
}
.field.is-set select { border-color: var(--primary); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 12px; }
.strong { font-weight: 600; }

/* Sign in ---------------------------------------------------------------- */

#signin-view {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
}
.signin-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow-3);
  padding: 24px;
  display: grid; gap: 16px;
}
.signin-head { display: flex; align-items: center; gap: 14px; }
.signin-mark {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary);
  flex: 0 0 auto;
}
.signin-head h1 { margin: 0; font-size: 22px; line-height: 28px; font-weight: 700; }
.signin-sub { margin: 0; font-size: 12px; color: var(--outline); }
.signin-body { margin: 0; color: var(--on-surface-variant); }
.signin-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px; }
#code { letter-spacing: 8px; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }
.hint { margin: 0; font-size: 12px; min-height: 16px; color: var(--on-surface-variant); }
.hint:empty { display: none; }
.hint.error { color: var(--error); }
.hint.ok { color: var(--tertiary); }

/* App shell -------------------------------------------------------------- */

#app-view {
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg);
}

.topbar {
  flex: 0 0 auto;
  background: var(--surface);
  padding-top: var(--safe-top);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
  position: relative; z-index: 3;
}
.topbar-row { display: flex; align-items: center; height: 64px; padding: 0 4px; gap: 0; }
.topbar-title { flex: 1 1 auto; min-width: 0; padding-left: 4px; }
.topbar-title h1 {
  margin: 0; font-size: 16px; line-height: 22px; font-weight: 700; letter-spacing: 1.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title p {
  margin: 0; font-size: 11px; line-height: 14px; font-weight: 500; color: var(--outline);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.search-row { padding: 8px 16px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--outline-variant);
  border-radius: 24px;
  padding: 0 4px 0 14px;
  min-height: 52px;
  color: var(--primary);
}
.search-box:focus-within { border-color: var(--primary); }
.search-box input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-size: 16px; color: var(--on-surface); padding: 10px 0;
}
.search-box input::placeholder { font-size: 13px; color: var(--on-surface-variant); }
.search-box input::-webkit-search-cancel-button { display: none; }

/* ScrollableTabRow */
.tabs {
  flex: 0 0 auto;
  display: flex;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--outline-variant);
  padding: 0 12px;
  scrollbar-width: none;
  position: relative; z-index: 2;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 48px;
  padding: 10px 16px;
  font-size: 12px; font-weight: 500; letter-spacing: .5px;
  color: var(--on-surface-variant);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab.is-active { color: var(--primary); font-weight: 700; border-bottom-color: var(--primary); }
.tab-count {
  border-radius: 10px; padding: 2px 7px;
  font-size: 11px; line-height: 14px; font-weight: 700;
  background: var(--surface-variant); color: var(--on-surface-variant);
}
.tab.is-active .tab-count { background: var(--primary); color: var(--on-primary); }

.filter-banner {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 16px;
  background: color-mix(in srgb, var(--secondary-container) 50%, transparent);
  color: var(--on-secondary-container);
  font-size: 11px; font-weight: 600;
}

.banner {
  flex: 0 0 auto;
  margin: 8px 16px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--partial-bg); color: var(--partial);
  font-size: 12px;
}

/* HorizontalPager: swipe between the four tabs */
.pager {
  flex: 1 1 auto; min-height: 0;
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.pager::-webkit-scrollbar { display: none; }
.page {
  flex: 0 0 100%; width: 100%;
  scroll-snap-align: start; scroll-snap-stop: always;
  overflow-y: auto; overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}
.page-inner { max-width: 760px; margin: 0 auto; }
.list {
  display: grid; gap: 14px;
  padding: 16px 16px calc(96px + var(--safe-bottom));
}

/* Duplicate alert banner on the ALL tab */
.dup-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 16px 0;
  padding: 10px 8px 10px 14px;
  border-radius: 12px;
  background: var(--error-container); color: var(--on-error-container);
  cursor: pointer;
}
.dup-banner .ic { color: var(--error); }
.dup-banner-text { flex: 1; min-width: 0; }
.dup-banner-text b { display: block; font-size: 12px; letter-spacing: .5px; }
.dup-banner-text span { font-size: 12px; line-height: 16px; opacity: .85; }
.dup-banner .btn.text { color: var(--error); font-weight: 700; padding: 0 6px; }

/* Empty state */
.empty {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 24px calc(96px + var(--safe-bottom));
  text-align: center;
}
.empty-icon {
  width: 80px; height: 80px; border-radius: 20px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface-variant) 60%, transparent);
  color: var(--primary);
  margin-bottom: 18px;
}
.empty h2 { margin: 0 0 8px; font-size: 22px; line-height: 28px; font-weight: 700; }
.empty p { margin: 0 24px; color: var(--outline); max-width: 420px; }
.empty .note { margin-top: 10px; font-size: 12px; }
.empty-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; justify-content: center; }

/* ProductCard -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-3);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.card.is-finished { background: color-mix(in srgb, var(--surface-variant) 50%, var(--bg)); }
.card-image {
  position: relative; display: block; width: 100%;
  aspect-ratio: 2 / 1;
  background: var(--surface-variant);
  overflow: hidden;
}
.card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-image::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, transparent 40%, rgba(0, 0, 0, .35));
}
.placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--outline);
  font-size: 11px; font-weight: 500;
}
.placeholder .ic { opacity: .6; }
.status-chip {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  padding: 6px 10px; border-radius: 8px;
  font-size: 11px; line-height: 14px; font-weight: 700;
  background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--on-surface);
}
.status-chip.finished { background: color-mix(in srgb, var(--primary-container) 95%, transparent); color: var(--primary); }
.status-chip.partial { background: color-mix(in srgb, var(--partial-bg) 95%, transparent); color: var(--partial); }
.zoom-chip {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--on-surface);
}
.note-chip {
  position: absolute; bottom: 8px; left: 8px; z-index: 1;
  padding: 2px 6px; border-radius: 4px;
  background: var(--tertiary); color: var(--on-tertiary);
  font-size: 9px; line-height: 14px; font-weight: 700; letter-spacing: .3px;
}
.card-data { display: block; width: 100%; text-align: left; padding: 14px; }
.partial-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 6px 10px; margin-bottom: 8px;
  border-radius: 8px;
  background: var(--partial-bg); color: var(--partial);
  font-weight: 700;
}
.partial-strip .lbl { display: flex; align-items: center; gap: 6px; font-size: 10px; letter-spacing: .5px; }
.partial-strip .lbl::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--partial); }
.partial-strip .val { font-size: 11px; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-name {
  flex: 1; min-width: 0;
  font-size: 16px; line-height: 24px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-chip {
  flex: 0 1 auto; min-width: 0; max-width: 45%;
  padding: 3px 8px; border-radius: 6px;
  background: var(--primary-container); color: var(--on-primary-container);
  font-size: 11px; line-height: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-chip:empty { display: none; }
.same-chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px; border-radius: 6px;
  background: var(--error-container); color: var(--on-error-container);
  font-size: 9px; font-weight: 700;
}
.same-chip .ic { width: 11px; height: 11px; color: var(--error); }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; margin-top: 8px; }
.df { min-width: 0; }
.df small { display: block; font-size: 10px; line-height: 14px; font-weight: 500; color: var(--outline); }
.df span { display: block; font-size: 12px; line-height: 16px; font-weight: 500; overflow-wrap: anywhere; }
.card-foot { margin-top: 8px; text-align: right; font-size: 11px; font-weight: 500; color: var(--primary); }

/* FAB (SmallFloatingActionButton) */
.fab {
  position: fixed; z-index: 4;
  right: 16px; bottom: calc(24px + var(--safe-bottom));
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary);
  box-shadow: var(--shadow-3);
}
@media (min-width: 800px) { .fab { right: calc(50% - 380px + 16px); } }

/* Sidebar ------------------------------------------------------------------ */

.scrim { position: fixed; inset: 0; z-index: 10; background: var(--scrim); }
.drawer {
  position: fixed; z-index: 11; top: 0; bottom: 0; left: 0;
  width: min(320px, 86vw);
  background: var(--surface);
  border-radius: 0 24px 24px 0;
  overflow-y: auto;
  transform: translateX(-105%);
  transition: transform .22s ease;
  visibility: hidden;
  padding-bottom: calc(24px + var(--safe-bottom));
}
.drawer.is-open { transform: none; visibility: visible; }
.drawer-head {
  padding: calc(20px + var(--safe-top)) 20px 20px;
  background: linear-gradient(to bottom, var(--primary), color-mix(in srgb, var(--primary) 82%, transparent));
  color: var(--on-primary);
}
.drawer-brand { display: flex; align-items: center; gap: 14px; }
.drawer-logo {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--on-primary) 20%, transparent);
}
.drawer-brand b { display: block; font-size: 16px; line-height: 24px; }
.drawer-brand span { font-size: 11px; opacity: .85; }
.drawer-mail {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 14px; padding: 6px 10px; border-radius: 8px;
  background: rgba(0, 0, 0, .2);
  font-size: 11px;
  max-width: 100%; overflow-wrap: anywhere;
}
.drawer-section {
  padding: 20px 20px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--outline);
}
.drawer-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 12px 20px;
}
.drawer-item:active { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.drawer-ic {
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.drawer-ic .ic { width: 22px; height: 22px; }
.drawer-item b { display: block; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--on-surface); }
.drawer-item small { display: block; font-size: 11px; line-height: 16px; color: var(--outline); overflow-wrap: anywhere; }
.drawer-info {
  margin: 16px 20px 0; padding: 14px;
  border: 1px solid var(--outline-variant); border-radius: 14px;
  background: color-mix(in srgb, var(--surface-variant) 50%, transparent);
}
.drawer-info b { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.drawer-info b .ic { color: var(--primary); }
.drawer-info p { margin: 6px 0 0; font-size: 11px; line-height: 16px; color: var(--on-surface-variant); white-space: pre-line; }

/* Dialogs -------------------------------------------------------------------- */

.modal {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: var(--scrim);
  padding: calc(8px + var(--safe-top)) 0 calc(8px + var(--safe-bottom));
}
.modal.dark { background: rgba(0, 0, 0, .95); padding: 0; }
.dialog {
  width: 92vw; max-width: 600px;
  max-height: 100%;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.dialog.tall { height: 92dvh; }
.dialog.medium { height: 85dvh; }
.dialog.full { width: calc(100vw - 32px); height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom)); max-width: 760px; }
.dialog.alert { max-width: 400px; }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 14px 20px; flex: 0 0 auto; }
.dlg-head .grow { flex: 1; min-width: 0; }
.dlg-head .grow > * { margin: 0; }
.dlg-kicker { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--primary); }
.dlg-title-1line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 20px; -webkit-overflow-scrolling: touch; }
.dlg-body.pad20 { padding: 20px; }
.dlg-foot { flex: 0 0 auto; display: flex; gap: 12px; padding: 14px 20px; }
.dlg-foot > .btn { flex: 1; }
.dlg-foot > .btn.wide { flex: 1.5; }
.divider { height: 1px; background: var(--outline-variant); flex: 0 0 auto; }
.section-title { margin: 16px 0 8px; font-size: 11px; font-weight: 700; color: var(--outline); letter-spacing: .5px; }

/* Product detail */
.detail-image {
  position: relative; height: 200px; border-radius: 16px; overflow: hidden;
  background: var(--surface-variant);
  display: block; width: 100%;
}
.detail-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-image .placeholder { font-size: 12px; font-weight: 400; gap: 6px; }
.zoom-hint {
  position: absolute; right: 8px; bottom: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  font-size: 10px; color: var(--on-surface);
}
.zoom-hint .ic { width: 16px; height: 16px; color: var(--primary); }
.supplier-card {
  margin-top: 16px; padding: 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--primary-container) 35%, var(--surface));
}
.supplier-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.balance-pill {
  padding: 4px 8px; border-radius: 8px;
  font-size: 11px; line-height: 14px; font-weight: 700;
  background: var(--surface-variant); color: var(--on-surface-variant);
}
.balance-pill.finished { background: var(--primary); color: var(--on-primary); }
.balance-pill.partial { background: var(--partial); color: #fff; }
.supplier-rows { display: grid; gap: 8px; margin: 12px 0; }
.supplier-row { display: grid; grid-template-columns: 1.3fr .9fr auto; gap: 8px; align-items: end; }
.supplier-row.single { grid-template-columns: 1.3fr .9fr; }
.totals {
  margin-top: 10px; padding: 10px; border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  font-size: 12px; line-height: 16px;
}
.totals .line { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; flex-wrap: wrap; }
.totals p { margin: 4px 0 0; color: var(--on-surface-variant); }
.spec-card {
  padding: 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--surface-variant) 35%, var(--surface));
  display: grid; gap: 10px;
}
.grid-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-row small { display: block; font-size: 11px; line-height: 16px; font-weight: 500; color: var(--outline); }
.grid-row span { display: block; font-weight: 600; overflow-wrap: anywhere; }
.spec-card .divider { background: color-mix(in srgb, var(--outline-variant) 50%, transparent); }
.notes-block small { display: block; font-size: 11px; font-weight: 700; color: var(--primary); }
.notes-block p { margin: 2px 0 0; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Photo pickers */
.photo-pick { display: flex; gap: 12px; align-items: center; }
.photo-thumb {
  width: 90px; height: 90px; border-radius: 12px; flex: 0 0 auto;
  background: var(--surface-variant); color: color-mix(in srgb, var(--on-surface-variant) 50%, transparent);
  display: grid; place-items: center; overflow: hidden;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-buttons { flex: 1; display: grid; gap: 8px; }
.photo-buttons .btn { border-radius: 10px; }
.photo-box {
  position: relative; height: 160px; border-radius: 16px; overflow: hidden;
  background: var(--surface-variant); border: 1px solid var(--outline-variant);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 8px; text-align: center;
}
.photo-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-box .remove {
  position: absolute; top: 8px; right: 8px;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .6); color: #fff;
}
.photo-box .row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.photo-caption { font-size: 11px; color: var(--outline); }

/* Lists inside dialogs (Bin, History, Duplicates) */
.dlg-list { display: grid; gap: 12px; padding: 16px; align-content: start; }
.list-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: 14px;
  background: var(--surface-variant);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  cursor: pointer;
}
.list-card.soft { background: color-mix(in srgb, var(--surface-variant) 40%, var(--surface)); }
.list-card.is-selected { background: color-mix(in srgb, var(--primary-container) 50%, var(--surface)); outline: 1px solid var(--primary); }
.list-card .main { flex: 1; min-width: 0; }
.list-card .name { font-size: 16px; line-height: 22px; font-weight: 700; overflow-wrap: anywhere; }
.list-card .meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; font-size: 12px; color: var(--on-surface-variant); }
.mini-chip {
  padding: 2px 6px; border-radius: 4px;
  background: color-mix(in srgb, var(--primary-container) 70%, transparent); color: var(--on-primary-container);
  font-size: 11px; font-weight: 500;
}
.check {
  width: 20px; height: 20px; border-radius: 2px; flex: 0 0 auto;
  border: 2px solid var(--on-surface-variant);
  display: grid; place-items: center; color: var(--on-primary);
}
.check.on { background: var(--primary); border-color: var(--primary); }
.check .ic { width: 16px; height: 16px; }
.hist-ic {
  width: 40px; height: 40px; border-radius: 8px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--primary-container); color: var(--on-primary-container);
}
.hist-ic.export { background: var(--secondary-container); }
.hist-ic .ic { width: 20px; height: 20px; }
.fmt {
  padding: 2px 6px; border-radius: 4px; background: var(--surface);
  font-size: 10px; font-weight: 500; flex: 0 0 auto;
}
.hist-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.hist-top .name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 32px 16px; text-align: center; color: var(--outline); min-height: 200px;
}
.dlg-empty .ic { color: var(--outline); margin-bottom: 8px; }
.dlg-empty .ok { color: var(--primary); }
.info-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--error-container) 40%, var(--surface));
  font-size: 12px; line-height: 16px;
}
.info-banner .ic { color: var(--error); width: 20px; height: 20px; }
.dup-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--error) 30%, transparent);
  background: color-mix(in srgb, var(--error-container) 15%, var(--surface));
}
.dup-row .main { flex: 1; min-width: 0; }
.dup-tag {
  display: inline-block; margin-left: 6px; padding: 1px 5px; border-radius: 4px;
  background: var(--error); color: #fff; font-size: 9px; font-weight: 700; vertical-align: middle;
}
.dup-thumb {
  width: 48px; height: 48px; border-radius: 8px; overflow: hidden; flex: 0 0 auto;
  background: var(--surface-variant); color: var(--outline); display: grid; place-items: center;
}
.dup-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Deleted product popup / alerts */
.info-rows { display: grid; gap: 8px; padding: 14px; border-radius: 12px; background: color-mix(in srgb, var(--surface-variant) 50%, var(--surface)); }
.info-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.info-row small { font-size: 12px; color: var(--on-surface-variant); }
.info-row span { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.deleted-tag {
  padding: 4px 8px; border-radius: 8px;
  background: var(--error-container); color: var(--on-error-container);
  font-size: 11px; font-weight: 700;
}
.alert-body { padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.alert-icon-box {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: var(--error-container); color: var(--error);
}
.name-box {
  width: 100%; padding: 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--surface-variant) 50%, var(--surface));
  font-size: 16px; font-weight: 600; overflow-wrap: anywhere;
}
.bullets {
  width: 100%; text-align: left; display: grid; gap: 6px;
  padding: 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--surface-variant) 50%, var(--surface));
  font-size: 12px; line-height: 16px; color: var(--on-surface-variant);
}
.bullets .keep { color: var(--primary); font-weight: 600; }
.alert-actions { display: flex; gap: 12px; width: 100%; margin-top: 12px; }
.alert-actions .btn { flex: 1; }

/* Filter dialog */
.filter-field { display: grid; gap: 6px; }
.filter-field > span { font-size: 12px; font-weight: 600; color: var(--on-surface-variant); }
.select-wrap { position: relative; }
.select-wrap select {
  width: 100%; min-height: 52px;
  padding: 12px 72px 12px 14px;
  border: 1px solid var(--outline-variant); border-radius: 12px;
  background: transparent; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.select-wrap.is-set select { border-color: var(--primary); }
.select-wrap select:focus { outline: none; border: 2px solid var(--primary); padding: 11px 71px 11px 13px; }
.select-wrap select option { color: var(--on-surface); background: var(--surface); }
.select-wrap .arrow { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--on-surface-variant); }
.select-wrap .clear { position: absolute; right: 40px; top: 50%; transform: translateY(-50%); }

/* Full-screen image viewer */
.viewer { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.viewer img {
  position: absolute; left: 50%; top: 50%;
  max-width: 100%; max-height: 100%;
  transform-origin: center center;
  -webkit-user-select: none; user-select: none; -webkit-user-drag: none;
}
.viewer-btns { position: absolute; top: calc(16px + var(--safe-top)); right: 16px; display: flex; gap: 12px; }
.viewer-btns button {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .6); color: #fff;
}
.viewer-hint {
  position: absolute; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%);
  padding: 6px 12px; border-radius: 16px;
  background: rgba(0, 0, 0, .6); color: rgba(255, 255, 255, .8);
  font-size: 11px; white-space: nowrap;
}

/* Snackbar */
.snackbar {
  position: fixed; z-index: 40;
  left: 50%; transform: translateX(-50%);
  bottom: calc(80px + var(--safe-bottom));
  width: calc(100vw - 32px); max-width: 560px;
  padding: 14px 16px; border-radius: 4px;
  background: #1e293b; color: #f1f5f9;
  box-shadow: var(--shadow-3);
  font-size: 14px; line-height: 20px;
}
:root[data-theme="dark"] .snackbar { background: #f1f5f9; color: #0f172a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .snackbar { background: #f1f5f9; color: #0f172a; } }

@media (max-width: 360px) {
  .row2 { grid-template-columns: 1fr; }
  .supplier-row { grid-template-columns: 1fr 80px auto; }
  .supplier-row.single { grid-template-columns: 1fr 80px; }
}

.filter-hint { margin: 0 20px 12px; }
.viewer-root { position: absolute; inset: 0; }
.dlg-head.flush { padding: 0 0 12px; }
.detail-image.deleted-img { height: 180px; margin-bottom: 14px; }
.gap-b14 { margin-bottom: 14px; }
.gap-t20 { margin-top: 20px; }
.btn.block { white-space: normal; text-align: center; }
