:root {
  --paper: #f7f3ec;
  --card: #fffdfa;
  --ink: #292622;
  --muted: #746e65;
  --line: #ddd6cb;
  --soft: #eee8df;
  --coral: #f45d3d;
  --coral-dark: #d9472c;
  --green: #28845f;
  --shadow: 0 18px 50px rgba(58, 46, 34, .14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--paper); }
body { min-height: 100%; margin: 0; color: var(--ink); background: var(--paper); font: 15px/1.4 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, select { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid rgba(244, 93, 61, .26); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { width: min(760px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 18px 112px; }
.topbar { position: sticky; z-index: 10; top: 0; min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid color-mix(in srgb, var(--line) 76%, transparent); }
.brand-block { min-width: 0; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-family: Georgia, serif; font-size: 22px; font-weight: 700; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; background: var(--coral); color: white; font: 800 16px/1 ui-sans-serif, system-ui; transform: rotate(-4deg); }
.brand-block p { margin: 2px 0 0 40px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.top-actions { position: relative; display: flex; align-items: center; gap: 5px; }
.icon-button, .quiet-button, .profile-button { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.icon-button { display: grid; place-items: center; border-radius: 50%; }
.icon-button:hover, .quiet-button:hover { background: var(--soft); }
.quiet-button { padding: 0 9px; border-radius: 11px; font-size: 12px; font-weight: 800; }
.sync-button { min-width: 28px; width: 28px; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(40,132,95,.12); }
.sync-button.is-syncing .sync-dot { background: #d79b30; animation: pulse 1s infinite; }
.sync-button.is-offline .sync-dot { background: var(--coral); }
@keyframes pulse { 50% { opacity: .38; } }
.profile-button { display: flex; align-items: center; gap: 7px; padding: 3px 6px 3px 3px; border-radius: 14px; }
.profile-button:hover { background: var(--soft); }
.profile-button svg { width: 16px; height: 16px; }
.profile-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 800; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; background: #2d2925; color: white; font-weight: 800; }
.profile-menu { position: absolute; top: 54px; right: 0; width: 225px; padding: 7px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.profile-menu button { width: 100%; min-height: 58px; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 11px; background: transparent; text-align: left; cursor: pointer; }
.profile-menu button:hover, .profile-menu button.active { background: var(--soft); }
.profile-menu .avatar { width: 38px; height: 38px; }
.profile-menu small { color: var(--muted); }

main { padding-top: 26px; }
.list-toolbar { display: grid; grid-template-columns: 1fr auto; gap: 9px; margin-bottom: 28px; }
.search-field { min-height: 49px; display: flex; align-items: center; gap: 9px; padding: 0 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--card); }
.search-field svg { width: 19px; color: var(--muted); }
.search-field input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-field input::placeholder { color: #9b948b; }
.sort-field select { height: 49px; padding: 0 34px 0 13px; border: 1px solid var(--line); border-radius: 15px; background: var(--card); color: var(--ink); font-size: 13px; font-weight: 750; }
.list-section + .list-section { margin-top: 30px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 10px; }
.section-title h2 { margin: 0; font: 700 18px/1.2 Georgia, serif; }
.section-title span { color: var(--muted); font-size: 11px; }
.treat-list { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.treat-row { min-height: 69px; display: grid; grid-template-columns: 48px minmax(0,1fr) auto 48px; align-items: center; gap: 4px; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.treat-row:last-child { border-bottom: 0; }
.treat-row.is-out { background: #f2eee8; }
.consume-button, .plus-button, .quantity-button { min-width: 44px; min-height: 44px; border: 0; cursor: pointer; }
.consume-button { display: grid; place-items: center; border-radius: 50%; background: transparent; }
.consume-ring { width: 26px; height: 26px; display: grid; place-items: center; border: 2px solid #aaa196; border-radius: 50%; color: transparent; transition: .16s; }
.consume-button:hover .consume-ring { border-color: var(--coral); background: rgba(244,93,61,.08); color: var(--coral); }
.consume-button:active .consume-ring { transform: scale(.86); background: var(--coral); border-color: var(--coral); color: white; }
.consume-button:disabled { cursor: default; opacity: .28; }
.consume-button:disabled .consume-ring { border-style: dashed; }
.treat-name { min-width: 0; min-height: 48px; display: flex; flex-direction: column; justify-content: center; padding: 3px 7px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.treat-name strong, .treat-name small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.treat-name strong { font-size: 15px; line-height: 1.25; }
.treat-name small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.quantity-button { padding: 0 8px; border-radius: 11px; background: transparent; color: var(--ink); font-weight: 850; }
.quantity-button.out { color: var(--muted); font-size: 11px; }
.quantity-button:hover { background: var(--soft); }
.plus-button { border-radius: 13px; background: var(--soft); color: var(--ink); font-size: 24px; line-height: 1; }
.plus-button:hover { background: var(--coral); color: white; }
.empty-state { min-height: 210px; display: grid; place-items: center; padding: 35px 24px; text-align: center; }
.empty-state span { font-size: 35px; }
.empty-state h3 { margin: 10px 0 4px; font: 700 22px/1.25 Georgia, serif; }
.empty-state p { max-width: 300px; margin: 0; color: var(--muted); font-size: 13px; }
.fab { position: fixed; z-index: 8; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); min-height: 54px; display: flex; align-items: center; gap: 8px; padding: 0 21px; border: 0; border-radius: 17px; background: var(--coral); color: white; box-shadow: 0 12px 30px rgba(198,65,38,.27); cursor: pointer; font-weight: 850; }
.fab:hover { background: var(--coral-dark); }

.modal-backdrop { position: fixed; z-index: 20; inset: 0; background: rgba(39,35,31,.48); backdrop-filter: blur(3px); }
.sheet { position: fixed; z-index: 21; left: 50%; bottom: 0; width: min(640px, 100%); max-height: 92vh; overflow-y: auto; transform: translateX(-50%); padding: 13px 24px calc(28px + env(safe-area-inset-bottom)); border-radius: 25px 25px 0 0; background: var(--card); box-shadow: var(--shadow); animation: sheet-in .2s ease-out; }
@keyframes sheet-in { from { transform: translate(-50%, 28px); opacity: 0; } }
.sheet-handle { width: 40px; height: 5px; margin: 0 auto 20px; border-radius: 5px; background: #d8d0c3; }
.sheet-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.sheet-header h2 { margin: 2px 0 0; font: 700 28px/1.15 Georgia, serif; }
.eyebrow { margin: 0; color: var(--coral-dark); font-size: 10px; font-weight: 900; letter-spacing: .13em; }
.sheet-subtitle { margin: 4px 0 18px; color: var(--muted); line-height: 1.55; }
.add-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 5px; margin-bottom: 19px; border-radius: 14px; background: var(--soft); }
.add-mode { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 800; }
.add-mode.active { background: white; color: var(--ink); box-shadow: 0 2px 8px rgba(52,42,30,.08); }
.big-input, .snack-form label { display: block; }
.big-input > span, .snack-form label > span:first-child { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.big-input small { font-weight: 500; }
.big-input input, .snack-form input, .snack-form select, .barcode-form input { width: 100%; height: 50px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; outline: 0; background: #fffefa; color: var(--ink); }
.big-input input:focus, .snack-form input:focus, .snack-form select:focus, .barcode-form input:focus { border-color: var(--coral); }
.catalogue-results { display: grid; gap: 7px; max-height: 390px; overflow-y: auto; margin-top: 14px; }
.catalogue-row { min-height: 61px; display: grid; grid-template-columns: 36px minmax(0,1fr) 46px; align-items: center; gap: 8px; padding: 6px 7px 6px 11px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.pin-mark { color: #d99422; font-size: 17px; }
.catalogue-name { min-width: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.catalogue-name strong, .catalogue-name small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.catalogue-name small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.catalogue-add { width: 42px; height: 42px; border: 0; border-radius: 12px; background: var(--soft); cursor: pointer; font-size: 22px; }
.catalogue-add:hover { background: var(--coral); color: white; }
.catalogue-empty { padding: 35px 14px; color: var(--muted); text-align: center; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.snack-form > label { margin-bottom: 13px; }
.stepper { height: 50px; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; border: 1px solid var(--line); border-radius: 12px; }
.stepper button { height: 100%; border: 0; background: transparent; cursor: pointer; font-size: 21px; }
.stepper output { text-align: center; font-weight: 850; }
.check-row { display: flex !important; align-items: center; gap: 11px; padding: 12px; margin: 2px 0 17px !important; border-radius: 12px; background: var(--soft); cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--coral); }
.check-row span { margin: 0 !important; }
.check-row strong, .check-row small { display: block; }
.check-row small { margin-top: 2px; color: var(--muted); }
.primary-button, .secondary-button { width: 100%; min-height: 50px; border-radius: 13px; cursor: pointer; font-weight: 850; }
.primary-button { border: 0; background: var(--coral); color: white; }
.primary-button:hover { background: var(--coral-dark); }
.secondary-button { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.secondary-button:hover { background: var(--soft); }
.scanner-frame { height: 235px; position: relative; display: grid; place-items: center; overflow: hidden; margin-bottom: 13px; border: 2px dashed #c9bfb0; border-radius: 17px; background: #302d29; color: white; }
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; }
.scanner-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; background: #302d29; text-align: center; }
.scanner-placeholder > span { color: #f6c763; font-size: 44px; }
.scanner-placeholder small { color: #cfc8be; }
.scanner-line { display: none; position: absolute; z-index: 2; left: 10%; right: 10%; top: 50%; height: 2px; background: var(--coral); box-shadow: 0 0 10px var(--coral); animation: scan 1.8s ease-in-out infinite alternate; }
.scanner-frame.active .scanner-line { display: block; }
.scanner-frame.active .scanner-placeholder { display: none; }
@keyframes scan { from { transform: translateY(-72px); } to { transform: translateY(72px); } }
.or-divider { display: flex; align-items: center; gap: 10px; margin: 17px 0; color: var(--muted); font-size: 11px; }
.or-divider::before, .or-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.barcode-form { display: flex; gap: 8px; }
.barcode-form button { padding: 0 16px; border: 0; border-radius: 12px; background: var(--ink); color: white; font-weight: 800; cursor: pointer; }
.lookup-status { min-height: 18px; color: var(--muted); font-size: 12px; text-align: center; }
.compact-sheet { bottom: 50%; max-width: 500px; padding: 28px; border-radius: 24px; transform: translate(-50%, 50%); animation: compact-in .2s ease-out; }
@keyframes compact-in { from { transform: translate(-50%, 45%); opacity: 0; } }
.quantity-card { padding: 18px; margin-bottom: 12px; border-radius: 16px; background: var(--soft); text-align: center; }
.quantity-card > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.quantity-card small { display: block; margin-top: 9px; color: var(--muted); font-size: 10px; }
.large-stepper { display: grid; grid-template-columns: 54px 1fr 54px; align-items: center; margin-top: 7px; }
.large-stepper button { height: 48px; border: 0; border-radius: 13px; background: white; cursor: pointer; font-size: 25px; }
.large-stepper strong { font-size: 30px; }
.edit-details { margin: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.edit-details summary { padding: 15px 2px; cursor: pointer; font-weight: 800; }
.edit-details form { padding: 0 0 16px; }
.danger-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.danger-actions button { min-height: 44px; border: 0; border-radius: 11px; background: transparent; color: #a03d2e; cursor: pointer; font-size: 12px; font-weight: 800; }
.danger-actions button:hover { background: #fae4df; }
.activity-list { display: grid; gap: 16px; max-height: 52vh; overflow-y: auto; }
.activity-day h3 { margin: 0 0 7px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.activity-day ul { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.activity-day li { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 8px 11px; border-bottom: 1px solid var(--line); }
.activity-day li:last-child { border-bottom: 0; }
.activity-day .avatar { width: 34px; height: 34px; }
.activity-day strong { display: block; }
.activity-day small { color: var(--muted); }
.welcome-icon { width: 66px; height: 66px; display: grid; place-items: center; margin-bottom: 17px; border-radius: 20px; background: #f5c665; font-size: 35px; transform: rotate(-3deg); }
.copy-field { display: flex; gap: 8px; margin: 17px 0 10px; }
.copy-field input { min-width: 0; height: 48px; flex: 1; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--soft); color: var(--muted); }
.copy-field button { border: 0; border-radius: 11px; padding: 0 16px; background: var(--ink); color: white; cursor: pointer; font-weight: 800; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 88px; max-width: calc(100% - 28px); display: flex; align-items: center; gap: 14px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; padding: 11px 14px; border-radius: 12px; background: var(--ink); color: white; box-shadow: var(--shadow); transition: .18s; font-size: 13px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast button { border: 0; background: transparent; color: #ffc8b9; cursor: pointer; font-weight: 900; }

@media (max-width: 620px) {
  .app-shell { padding-inline: 12px; }
  .topbar { min-height: 72px; }
  .brand-block p { display: none; }
  .quiet-button { font-size: 11px; padding-inline: 6px; }
  .profile-name { display: none; }
  .top-actions { gap: 1px; }
  .list-toolbar { grid-template-columns: 1fr auto; margin-top: 2px; }
  .sort-field select { width: 82px; padding-left: 10px; }
  .treat-row { grid-template-columns: 46px minmax(0,1fr) 44px 46px; padding-inline: 4px; }
  .compact-sheet { width: calc(100% - 20px); max-height: 90vh; padding: 23px 18px; }
  .form-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
