:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #22342b;
  background: #f5f6ef;
  -webkit-text-size-adjust: 100%;
  --green: #235543;
  --muted: #526358;
  --line: #dbe3d5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p { margin: 0; }
button, textarea, select { font: inherit; }
button { min-height: 44px; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #a16b25; outline-offset: 3px; }

.app {
  max-width: 530px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    calc(18px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.topbar, .brand, .top-actions, .dialog-title, .dialog-actions { display: flex; align-items: center; }
.topbar, .dialog-title { justify-content: space-between; gap: 12px; }
.brand { gap: 11px; }
.brand img { display: block; border-radius: 13px; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--muted); }
h1 { font-size: 23px; line-height: 1.25; margin-top: 2px; }
.import-button, .primary-button, .secondary-button, .copy-button {
  border-radius: 11px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
}
.import-button, .secondary-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--green);
}
.import-button span { font-weight: 800; }
.top-actions { gap: 6px; }
.trash-button {
  width: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--green);
}

.products {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-top: 19px;
  padding: 4px;
  border-radius: 13px;
  background: #e6ebdf;
}
.products button, .shelves button {
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}
.products button[aria-pressed="true"] { background: #fff; color: var(--green); }
.shelves { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.shelves button { border-color: var(--line); }
.shelves button[aria-pressed="true"] { background: #dce9d9; border-color: #8fac8c; color: #214c37; }

@media (max-width: 360px) {
  .topbar { gap: 6px; }
  .brand { gap: 7px; }
  .brand img { width: 40px; height: 40px; }
  .import-button { padding: 0 10px; }
  .import-button span { display: none; }
}

.stock {
  margin-top: 13px;
  border-radius: 18px;
  padding: 19px 20px;
  background: var(--green);
  color: #f9faf4;
}
.stock h2 { font-size: 14px; font-weight: 550; color: #e3ecde; }
.count { display: flex; align-items: baseline; gap: 9px; margin: 3px 0 6px; }
#count { font-size: 46px; line-height: 1.12; font-weight: 740; font-variant-numeric: tabular-nums; }
.unit { font-size: 15px; }
.stock p { font-size: 13px; line-height: 1.5; color: #e3ecde; }

.feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #e2edde;
  color: #254d3a;
  font-size: 14px;
  line-height: 1.5;
}
.feedback[data-error="true"] { background: #f8e9df; color: #853520; }
.inventory { margin-top: 20px; }
.inventory h2 { font-size: 16px; margin-bottom: 10px; }
.code-list { margin: 0; padding: 0; list-style: none; }
.code-list:not(:empty) { border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.code-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 8px 13px;
}
.code-list li + li { border-top: 1px solid #e7ebe3; }
code {
  font: 650 clamp(14px, 4.5vw, 17px)/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .04em;
  overflow-wrap: anywhere;
}
.copy-button { background: #e6efe5; border: 0; color: #224f3b; }
.primary-button { background: var(--green); border: 0; color: #fff; }

.empty {
  display: grid;
  justify-items: center;
  padding: 22px 14px 14px;
  border: 1px dashed #b7c6b3;
  border-radius: 14px;
  color: var(--muted);
}
.empty svg { color: #57745f; }
.empty p { margin-top: 6px; font-size: 15px; }
.text-button { border: 0; background: transparent; color: var(--green); font-size: 15px; font-weight: 650; }

footer { margin-top: 17px; color: var(--muted); font-size: 12px; line-height: 1.6; }
footer p + p { margin-top: 5px; }

dialog {
  width: min(calc(100% - 28px), 465px);
  max-height: calc(100dvh - 28px);
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fcfcf8;
  color: #22342b;
}
dialog::backdrop { background: rgb(26 38 30 / .5); }
.dialog-title { margin-bottom: 8px; }
.dialog-title h2 { font-size: 20px; }
.close-button { width: 44px; border: 0; background: transparent; font-size: 27px; color: var(--muted); }
label { display: block; font-size: 14px; margin-bottom: 7px; }
textarea, select {
  display: block;
  width: 100%;
  resize: vertical;
  padding: 10px;
  border: 1px solid #b7c6b3;
  border-radius: 9px;
  background: #fff;
  color: inherit;
  font-size: 16px;
  line-height: 1.45;
}
select { min-height: 44px; margin-bottom: 11px; }
.dialog-actions { justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.import-feedback { margin-top: 8px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.trash-note { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 9px; }
.trash-list li { flex-direction: column; align-items: flex-start; gap: 3px; }
.trash-list small { color: var(--muted); font-size: 12px; }
