#catalog .search-form {
  margin-block: 2px 13px;
}

#catalog-new {
  margin: 0 0 20px;
}

#catalog .item-list,
#pending .item-list,
#work-dialog .item-list {
  display: grid;
  gap: 8px;
}

#catalog .list-product,
#work-dialog .list-product {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 67px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  overflow-wrap: anywhere;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.list-product b {
  font-weight: 730;
  line-height: 1.2;
}

.product-description { display: grid; min-width: 0; gap: 4px; overflow-wrap: anywhere; }
.photo-credit { color: var(--muted); font-size: .72rem; line-height: 1.25; }
.photo-credit a { color: var(--violet); text-decoration: underline; text-underline-offset: 2px; }
#entry-product .product-description { flex: 1; }
#entry-product-photo, #food-product-photo { flex: 0 0 auto; }
.food-photo-preview { display: flex; align-items: center; gap: 10px; }

.list-product .muted {
  font-size: .875rem;
  line-height: 1.25;
}

#catalog .list-product:active,
#work-dialog .list-product:active {
  border-color: var(--violet);
  background: var(--lavender);
}

#pending .pending-card {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
}

#pending .meal-row {
  width: 100%;
  min-height: 68px;
  border: 0;
  padding: 11px 14px;
  gap: 12px;
  text-align: left;
}

#pending .entry-description {
  min-width: 0;
  overflow-wrap: anywhere;
}

#pending .entry-value {
  max-width: 39%;
  white-space: normal;
  line-height: 1.25;
}

#catalog .empty-message,
#pending .empty-message,
#work-dialog .empty-message {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
}

#work-dialog {
  position: fixed;
  width: min(100%, 34rem);
  max-width: 100%;
  max-height: calc(100vh - 18px);
  max-height: calc(100dvh - max(18px, env(safe-area-inset-top)));
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 84px 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 -16px 56px #20172a20;
}

#work-dialog::backdrop {
  background: #20172a68;
}

#work-dialog[open] {
  animation: food-sheet-in 180ms cubic-bezier(.2, .75, .35, 1) both;
}

@keyframes food-sheet-in {
  from { opacity: .7; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

#work-dialog .sheet {
  padding: 0 max(17px, env(safe-area-inset-right)) calc(21px + env(safe-area-inset-bottom)) max(17px, env(safe-area-inset-left));
}

#work-dialog .sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 15px;
  padding-block: 13px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

#work-dialog .sheet-head h2 {
  font-family: var(--display, system-ui);
  font-size: clamp(1.4rem, 6vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.08;
}

#work-dialog .close-button {
  width: 44px;
  min-height: 44px;
  flex: 0 0 44px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: var(--lavender);
  color: var(--violet);
  font-size: 1.65rem;
  font-weight: 500;
}

#work-dialog .mode > * + * {
  margin-block-start: 10px;
}

#work-dialog .field-stack {
  display: grid;
  gap: 13px;
}

#work-dialog .field-stack > * + * {
  margin-block-start: 0;
}

#work-dialog .field-grid,
#work-dialog .confirm-buttons,
.search-form {
  display: grid;
  align-items: end;
  gap: 9px;
}

#work-dialog .field-grid,
#work-dialog .confirm-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.search-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.search-form .button {
  min-height: 48px;
  padding-inline: 13px;
}

#work-dialog label:not(.check-label, .sr-only),
.auth-panel label {
  display: block;
  min-width: 0;
  color: var(--ink);
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.3;
}

#work-dialog label .muted {
  font-size: inherit;
  font-weight: 450;
}

#work-dialog label > :is(input:not([type="checkbox"]), select) {
  display: block;
  margin-top: 5px;
}

#catalog input[type="search"],
#work-dialog :is(input:not([type="checkbox"], [type="hidden"]), select),
.auth-panel input[type="password"] {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--bg, #f7f6fa);
  color: var(--ink);
  font: 500 1rem/1.3 var(--font, system-ui);
}

#catalog input::placeholder,
#work-dialog input::placeholder {
  color: var(--muted);
  opacity: 1;
}

#work-dialog select {
  appearance: none;
  height: 48px;
  padding-inline-end: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--violet) 50%),
    linear-gradient(135deg, var(--violet) 50%, transparent 50%);
  background-position: right 16px center, right 11px center;
  background-repeat: no-repeat;
  background-size: 5px 5px;
}

#work-dialog :is(input, select):focus,
#catalog input:focus,
.auth-panel input:focus {
  border-color: var(--violet);
}

