:root {
  --paper: #f3eee4;
  --paper-2: #e8dfd0;
  --ink: #1c271d;
  --muted: #66715f;
  --green: #2f5d3a;
  --green-2: #3f734b;
  --leaf: #dce8d8;
  --clay: #c45c32;
  --card: #fffdf8;
  --line: #e2d6c4;
  --danger: #b42318;
  --danger-bg: #fde8e6;
  --warn: #b45309;
  --warn-bg: #fff4e0;
  --ok: #2f5d3a;
  --shadow: 0 10px 30px rgba(44, 36, 22, 0.08);
  --radius: 18px;
  --tab: calc(64px + env(safe-area-inset-bottom));
  --font: "Figtree", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 420px at 8% -5%, rgba(239, 228, 204, 0.9) 0%, transparent 55%),
    radial-gradient(700px 380px at 95% 8%, rgba(220, 232, 216, 0.55) 0%, transparent 50%),
    radial-gradient(500px 300px at 50% 100%, rgba(196, 92, 50, 0.06) 0%, transparent 60%);
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.ambient__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
}
.ambient__blob--1 {
  width: 280px;
  height: 280px;
  top: -80px;
  right: -60px;
  background: rgba(47, 93, 58, 0.09);
}
.ambient__blob--2 {
  width: 220px;
  height: 220px;
  bottom: 120px;
  left: -70px;
  background: rgba(196, 92, 50, 0.07);
}
.ambient__wave {
  position: absolute;
  left: 0;
  width: 100%;
  height: auto;
}
.ambient__wave--top {
  top: 0;
  height: 72px;
  opacity: 0.85;
}
.ambient__wave--bottom {
  bottom: calc(var(--tab) - 20px);
  height: 88px;
  opacity: 0.9;
}
.ambient__lines {
  position: absolute;
  top: 12%;
  right: -20px;
  width: 140px;
  height: 140px;
  opacity: 0.7;
}

.app {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 16px 16px var(--tab);
  position: relative;
  z-index: 1;
}

