:root {
  --paper: #fffaf0;
  --paper-deep: #fff1cc;
  --card: #ffffff;
  --ink: #2c251f;
  --muted: #81746a;
  --line: rgba(54, 42, 28, 0.1);
  --gold: #f2b84b;
  --gold-strong: #db8d0f;
  --sage: #9fbf8f;
  --sage-deep: #55784d;
  --coral: #f28b74;
  --blue: #6f98c9;
  --shadow: 0 18px 50px rgba(83, 61, 34, 0.14);
  --radius: 22px;
  color-scheme: light;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 4%, rgba(242, 184, 75, 0.32), transparent 22rem),
    radial-gradient(circle at 92% 24%, rgba(159, 191, 143, 0.28), transparent 24rem),
    linear-gradient(145deg, #fff8e8 0%, #f8fbef 52%, #fff1e9 100%);
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.55) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.55) 1px, transparent 1px);
  background-size: 30px 30px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(219, 141, 15, 0.3);
  outline-offset: 2px;
}

img {
  display: block;
  max-width: 100%;
}

.icon-sprite {
  display: none;
}

.app-shell {
  position: relative;
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.96), rgba(255, 250, 240, 0.9)),
    var(--paper);
  box-shadow: 0 0 0 1px rgba(65, 50, 31, 0.06), 0 30px 90px rgba(66, 49, 32, 0.18);
  overflow: hidden;
}

.app-main {
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 18px calc(104px + env(safe-area-inset-bottom));
}

.page {
  display: none;
  animation: pageIn 0.24s ease-out;
}

.page.is-active {
  display: block;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 900;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.round-action {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 50%;
  color: #39291d;
  background: var(--gold);
  box-shadow: 0 12px 26px rgba(219, 141, 15, 0.24);
}

.round-action.soft {
  color: var(--sage-deep);
  background: #eaf3df;
  box-shadow: none;
}

.round-action svg,
.bottom-nav svg,
.ghost-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero-card {
  display: grid;
  grid-template-columns: 102px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(255, 243, 209, 0.9)),
    var(--card);
  box-shadow: var(--shadow);
}

.cat-plate {
  position: relative;
  display: grid;
  place-items: center;
  width: 102px;
  height: 102px;
  border-radius: 31px;
  background:
    linear-gradient(145deg, #f5cc73, #f7e5b5 62%, #ffffff);
  overflow: hidden;
}

.cat-plate::after {
  position: absolute;
  inset: auto 12px 10px;
  height: 9px;
  border-radius: 999px;
  background: rgba(112, 75, 28, 0.12);
  content: "";
}

.cat-plate img {
  position: relative;
  z-index: 1;
  width: 92px;
  height: 92px;
  object-fit: contain;
  filter: drop-shadow(0 11px 10px rgba(86, 54, 20, 0.18));
}

.hero-copy {
  min-width: 0;
}

.label-pill {
  display: inline-flex;
  width: fit-content;
  margin: 0 0 8px;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--sage-deep);
  background: #edf6e6;
  font-size: 12px;
  font-weight: 800;
}

.hero-copy h2 {
  margin-bottom: 4px;
  font-size: 27px;
  font-weight: 900;
}

.hero-copy p:not(.label-pill) {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hero-tags span {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  color: #624225;
  background: rgba(255, 255, 255, 0.74);
  font-size: 11px;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 16px 0 22px;
}

.metric-card {
  min-height: 104px;
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
}

.metric-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 22px;
  line-height: 1;
}

.metric-card span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin: 22px 0 12px;
}

.section-head.compact {
  align-items: center;
  margin-top: 0;
}

.text-button,
.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--sage-deep);
  background: #eef6e8;
  font-size: 13px;
  font-weight: 800;
}

.attention-list,
.item-list,
.restock-list,
.price-ledger,
.packing-list {
  display: grid;
  gap: 10px;
}

.attention-card,
.inventory-card,
.restock-card,
.ledger-card,
.packing-card,
.profile-card,
.preference-grid article,
.quick-panel,
.restock-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 30px rgba(83, 61, 34, 0.08);
}

.attention-card,
.restock-card,
.ledger-card,
.packing-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.attention-card h3,
.restock-card h3,
.ledger-card h3,
.packing-card h3 {
  margin-bottom: 4px;
}

.attention-card p,
.restock-card p,
.ledger-card p,
.packing-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-chip.low {
  color: #8c3524;
  background: #ffe5dc;
}

.status-chip.soon {
  color: #80540c;
  background: #fff0bf;
}

.status-chip.ok {
  color: var(--sage-deep);
  background: #eaf5e2;
}

.quick-panel {
  margin-top: 18px;
  padding: 16px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.quick-action {
  display: grid;
  gap: 6px;
  justify-items: start;
  min-height: 88px;
  padding: 12px;
  border-radius: 18px;
  color: var(--ink);
  background: #fff4d5;
  text-align: left;
}

.quick-action:nth-child(2) {
  background: #edf6e6;
}

.quick-action:nth-child(3) {
  background: #fbe8df;
}

.quick-action strong {
  font-size: 14px;
}

.quick-action span {
  color: var(--muted);
  font-size: 11px;
}

.search-box {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  min-height: 48px;
  margin-bottom: 13px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.82);
}

.search-box span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  background: var(--sage);
  font-size: 12px;
  font-weight: 900;
}