#work-dialog .check-label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  line-height: 1.3;
}

#work-dialog input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--violet);
}

#work-dialog .selected-product {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  border-radius: 14px;
  background: var(--lavender);
}

#work-dialog .selected-product > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow-wrap: anywhere;
}

#work-dialog .selected-product .text-button {
  color: var(--violet);
  font-size: .875rem;
}

#work-dialog .form-error,
.auth-panel .form-error {
  margin-bottom: 14px;
  padding: 11px 13px;
  border-radius: 12px;
  background: #faedf1;
  color: #8c294d;
  font-size: .9rem;
  overflow-wrap: anywhere;
}

#work-dialog .remove-button {
  color: var(--danger);
}

#lookup-items {
  max-height: 34dvh;
  padding-bottom: 1px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#entry-label-file::file-selector-button {
  margin-inline-end: 8px;
  padding: 6px 9px;
  border: 0;
  border-radius: 8px;
  background: var(--lavender);
  color: var(--violet);
  font: 700 .875rem var(--font, system-ui);
  cursor: pointer;
}

#entry-label-preview {
  display: block;
  width: 100%;
  max-height: 210px;
  object-fit: contain;
  border-radius: 14px;
  background: var(--bg, #f7f6fa);
}

#work-dialog .camera {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 17px;
  background: var(--ink);
}

#work-dialog .camera video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#work-dialog .scan-guide {
  position: absolute;
  inset: 27% 11%;
  border: 2px solid var(--lime);
  border-radius: 12px;
  box-shadow: 0 0 0 200px #20172a50;
  pointer-events: none;
}

#work-dialog .scan-guide::after {
  content: "";
  position: absolute;
  top: 50%;
  inset-inline: 6%;
  height: 1px;
  background: var(--lime);
  opacity: .65;
}

#work-dialog .camera-stop {
  position: absolute;
  inset: auto 9px 9px auto;
  min-height: 44px;
  padding: 5px 12px;
  border: 1px solid #ffffff32;
  border-radius: 11px;
  background: var(--ink);
  color: white;
  font-size: .875rem;
  font-weight: 700;
}

#scan-message {
  padding: 1px 1px 3px;
  line-height: 1.35;
}

body.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 83% 9%, var(--lavender, #eee8f8), transparent 55%), var(--bg, #f7f6fa);
}

main.auth-card {
  display: grid;
  width: min(100%, 27rem);
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 27px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.auth-visual {
  min-height: clamp(9rem, 42vw, 13rem);
  display: flex;
  align-items: flex-start;
  padding: 20px;
  background-color: var(--ink);
  background-image: linear-gradient(90deg, #21172ce8 0%, #21172c25 78%), url("market-still-life.webp"), radial-gradient(ellipse at 80% 50%, #684c8b, transparent 62%);
  background-position: center, right 48%, center;
  background-size: cover;
  color: white;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font: 750 1.46rem/1 var(--display, system-ui);
  letter-spacing: -.04em;
}

.auth-brand .brand-mark {
  background: var(--lime);
}

.auth-brand .brand-mark i {
  background: var(--ink);
}

.auth-panel {
  min-width: 0;
  padding: clamp(17px, 5vw, 29px);
}

.auth-panel h1 {
  margin: 0 0 19px;
  color: var(--ink);
  font-family: var(--display, system-ui);
  font-size: clamp(1.6rem, 7.5vw, 2.43rem);
  font-weight: 720;
  line-height: 1.05;
  letter-spacing: -.045em;
  hyphens: auto;
  overflow-wrap: anywhere;
}

.auth-panel form {
  display: grid;
  gap: 7px;
}

.auth-panel form .button {
  width: 100%;
  margin-top: 6px;
}

@media (min-width: 640px) {
  #work-dialog {
    margin: auto;
    border-bottom: 1px solid var(--line);
    border-radius: 26px;
  }

  #work-dialog .sheet {
    padding: 0 22px 21px;
  }
}

@media (min-width: 800px) {
  main.auth-card {
    grid-template-columns: .94fr 1.06fr;
    width: min(100%, 48rem);
    min-height: 302px;
  }

  .auth-visual {
    padding: 24px;
  }

  .auth-panel {
    align-self: center;
    padding: 29px;
  }

  .auth-panel h1 {
    font-size: 2.18rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  #work-dialog[open] { animation: none; }
  #catalog .list-product,
  #work-dialog .list-product { transition: none; }
}
