:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #26332d;
  background: #faf8f2;
  font-synthesis: none;
  --green: #3f6b57;
  --green-dark: #315443;
  --green-soft: #79a86b;
  --cream: #faf8f2;
  --white: #ffffff;
  --ink: #26332d;
  --muted: #6f7d76;
  --accent: #f2a65a;
  --border: #e4e7df;
  --danger: #a6403a;
  --shadow: 0 14px 35px rgba(42, 70, 57, 0.1);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream); }
body { margin: 0; min-width: 320px; min-height: 100vh; min-height: 100dvh; background: var(--cream); }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; min-height: 100dvh; }
.center-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; }
.brand-mark, .wordmark-dot {
  display: grid; place-items: center; background: var(--green); color: white; font-weight: 800;
}
.brand-mark { width: 58px; height: 58px; border-radius: 19px 19px 19px 6px; font-size: 30px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }

.login-screen { min-height: 100vh; min-height: 100dvh; padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom)); display: grid; align-items: center; }
.login-card { width: 100%; max-width: 420px; margin: auto; }
.brand-lockup { display: flex; align-items: center; gap: 12px; color: var(--green); font-size: 23px; font-weight: 800; letter-spacing: -0.02em; }
.brand-lockup .brand-mark { width: 42px; height: 42px; border-radius: 14px 14px 14px 5px; font-size: 21px; box-shadow: none; }
.login-copy { margin: 44px 0 32px; }
.eyebrow { margin: 0 0 7px; color: var(--green-soft); font-size: 12px; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
h1, h2, p { text-wrap: pretty; }
h1 { margin: 0; font-size: clamp(30px, 9vw, 42px); line-height: 1.07; letter-spacing: -0.045em; }
.login-copy > p:last-child { max-width: 330px; margin: 16px 0 0; color: var(--muted); line-height: 1.55; }

.field { margin-bottom: 18px; }
.field label, .location-fieldset legend { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 750; }
.field label span { color: var(--muted); font-size: 12px; font-weight: 500; }
input { min-height: 52px; width: 100%; border: 1.5px solid var(--border); border-radius: 14px; background: var(--white); padding: 0 15px; color: var(--ink); font-size: 16px; outline: none; transition: border-color .18s, box-shadow .18s; }
input:focus { border-color: var(--green-soft); box-shadow: 0 0 0 4px rgba(121, 168, 107, .14); }
input::placeholder { color: #98a29d; }
.password-field { position: relative; }
.password-field input { padding-right: 54px; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 13px; background: transparent; color: var(--green); }
.icon-button:hover { background: rgba(63, 107, 87, .08); }
.icon-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle { position: absolute; top: 4px; right: 4px; color: var(--muted); }

.primary-button, .secondary-button { min-height: 50px; border-radius: 14px; padding: 0 20px; border: 0; font-weight: 750; transition: transform .15s, background .15s; }
.primary-button { background: var(--green); color: white; box-shadow: 0 9px 24px rgba(63, 107, 87, .2); }
.primary-button:hover { background: var(--green-dark); }
.primary-button:active, .secondary-button:active { transform: translateY(1px); }
.secondary-button { background: #eaf0e9; color: var(--green-dark); }
.full-width { width: 100%; }
button:disabled { cursor: wait; opacity: .68; }
.button-spinner { display: none; width: 18px; height: 18px; margin-left: 9px; border: 2px solid rgba(255,255,255,.5); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
.is-loading .button-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.inline-message { margin: 0 0 14px; padding: 11px 13px; border-radius: 11px; font-size: 14px; line-height: 1.4; }
.inline-message.error { color: var(--danger); background: #fbecea; }

.topbar { position: sticky; z-index: 10; top: 0; display: flex; align-items: center; justify-content: space-between; padding: max(14px, env(safe-area-inset-top)) 20px 12px; background: rgba(250,248,242,.92); backdrop-filter: blur(14px); }
.wordmark { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 18px; font-weight: 850; letter-spacing: -.03em; }
.wordmark-dot { width: 28px; height: 28px; border-radius: 9px 9px 9px 3px; font-size: 14px; }
.page-kicker { margin: 3px 0 0 36px; color: var(--muted); font-size: 11px; }
.main-content { max-width: 720px; margin: 0 auto; padding: 18px 18px 148px; }
.view { animation: fade-in .2s ease; }
@keyframes fade-in { from { opacity: .25; transform: translateY(3px); } }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 10px 2px 24px; }
.page-heading h1 { font-size: clamp(29px, 8vw, 38px); }
.compact-heading { margin-bottom: 18px; }
.count-badge { flex: none; margin-bottom: 3px; border-radius: 999px; padding: 7px 10px; background: #e8efe6; color: var(--green); font-size: 12px; font-weight: 750; }

.card-list { display: grid; gap: 12px; }
.product-card { position: relative; display: grid; grid-template-columns: 78px minmax(0,1fr); gap: 14px; min-height: 102px; padding: 12px; border: 1px solid rgba(63,107,87,.09); border-radius: 18px; background: var(--white); box-shadow: 0 6px 20px rgba(42,70,57,.055); }
button.product-card { width: 100%; color: inherit; text-align: left; cursor: pointer; }
button.product-card:hover { border-color: rgba(63,107,87,.3); }
.product-image { width: 78px; height: 78px; align-self: center; border-radius: 13px; object-fit: contain; background: #f3f1eb; }
.image-fallback { display: grid; place-items: center; color: #93a099; font-size: 28px; }
.product-info { min-width: 0; align-self: center; padding-right: 2px; }
.product-name { margin: 0; overflow: hidden; color: var(--ink); font-size: 16px; font-weight: 780; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.product-brand { margin: 4px 0 0; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.product-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.quantity-pill { border-radius: 999px; padding: 4px 8px; background: #edf3ec; color: var(--green-dark); font-weight: 750; }
.expiry { display: inline-flex; align-items: center; gap: 4px; }
.expiry.soon { color: #9a5c1c; font-weight: 700; }
.expiry.expired { color: var(--danger); font-weight: 700; }
.select-cue { align-self: center; color: var(--green); font-size: 22px; font-weight: 400; }
.search-results .product-card { grid-template-columns: 68px minmax(0,1fr) 22px; min-height: 92px; }
.search-results .product-image { width: 68px; height: 68px; }
.skeleton-card { overflow: hidden; height: 102px; background: #eeeae1; }
.skeleton-card::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.state-card { padding: 42px 24px; border-radius: 22px; background: var(--white); text-align: center; box-shadow: 0 8px 30px rgba(42,70,57,.06); }
.state-card h2, .search-welcome h2 { margin: 16px 0 7px; font-size: 20px; letter-spacing: -.02em; }
.state-card p, .search-welcome p { max-width: 310px; margin: 0 auto 22px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.small-state { margin-top: 26px; padding: 32px 20px; }
.state-icon { display: grid; place-items: center; width: 45px; height: 45px; margin: 0 auto; border-radius: 50%; background: #edf3ec; color: var(--green); font-size: 19px; font-weight: 800; }
.error-icon { background: #fbecea; color: var(--danger); }
.pantry-illustration { position: relative; width: 150px; height: 86px; margin: 0 auto 4px; }
.shelf { position: absolute; bottom: 5px; left: 4px; width: 142px; height: 8px; border-radius: 5px; background: var(--green); }
.jar { position: absolute; bottom: 13px; border-radius: 8px 8px 6px 6px; background: #dce9d8; border: 2px solid var(--green); }
.jar::before { content:""; position:absolute; top:-6px; left:2px; right:2px; height:5px; border-radius:3px 3px 0 0; background:var(--accent); }
.jar-one { left: 16px; width: 35px; height: 47px; }.jar-two { left: 59px; width: 38px; height: 61px; }.jar-three { left: 106px; width: 29px; height: 41px; }

.search-form { position: relative; display: grid; grid-template-columns: 22px minmax(0,1fr) auto auto; align-items: center; gap: 8px; padding: 6px 6px 6px 15px; border: 1.5px solid var(--border); border-radius: 17px; background: white; box-shadow: 0 5px 18px rgba(42,70,57,.06); }
.search-form:focus-within { border-color: var(--green-soft); box-shadow: 0 0 0 4px rgba(121,168,107,.14); }
.search-form svg { width: 21px; fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; }
.search-form input { min-width: 0; min-height: 46px; border: 0; padding: 0; box-shadow: none; }
.search-form input:focus { box-shadow: none; }
.search-button { min-height: 44px; border: 0; border-radius: 12px; padding: 0 15px; background: var(--green); color: white; font-weight: 750; }
.clear-button { width: 36px; height: 44px; margin-right: -7px; border: 0; background: transparent; color: var(--muted); font-size: 25px; }
.search-hint { margin: 8px 5px 22px; color: var(--muted); font-size: 12px; }
.search-welcome { padding: 48px 20px; text-align: center; }
.search-orbit { display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto; border-radius: 50%; background: #eaf1e7; color: var(--green); font-size: 32px; transform: rotate(-20deg); }
.scanner-entry { display: grid; grid-template-columns: 48px minmax(0,1fr) 18px; align-items: center; gap: 12px; width: 100%; min-height: 78px; border: 0; border-radius: 18px; padding: 12px 14px; background: var(--green); color: white; text-align: left; box-shadow: 0 9px 24px rgba(63,107,87,.2); }
.scanner-entry:hover { background: var(--green-dark); }
.scanner-entry-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.14); }
.scanner-entry-icon svg { width: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.scanner-entry strong, .scanner-entry small { display: block; }
.scanner-entry strong { font-size: 16px; }
.scanner-entry small { margin-top: 3px; color: rgba(255,255,255,.76); font-size: 12px; }
.scanner-entry .select-cue { color: white; }
.manual-divider { display: flex; align-items: center; gap: 10px; margin: 20px 3px 14px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.manual-divider::before, .manual-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.fab { position: fixed; z-index: 12; right: max(18px, calc((100vw - 720px) / 2 + 18px)); bottom: calc(83px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px; min-height: 50px; border: 0; border-radius: 16px; padding: 0 17px; background: var(--green); color: white; font-weight: 750; box-shadow: 0 10px 28px rgba(49,84,67,.3); }
.fab > span:first-child { font-size: 25px; font-weight: 400; line-height: 1; }
.bottom-nav { position: fixed; z-index: 11; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); height: calc(70px + env(safe-area-inset-bottom)); padding: 6px max(18px, calc((100vw - 720px) / 2)) env(safe-area-inset-bottom); border-top: 1px solid rgba(63,107,87,.1); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); }
.nav-item { min-height: 56px; border: 0; background: transparent; color: #829087; font-size: 11px; font-weight: 700; }
.nav-item svg { display: block; width: 23px; height: 23px; margin: 0 auto 2px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { color: var(--green); }

.sheet-backdrop { position: fixed; z-index: 30; inset: 0; background: rgba(25,38,32,.42); opacity: 0; animation: backdrop-in .2s forwards; }
@keyframes backdrop-in { to { opacity: 1; } }
.bottom-sheet { position: fixed; z-index: 31; right: 0; bottom: 0; left: 0; max-height: calc(100vh - 18px); max-height: calc(100dvh - 18px); overflow-y: auto; border-radius: 25px 25px 0 0; padding: 8px 20px calc(22px + env(safe-area-inset-bottom)); background: var(--white); box-shadow: 0 -16px 50px rgba(25,38,32,.18); animation: sheet-in .25s ease-out; }
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet-handle { width: 40px; height: 4px; margin: 0 auto 7px; border-radius: 4px; background: #d6dcd7; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-header h2 { margin: 0; font-size: 20px; }
.sheet-header .icon-button { color: var(--muted); font-size: 26px; }
.selected-product { display: grid; grid-template-columns: 58px minmax(0,1fr); gap: 12px; align-items: center; margin-bottom: 20px; padding: 10px; border-radius: 15px; background: var(--cream); }
.selected-product .product-image { width: 58px; height: 58px; }
.selected-product .product-name { font-size: 15px; }
.form-row { display: grid; grid-template-columns: 1fr 1.55fr; gap: 12px; }
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; height: 52px; overflow: hidden; border: 1.5px solid var(--border); border-radius: 14px; }
.stepper button { border: 0; background: #f2f5f0; color: var(--green); font-size: 23px; }
.stepper output { display: grid; place-items: center; font-weight: 800; }
.location-fieldset { margin: 0 0 20px; padding: 0; border: 0; }
.location-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.location-grid input { position: absolute; opacity: 0; pointer-events: none; }
.location-grid span { display: flex; align-items: center; min-height: 48px; border: 1.5px solid var(--border); border-radius: 13px; padding: 0 11px; color: var(--muted); font-size: 13px; font-weight: 700; }
.location-grid input:checked + span { border-color: var(--green); background: #edf3ec; color: var(--green-dark); }
.location-grid input:focus-visible + span { outline: 3px solid rgba(121,168,107,.3); }
body.sheet-open { overflow: hidden; }

.scanner-modal { position: fixed; z-index: 40; inset: 0; overflow-y: auto; overscroll-behavior: contain; background: var(--cream); padding: max(14px, env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); animation: fade-in .2s ease; }
.scanner-header { display: flex; align-items: center; justify-content: space-between; max-width: 620px; margin: 0 auto 14px; }
.scanner-header h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.scanner-header .eyebrow { margin-bottom: 3px; }
.scanner-close { background: rgba(63,107,87,.08); color: var(--muted); font-size: 27px; }
.scanner-live, .scanner-summary { max-width: 620px; margin: 0 auto; }
.camera-frame { position: relative; overflow: hidden; aspect-ratio: 4 / 3; max-height: 44vh; min-height: 220px; border-radius: 22px; background: #17201c; box-shadow: var(--shadow); }
.camera-frame video { width: 100%; height: 100%; object-fit: cover; }
.scan-guide { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scan-guide span { width: 78%; height: 35%; border: 2px solid rgba(255,255,255,.84); border-radius: 16px; box-shadow: 0 0 0 999px rgba(13,22,18,.22); }
.scan-guide span::after { content: ""; display: block; width: 86%; height: 2px; margin: calc(17.5% - 1px) auto 0; background: var(--accent); box-shadow: 0 0 8px rgba(242,166,90,.8); animation: scan-line 1.8s ease-in-out infinite alternate; }
@keyframes scan-line { from { transform: translateY(-23px); } to { transform: translateY(23px); } }
.camera-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 25px; background: #27342e; color: white; text-align: center; }
.camera-state p { max-width: 300px; margin: 0 0 4px; color: #d7dfda; font-size: 13px; line-height: 1.45; }
.camera-spinner { width: 28px; height: 28px; border: 3px solid rgba(255,255,255,.35); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
.camera-error > span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: #fbecea; color: var(--danger); font-size: 20px; font-weight: 800; }
.scan-feedback { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 46px; margin: 10px 0; border-radius: 13px; background: #eaf0e9; color: var(--green-dark); font-size: 14px; font-weight: 720; transition: background .18s, color .18s; }
.feedback-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green-soft); box-shadow: 0 0 0 4px rgba(121,168,107,.14); }
.scan-feedback.success { background: #dfeedd; color: var(--green-dark); }
.scan-feedback.success .feedback-dot { background: var(--green); }
.scan-feedback.warning { background: #fff0df; color: #8b541c; }
.scan-feedback.warning .feedback-dot { background: var(--accent); }
.scan-session { border-radius: 18px; padding: 14px; background: white; box-shadow: 0 6px 20px rgba(42,70,57,.055); }
.scan-session-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.scan-session-heading h3 { margin: 0; font-size: 15px; }
.scan-recent { display: grid; gap: 8px; max-height: 174px; overflow-y: auto; }
.scan-empty { margin: 9px 0; color: var(--muted); font-size: 13px; text-align: center; }
.scan-recent-item { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: 9px; min-height: 48px; }
.scan-recent-item .product-image { width: 42px; height: 42px; border-radius: 10px; }
.scan-recent-item .product-name { font-size: 13px; -webkit-line-clamp: 1; }
.scan-recent-item .product-brand { margin-top: 2px; font-size: 11px; }
.scan-quantity { color: var(--green); font-size: 15px; font-weight: 850; }
.scanner-action { margin-top: 12px; }

.summary-intro { margin: 0 2px 15px; color: var(--muted); font-size: 14px; }
.summary-list { display: grid; gap: 10px; }
.summary-item { display: grid; grid-template-columns: 54px minmax(0,1fr) auto; align-items: center; gap: 10px; border: 1px solid rgba(63,107,87,.09); border-radius: 16px; padding: 10px; background: white; }
.summary-item .product-image { width: 54px; height: 54px; border-radius: 11px; }
.summary-item .product-name { font-size: 14px; }
.summary-controls { display: grid; grid-template-columns: 38px 38px 38px; align-items: center; }
.summary-controls button { min-height: 40px; border: 0; border-radius: 10px; background: #edf3ec; color: var(--green); font-size: 20px; }
.summary-controls output { text-align: center; font-weight: 850; }
.remove-summary-item { grid-column: 3; justify-self: end; min-height: 34px; margin-top: -3px; border: 0; background: transparent; color: var(--danger); font-size: 12px; font-weight: 700; }
.summary-options { margin-top: 18px; border-radius: 18px; padding: 15px; background: white; }
.summary-options .field { margin-bottom: 0; }
.summary-actions { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); display: grid; grid-template-columns: .8fr 1.2fr; gap: 9px; margin: 14px -16px -20px; padding: 12px 16px calc(20px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: rgba(250,248,242,.96); backdrop-filter: blur(12px); }
.summary-actions button { padding-inline: 12px; }
body.scanner-open { overflow: hidden; }

.toast { position: fixed; z-index: 50; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom)); left: 18px; max-width: 440px; margin: 0 auto; border-radius: 14px; padding: 14px 17px; background: var(--green-dark); color: white; font-size: 14px; font-weight: 650; text-align: center; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity:0; transform: translateY(8px); } }

@media (max-width: 370px) {
  .main-content { padding-inline: 14px; }
  .topbar { padding-inline: 16px; }
  .fab { right: 14px; }
  .fab > span:last-child { display: none; }
  .fab { width: 52px; justify-content: center; padding: 0; }
  .fab > span:first-child { font-size: 28px; }
  .scanner-modal { padding-inline: 12px; }
  .summary-item { grid-template-columns: 46px minmax(0,1fr) auto; gap: 8px; padding: 9px; }
  .summary-item .product-image { width: 46px; height: 46px; }
  .summary-controls { grid-template-columns: 35px 31px 35px; }
  .summary-actions { grid-template-columns: 1fr; }
}

@media (min-width: 760px) {
  .login-screen { background: radial-gradient(circle at 75% 22%, #e5ede0 0 7%, transparent 28%), var(--cream); }
  .login-card { padding: 36px; border-radius: 26px; background: rgba(255,255,255,.72); box-shadow: 0 20px 70px rgba(42,70,57,.08); }
  .main-content { padding-top: 28px; }
  .bottom-sheet { left: 50%; bottom: 20px; width: 520px; border-radius: 25px; transform: translateX(-50%); animation: modal-in .2s ease-out; }
  @keyframes modal-in { from { opacity:0; transform: translate(-50%, 12px); } }
  .card-list { grid-template-columns: 1fr 1fr; }
  .state-card, .search-welcome { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