a { color: var(--green); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.topbar .page-head {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
}
.topbar > .icon-btn {
  flex-shrink: 0;
}
.brand {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.brand small {
  display: block;
  font-family: var(--font);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.shelfie-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.shelfie-logo--hero {
  flex-direction: column;
  text-align: center;
  gap: 14px;
  margin-bottom: 8px;
}
.shelfie-mark {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(47, 93, 58, 0.22);
}
.shelfie-logo--hero .shelfie-mark {
  width: 72px;
  height: 72px;
  border-radius: 20px;
}
.shelfie-word { min-width: 0; }
.shelfie-name {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.55rem;
  letter-spacing: -0.04em;
  line-height: 1.05;
  background: linear-gradient(135deg, var(--ink) 0%, var(--green) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.shelfie-logo--hero .shelfie-name {
  font-size: 2.35rem;
}
.shelfie-word small {
  display: block;
  margin-top: 4px;
  font-family: var(--font);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.page-head {
  position: relative;
  margin-bottom: 16px;
  padding-top: 4px;
}
.page-head__line {
  position: absolute;
  left: 0;
  top: 0;
  width: 56px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--clay));
  opacity: 0.85;
}
.page-head__title {
  padding-top: 14px;
}

.top-actions { display: flex; gap: 8px; }

.icon-btn, .btn, .chip {
  border: 0;
  cursor: pointer;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}
.icon-btn svg { width: 20px; height: 20px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  font-weight: 650;
}
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--green); }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }

.flash {
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 14px;
  font-weight: 600;
}
.flash.success { background: var(--leaf); color: var(--green); }
.flash.error { background: var(--danger-bg); color: var(--danger); }

.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 4px 4px 4px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.searchbar input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 10px 0;
  outline: none;
}
.searchbar button { margin: 0; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 22px 0 10px;
}
.section-head h2, .place-title {
  font-family: var(--display);
  font-size: 1.35rem;
  margin: 0;
  position: relative;
  padding-left: 12px;
}
.section-head h2::before, .place-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.15em;
  bottom: 0.15em;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--green), var(--clay));
  opacity: 0.75;
}
.place-block { margin-bottom: 8px; }
.type-label {
  margin: 14px 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-list { display: grid; gap: 10px; }
.product-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  background: linear-gradient(145deg, #fffdf8 0%, #faf6ee 100%);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  color: inherit;
  border: 1px solid rgba(226, 214, 196, 0.65);
}
.product-card:active { transform: scale(0.995); }
.thumb {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--leaf);
  display: grid;
  place-items: center;
  color: var(--green);
  font-family: var(--display);
  font-size: 1.4rem;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.meta h3 { margin: 0 0 2px; font-size: 1.05rem; }
.meta p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink);
}
.badge.low { background: #f3e0c8; color: #8a4b12; }
.badge.zero { background: var(--danger-bg); color: var(--danger); }
.badge.open { background: var(--leaf); color: var(--green); }
.badge.hidden { background: #ececec; color: #666; }
.alert {
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 700;
}
.alert.expired { color: var(--danger); }
.alert.soon { color: var(--warn); }

.empty {
  text-align: center;
  padding: 36px 16px 42px;
  background: linear-gradient(160deg, #fffdf8 0%, #f5efe3 100%);
  border-radius: 24px;
  box-shadow: var(--shadow);
  border: 1px dashed rgba(47, 93, 58, 0.18);
}
.empty-art {
  color: var(--green);
  opacity: 0.45;
  margin-bottom: 8px;
}
.empty-art__svg {
  width: 120px;
  height: auto;
  margin: 0 auto;
}
.empty h2 { font-family: var(--display); margin: 0 0 8px; }
.empty p { color: var(--muted); }

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.filters .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span2 { grid-column: 1 / -1; }
label { font-size: 0.82rem; font-weight: 700; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="file"], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 12px 12px;
  color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; gap: 12px; }
.form-card, .panel {
  background: linear-gradient(180deg, #fffdf8 0%, #faf7f0 100%);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  border: 1px solid rgba(226, 214, 196, 0.55);
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}
.check[hidden] { display: none !important; }
.check input { width: 18px; height: 18px; }
.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--paper-2);
  padding: 4px;
  border-radius: 14px;
}
.segment label {
  text-align: center;
  padding: 0;
  color: var(--ink);
  font-size: 0.95rem;
}
.segment input { display: none; }
.segment span {
  display: block;
  padding: 10px 8px;
  border-radius: 11px;
}
.segment input:checked + span {
  background: var(--card);
  box-shadow: var(--shadow);
}

.qty-box {
  display: flex;
  align-items: center;
  gap: 10px;
}
.qty-box .btn { width: 46px; padding: 0; font-size: 1.3rem; }
.qty-value { font-family: var(--display); font-size: 2rem; min-width: 48px; text-align: center; }

.hero-photo {
  height: 220px;
  border-radius: 24px;
  overflow: hidden;
  background: var(--leaf);
  margin-bottom: 14px;
  display: grid;
  place-items: center;
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; }
.dl { display: grid; gap: 8px; }
.dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 700; text-align: right; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 8px env(safe-area-inset-bottom);
  z-index: 20;
  box-shadow: 0 -8px 32px rgba(44, 36, 22, 0.04);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 6px 0;
}
.tabbar a.active { color: var(--green); }
.tabbar svg { width: 22px; height: 22px; }

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  position: relative;
  z-index: 1;
}
.auth-card {
  width: min(420px, 100%);
  background: linear-gradient(165deg, rgba(255, 253, 248, 0.92) 0%, rgba(250, 247, 240, 0.88) 100%);
  backdrop-filter: blur(8px);
  border-radius: 28px;
  padding: 28px 22px;
  border: 1px solid rgba(226, 214, 196, 0.7);
  box-shadow: 0 20px 50px rgba(44, 36, 22, 0.1);
}
.auth .shelfie-logo--hero {
  margin-bottom: 4px;
}
.auth-card h1 {
  font-family: var(--display);
  font-size: 2.4rem;
  margin: 0 0 6px;
}
.lede { color: var(--muted); margin: 0 0 22px; }
.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.place-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.toggle-row {
  display: flex;
  justify-content: flex-end;
  clear: both;
  margin: 0 0 14px;
}
.toggle-row a { font-size: 0.85rem; font-weight: 700; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.3rem;
  letter-spacing: 0.14em;
  background: var(--leaf);
  padding: 12px;
  border-radius: 12px;
  text-align: center;
}
.preview {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 16px;
  display: none;
}
.preview.show { display: block; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.install-banner {
  display: none;
  background: var(--green);
  color: white;
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 14px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.install-banner.show { display: flex; }
.install-banner button { background: #fff; color: var(--green); }

@media (min-width: 720px) {
  .app { padding-top: 28px; }
  .card-list { grid-template-columns: 1fr; }
  .ambient__wave--bottom { bottom: 72px; }
}

body:not(.has-tabbar) .ambient__wave--bottom {
  bottom: 0;
}
