:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #111827;
  --muted: #667085;
  --border: #dfe5ea;
  --primary: #111827;
  --primary-contrast: #ffffff;
  --accent: #dff6e8;
  --accent-strong: #177245;
  --warning: #fff1d6;
  --warning-text: #8a4b08;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --radius: 18px;
  --shadow: 0 12px 32px rgba(16,24,40,.07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: light; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
input, select {
  width: 100%; border: 1px solid var(--border); background: #fff; color: var(--text);
  min-height: 44px; border-radius: 12px; padding: 10px 12px; outline: none;
}
input:focus, select:focus { border-color: #98a2b3; box-shadow: 0 0 0 3px rgba(17,24,39,.07); }
label { display: block; font-size: .82rem; font-weight: 700; margin-bottom: 7px; color: #344054; }
small { color: var(--muted); display: block; margin-top: 5px; }
h1,h2,h3,p { margin-top: 0; }
h1 { font-size: clamp(2.6rem, 6vw, 5.6rem); line-height: .95; letter-spacing: -.055em; max-width: 750px; margin-bottom: 22px; }
h2 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.04em; margin-bottom: 0; }
h3 { font-size: 1.25rem; margin-bottom: 0; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.min-w-0 { min-width: 0; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.stack-md > * + * { margin-top: 14px; }
.stack-lg > * + * { margin-top: 18px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-weight: 800; font-size: .72rem; color: var(--muted); margin-bottom: 10px; }
.lead { font-size: 1.08rem; line-height: 1.65; max-width: 680px; color: #475467; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn { border: 0; border-radius: 12px; min-height: 42px; padding: 10px 14px; font-weight: 750; transition: transform .12s ease, background .12s ease; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-contrast); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.subtle { background: #f7f8fa; color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.full { width: 100%; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); background: #fff; font-size: 1.15rem; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(0,1.45fr) minmax(360px,.55fr); gap: 40px; padding: clamp(24px,6vw,80px); align-items: center; }
.auth-brand { max-width: 900px; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; background: var(--text); color: white; border-radius: 16px; font-weight: 900; font-size: 1.4rem; margin-bottom: 38px; }
.brand-mark.compact { width: 36px; height: 36px; border-radius: 10px; font-size: .95rem; margin: 0; flex: 0 0 auto; }
.feature-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.feature-chips span { padding: 8px 11px; border: 1px solid #cfd6dd; background: rgba(255,255,255,.55); border-radius: 999px; font-weight: 700; font-size: .8rem; }
.auth-card { padding: 28px; max-width: 470px; width: 100%; justify-self: end; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 13px; padding: 4px; margin-bottom: 24px; }
.segmented-btn { border: 0; background: transparent; border-radius: 10px; padding: 10px; font-weight: 750; color: var(--muted); }
.segmented-btn.active { background: #fff; color: var(--text); box-shadow: 0 2px 8px rgba(16,24,40,.06); }

.app { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 10; }
.brand-row { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.side-nav { display: grid; gap: 7px; margin-top: 34px; }
.nav-btn { min-height: 46px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 12px; background: transparent; padding: 0 12px; text-align: left; font-weight: 700; color: #475467; }
.nav-btn.active { background: var(--text); color: #fff; }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
.user-mini { display: grid; grid-template-columns: 38px minmax(0,1fr); gap: 10px; align-items: center; padding: 10px 4px; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-strong); font-weight: 900; }
.content { min-width: 0; padding: clamp(24px,4vw,54px); padding-bottom: 100px; }
.view-section { max-width: 1250px; margin: 0 auto; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar { padding: 14px; display: flex; gap: 12px; align-items: end; margin-bottom: 18px; box-shadow: none; }
.field-inline.grow { flex: 1 1 230px; }
.field-inline.grow-2 { flex: 2 1 300px; }
.align-end { margin-bottom: 1px; }
.toolbar-meta { min-width: 90px; text-align: right; padding: 6px 8px; }
.toolbar-meta strong { font-size: 1.45rem; display: block; }
.toolbar-meta small { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.72); }
.stat-card strong { display: block; font-size: 1.65rem; letter-spacing: -.03em; }
.stat-card span { color: var(--muted); font-size: .8rem; font-weight: 650; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(240px,1fr)); gap: 14px; }
.product-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px; min-width: 0; }
.product-top { display: grid; grid-template-columns: 64px minmax(0,1fr); gap: 12px; align-items: center; }
.product-thumb { width: 64px; height: 64px; border-radius: 13px; object-fit: cover; background: #edf1f4; display: grid; place-items: center; overflow: hidden; font-size: 1.3rem; color: #98a2b3; }
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-barcode { color: var(--muted); font-size: .75rem; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-line { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 10px; }
.stock-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 7px 9px; background: var(--accent); color: var(--accent-strong); font-size: .78rem; font-weight: 800; }
.stock-pill.low { background: var(--warning); color: var(--warning-text); }
.product-actions { display: grid; grid-template-columns: 42px 42px minmax(0,1fr); gap: 7px; margin-top: 12px; }
.product-actions .btn { padding-inline: 8px; }

.shopping-list { display: grid; gap: 9px; }
.shopping-item { display: grid; grid-template-columns: 30px 48px minmax(0,1fr) auto auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 15px; padding: 11px 12px; }
.shopping-item.checked { opacity: .57; }
.shopping-item.checked .shopping-name { text-decoration: line-through; }
.shopping-check { width: 22px; height: 22px; accent-color: var(--text); }
.shopping-thumb { width: 48px; height: 48px; border-radius: 10px; background: var(--surface-2); object-fit: cover; }
.shopping-name { font-weight: 780; }
.shopping-meta { color: var(--muted); font-size: .75rem; margin-top: 3px; }
.qty-badge { min-width: 42px; text-align: center; padding: 7px 9px; border-radius: 10px; background: var(--surface-2); font-weight: 800; }
.list-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(270px,1fr)); gap: 14px; }
.list-card { background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 18px; }
.list-card-head { display: flex; justify-content: space-between; gap: 10px; }
.list-type { display: inline-flex; padding: 6px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .73rem; font-weight: 800; }
.list-card .meta { margin-top: 16px; display: flex; gap: 12px; color: var(--muted); font-size: .82rem; }
.empty-state { min-height: 310px; display: grid; place-items: center; align-content: center; text-align: center; padding: 40px; color: var(--muted); }
.empty-state h3 { color: var(--text); margin: 10px 0 6px; }
.empty-state p { max-width: 420px; }
.empty-icon { width: 54px; height: 54px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; font-size: 1.4rem; }

.modal { border: 0; padding: 0; border-radius: 22px; width: min(760px, calc(100vw - 24px)); max-height: min(88vh, 900px); overflow: auto; background: transparent; }
.modal::backdrop { background: rgba(17,24,39,.42); backdrop-filter: blur(4px); }
.modal-card { background: #fff; border-radius: 22px; padding: 22px; display: grid; gap: 18px; box-shadow: 0 30px 90px rgba(16,24,40,.22); }
.modal-card.narrow, .narrow { max-width: 560px; margin: auto; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-actions { display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--border); padding-top: 16px; }
.product-form-grid { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 18px; }
.image-picker { min-width: 0; }
.image-drop, .product-preview { width: 100%; aspect-ratio: 1; border-radius: 16px; }
.image-drop { border: 1px dashed #b8c1cc; background: #f7f8fa; display: grid; place-items: center; color: var(--muted); font-weight: 700; margin: 0; cursor: pointer; text-align: center; padding: 10px; }
.product-preview { object-fit: cover; margin-bottom: 8px; }
.qty-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; }
.input-action { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.scanner-stage { position: relative; background: #0b0f14; min-height: 310px; border-radius: 18px; overflow: hidden; }
.scanner-stage video { width: 100%; height: 100%; min-height: 310px; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%,-50%); width: min(78%,480px); height: 115px; border: 2px solid rgba(255,255,255,.92); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.22); }
.manual-barcode { margin-top: 4px; }
.invite-result { background: #f7f8fa; border-radius: 14px; padding: 12px; }
.callout { padding: 13px; border-radius: 14px; background: #f7f8fa; color: #475467; font-size: .87rem; line-height: 1.55; }
.toast { position: fixed; z-index: 1000; left: 50%; bottom: 26px; transform: translate(-50%,20px); background: #111827; color: white; border-radius: 12px; padding: 10px 14px; opacity: 0; pointer-events: none; transition: .18s ease; max-width: min(90vw,560px); text-align: center; font-weight: 650; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.toast.error { background: #7a271a; }
.mobile-topbar, .bottom-nav { display: none; }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; align-content: center; padding: 26px; }
  .auth-brand { display: none; }
  .auth-card { justify-self: center; }
  .app { display: block; }
  .sidebar { display: none; }
  .mobile-topbar { position: sticky; top: 0; z-index: 15; display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,.92); backdrop-filter: blur(14px); padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .content { padding: 20px 14px 96px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(3,1fr); position: fixed; z-index: 16; bottom: 0; left: 0; right: 0; padding: 7px max(10px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); background: rgba(255,255,255,.95); backdrop-filter: blur(14px); border-top: 1px solid var(--border); }
  .bottom-nav-btn { border: 0; background: transparent; min-height: 50px; border-radius: 11px; display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); }
  .bottom-nav-btn.active { color: var(--text); background: #f2f4f7; }
  .page-head { align-items: center; }
  .head-actions #scanBtn { display: none; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .align-end { width: 100%; }
}
@media (max-width: 620px) {
  .page-head { align-items: flex-end; }
  .head-actions { justify-content: flex-end; }
  .stat-grid { grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
  .stat-card { padding: 12px 10px; }
  .stat-card strong { font-size: 1.3rem; }
  .product-grid { grid-template-columns: 1fr; }
  .shopping-item { grid-template-columns: 28px 44px minmax(0,1fr) auto; }
  .shopping-item .delete-shop { grid-column: 4; }
  .product-form-grid { grid-template-columns: 1fr; }
  .image-picker { display: grid; grid-template-columns: 110px minmax(0,1fr); gap: 10px; align-items: start; }
  .image-drop, .product-preview { width: 110px; }
  .qty-grid { grid-template-columns: 1fr 1fr 1fr; }
  .modal { width: calc(100vw - 12px); max-height: 94vh; }
  .modal-card { padding: 16px; border-radius: 18px; }
  .modal-actions { flex-wrap: wrap; }
  .scanner-stage, .scanner-stage video { min-height: 46vh; }
}