.search-box input,
.item-form input,
.item-form select,
.item-form textarea {
  width: 100%;
  border: 0;
  color: var(--ink);
  background: transparent;
}

.search-box input {
  min-height: 46px;
}

.category-strip {
  display: flex;
  gap: 8px;
  margin: 0 -18px 14px;
  padding: 0 18px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-strip::-webkit-scrollbar {
  display: none;
}

.category-chip {
  min-width: max-content;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 800;
}

.category-chip.is-active {
  color: #4f3211;
  background: var(--gold);
  border-color: rgba(117, 76, 18, 0.12);
}

.inventory-card {
  padding: 15px;
}

.item-top {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.item-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: var(--paper-deep);
  font-size: 20px;
}

.item-title {
  min-width: 0;
}

.item-title h3 {
  overflow: hidden;
  margin-bottom: 3px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.item-progress {
  height: 8px;
  margin: 13px 0 11px;
  border-radius: 999px;
  background: rgba(61, 42, 18, 0.08);
  overflow: hidden;
}

.item-progress span {
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sage), var(--gold));
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.item-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #725b45;
  background: #faf1df;
  font-size: 12px;
  font-weight: 700;
}

.item-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.small-button {
  min-height: 38px;
  border-radius: 14px;
  color: #4a3728;
  background: #f8eccd;
  font-size: 13px;
  font-weight: 900;
}

.small-button.secondary {
  color: var(--sage-deep);
  background: #edf6e7;
}

.restock-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 13px;
  padding: 14px;
}

.summary-cell {
  min-width: 0;
}

.summary-cell strong {
  display: block;
  margin-bottom: 4px;
  font-size: 21px;
}

.summary-cell span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.price {
  color: #7c4d08;
  font-weight: 900;
}

.profile-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 15px;
}

.profile-card img {
  width: 82px;
  height: 82px;
  object-fit: contain;
  border-radius: 26px;
  background: #fff1cc;
}

.profile-card p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.muted {
  color: var(--muted);
}

.preference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.preference-grid article {
  padding: 15px;
}

.preference-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

.packing-checkbox {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid rgba(85, 120, 77, 0.25);
  border-radius: 10px;
  color: #fff;
  background: #fff;
}

.packing-card.is-done .packing-checkbox {
  border-color: var(--sage);
  background: var(--sage);
}

.bottom-nav {
  position: fixed;
  right: 50%;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(100%, 480px);
  min-height: calc(76px + env(safe-area-inset-bottom));
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(65, 50, 31, 0.08);
  background: rgba(255, 253, 245, 0.9);
  backdrop-filter: blur(18px);
  transform: translateX(50%);
}

.nav-item {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 58px;
  border-radius: 18px;
  color: #978574;
  background: transparent;
  font-size: 11px;
  font-weight: 800;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.is-active {
  color: #3b2b1e;
  background: #fff0bf;
}

.item-dialog {
  width: min(100% - 18px, 462px);
  max-height: min(86dvh, 720px);
  margin: auto auto 9px;
  padding: 0;
  border: 0;
  border-radius: 26px;
  color: var(--ink);
  background: #fffdf6;
  box-shadow: 0 30px 80px rgba(50, 32, 18, 0.28);
}

.item-dialog::backdrop {
  background: rgba(42, 32, 21, 0.28);
  backdrop-filter: blur(7px);
}

.item-form {
  display: grid;
  gap: 13px;
  padding: 12px 16px 18px;
}

.sheet-handle {
  width: 44px;
  height: 5px;
  margin: 0 auto 2px;
  border-radius: 999px;
  background: rgba(68, 49, 30, 0.18);
}

.item-form label {
  display: grid;
  gap: 7px;
  color: #6e5f51;
  font-size: 12px;
  font-weight: 900;
}

.item-form input,
.item-form select,
.item-form textarea {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff7e8;
}

.item-form textarea {
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.primary-button {
  min-height: 48px;
  border-radius: 16px;
  color: #3b2816;
  background: var(--gold);
  font-weight: 950;
  box-shadow: 0 13px 28px rgba(219, 141, 15, 0.24);
}

.toast {
  position: fixed;
  right: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(360px, calc(100% - 32px));
  padding: 11px 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(44, 37, 31, 0.92);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(50%, 0);
}

.empty-state {
  padding: 22px;
  border: 1px dashed rgba(84, 62, 34, 0.2);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  text-align: center;
}

@media (min-width: 760px) {
  body {
    padding: 28px 0;
  }

  .app-shell {
    min-height: calc(100dvh - 56px);
    border-radius: 32px;
  }

  .app-main {
    min-height: calc(100dvh - 56px);
  }

  .bottom-nav {
    bottom: 28px;
    border-radius: 0 0 32px 32px;
  }
}

@media (max-width: 370px) {
  .app-main {
    padding-inline: 14px;
  }

  h1 {
    font-size: 27px;
  }

  .hero-card {
    grid-template-columns: 88px minmax(0, 1fr);
    padding: 13px;
  }

  .cat-plate {
    width: 88px;
    height: 88px;
    border-radius: 27px;
  }

  .cat-plate img {
    width: 78px;
    height: 78px;
  }

  .metric-grid,
  .quick-actions,
  .restock-summary {
    grid-template-columns: 1fr;
  }

  .preference-grid,
  .form-row {
    grid-template-columns: 1fr;
  }
}
