:root {
  --bg0: #f3f6f2;
  --bg1: #e7eee8;
  --ink: #14241e;
  --muted: #5f7368;
  --line: rgba(20, 36, 30, 0.1);
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --accent: #1f6f5b;
  --accent-soft: #d7efe6;
  --accent-2: #c45c26;
  --plus: #1f6f5b;
  --minus: #b42318;
  --danger: #b42318;
  --shadow: 0 12px 40px rgba(20, 36, 30, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
  --tabbar-h: calc(64px + env(safe-area-inset-bottom));
  --font: "Source Sans 3", system-ui, sans-serif;
  --display: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(31, 111, 91, 0.16), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(196, 92, 38, 0.1), transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1));
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }

.app {
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + 1rem);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  padding-top: calc(0.85rem + env(safe-area-inset-top));
  backdrop-filter: blur(14px);
  background: rgba(243, 246, 242, 0.85);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.15rem;
}
.brand-mark {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 9px;
  background: linear-gradient(135deg, #2a9d8f, #1f6f5b 60%, #c45c26);
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--panel-solid);
  border-radius: 12px;
  width: 2.4rem;
  height: 2.4rem;
  cursor: pointer;
  font-size: 1rem;
}

.main {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 1rem 1rem 0;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.15rem;
  padding: 0.45rem 0.4rem calc(0.45rem + env(safe-area-inset-bottom));
  background: rgba(20, 36, 30, 0.94);
  color: #eef5f0;
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  color: rgba(238, 245, 240, 0.62);
  font-size: 0.68rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.35rem 0.2rem;
  border-radius: 12px;
}
.tabbar a.active, .tabbar a:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}
.tab-ico { font-size: 1.15rem; line-height: 1; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.page-head.tight { margin-top: 0.75rem; }
.page-head h1, .hero-home h1, .auth-body h1 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: clamp(1.7rem, 5vw, 2.35rem);
  margin: 0.1rem 0 0;
  line-height: 1.1;
}
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 700;
}
.lede { color: var(--muted); margin: 0.35rem 0 0; line-height: 1.45; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.7rem 1.05rem;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  min-height: 44px;
}
.btn:hover { background: #f4f8f5; text-decoration: none; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: rgba(180, 35, 24, 0.25); }
.btn.ghost { background: transparent; border: none; color: var(--muted); min-height: auto; padding: 0.35rem 0.5rem; }
.btn.wide { width: 100%; }
.actions { display: flex; gap: 0.45rem; flex-wrap: wrap; }

input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 0.78rem 0.9rem;
  color: var(--ink);
}
textarea { resize: vertical; }
label { display: block; font-size: 0.92rem; font-weight: 600; }
.stack { display: grid; gap: 0.9rem; }
.stack.compact { gap: 0.7rem; margin-top: 0.85rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }

.toast {
  border-radius: 14px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.85);
  animation: rise 0.35s ease;
}
.toast-ok { background: var(--accent-soft); border-color: rgba(31,111,91,0.25); }
.toast-error { background: #fdecea; border-color: rgba(180,35,24,0.25); color: var(--danger); }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.hero-home { margin-bottom: 1.1rem; }
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.4rem;
}
.home-card {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  min-height: 92px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.home-card:hover { transform: translateY(-2px); text-decoration: none; }
.home-card strong { display: block; font-family: var(--display); font-size: 1.05rem; }
.home-card span:last-child { color: var(--muted); font-size: 0.88rem; }
.home-emoji { font-size: 1.6rem; }
.home-card.products { background: linear-gradient(145deg, #fff, #e8f6ef); }
.home-card.things { background: linear-gradient(145deg, #fff, #f4efe8); }
.home-card.rooms { background: linear-gradient(145deg, #fff, #eef2f7); }
.home-card.add { background: linear-gradient(145deg, #1f6f5b, #2a9d8f); color: #fff; }
.home-card.add span:last-child { color: rgba(255,255,255,0.8); }

.section { margin-top: 0.5rem; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.55rem;
}
.section h2, .form-card h2, .room-card h2 {
  font-family: var(--display);
  font-size: 1.15rem;
  margin: 0 0 0.7rem;
  letter-spacing: -0.02em;
}

.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.feed a { color: inherit; text-decoration: none; display: flex; justify-content: space-between; gap: 0.75rem; }
.feed-row { display: flex; justify-content: space-between; gap: 0.75rem; width: 100%; }
.feed.dense li { padding: 0.85rem 0; }
.plus { color: var(--plus); font-weight: 700; }
.minus { color: var(--minus); font-weight: 700; }
.muted { color: var(--muted); }
.tiny { font-size: 0.8rem; }
.empty { color: var(--muted); }

.search-bar {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1rem;
}
@media (min-width: 640px) {
  .search-bar {
    grid-template-columns: 1.2fr 1fr 1fr auto;
    align-items: center;
  }
  .search-bar:has(select[name="expiry"]) {
    grid-template-columns: 1.1fr 0.9fr 0.9fr 0.9fr auto;
  }
}

.item-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 560px) {
  .item-grid { grid-template-columns: 1fr 1fr; }
}

.item-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.8rem;
  padding: 0.65rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease;
}
.item-card:hover { transform: translateY(-2px); text-decoration: none; }
.item-photo {
  width: 88px;
  height: 88px;
  border-radius: 16px;
  overflow: hidden;
  background: #e5efe9;
  display: grid;
  place-items: center;
}
.item-photo img { width: 100%; height: 100%; object-fit: cover; }
.item-photo.placeholder span { font-size: 1.7rem; opacity: 0.7; }
.item-body strong {
  display: block;
  font-family: var(--display);
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}
.item-meta { display: grid; gap: 0.2rem; }
.qty { font-weight: 700; color: var(--accent); }
.where { font-size: 0.82rem; color: var(--muted); }
.expiry {
  font-size: 0.78rem;
  font-weight: 650;
  margin-top: 0.15rem;
}
.badge-expired { color: var(--minus); }
.badge-soon { color: #a35b12; }
.badge-ok { color: var(--muted); }

.item-card.exp-expired {
  border-color: rgba(180, 35, 24, 0.28);
  background: linear-gradient(145deg, #fff, #fdecea);
}
.item-card.exp-soon {
  border-color: rgba(163, 91, 18, 0.28);
  background: linear-gradient(145deg, #fff, #fff4e6);
}

.expiry-card {
  margin: 0 0 0.9rem;
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.expiry-card .tiny { color: var(--muted); }
.expiry-card strong {
  display: block;
  font-family: var(--display);
  font-size: 1.15rem;
  margin-top: 0.2rem;
  letter-spacing: -0.02em;
}
.expiry-card .muted-strong { color: var(--muted); font-weight: 600; font-size: 1rem; }
.expiry-card.status-expired {
  background: #fdecea;
  border-color: rgba(180, 35, 24, 0.28);
  color: var(--minus);
}
.expiry-card.status-soon {
  background: #fff4e6;
  border-color: rgba(163, 91, 18, 0.28);
  color: #a35b12;
}
.expiry-card.status-ok { color: var(--accent); }

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px dashed var(--line);
}
.empty-ico { font-size: 2.4rem; margin-bottom: 0.5rem; }
.empty-state .btn { margin-top: 0.9rem; }

.form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.photo-picker {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.9rem;
  align-items: center;
}
.photo-preview {
  width: 110px;
  height: 110px;
  border-radius: 18px;
  overflow: hidden;
  background: #e5efe9;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  border: 1px dashed rgba(31,111,91,0.3);
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.check-inline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.55rem;
  font-weight: 500;
  color: var(--muted);
}
.check-inline input { width: auto; margin: 0; }

.detail-hero {
  border-radius: 24px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: #dfeae3;
  box-shadow: var(--shadow);
}
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero.no-photo { aspect-ratio: 16 / 7; display: grid; place-items: center; }
.detail-placeholder { font-size: 3rem; opacity: 0.7; }

.qty-card {
  margin: 0.9rem 0;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #1f6f5b, #2a9d8f);
  color: #fff;
  box-shadow: var(--shadow);
}
.qty-card .tiny { color: rgba(255,255,255,0.75); }
.qty-card strong {
  display: block;
  font-family: var(--display);
  font-size: 2rem;
  letter-spacing: -0.03em;
  margin-top: 0.15rem;
}
.qty-card strong span { font-size: 1rem; opacity: 0.85; font-weight: 600; }
.qty-sub {
  margin-top: 0.45rem;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.82);
  font-weight: 600;
}
.notes {
  white-space: pre-wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.batch-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.batch-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.batch-card.exp-expired {
  background: #fdecea;
  border-color: rgba(180, 35, 24, 0.28);
}
.batch-card.exp-soon {
  background: #fff4e6;
  border-color: rgba(163, 91, 18, 0.28);
}
.batch-main { display: grid; gap: 0.2rem; }
.batch-actions { display: flex; gap: 0.35rem; align-items: center; }
.hint-box {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid rgba(31, 111, 91, 0.2);
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.4;
}

.barcode-box { display: grid; gap: 0.45rem; }
.barcode-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.4rem;
  margin-top: 0.35rem;
}
.barcode-row input { margin: 0; }
.scanner-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 16, 14, 0.72);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.scanner-modal[hidden] { display: none !important; }
.scanner-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 1rem;
  box-shadow: var(--shadow);
}
.scanner-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
#reader {
  overflow: hidden;
  border-radius: 14px;
  background: #111;
}
.scan-result {
  margin-top: 0.9rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid rgba(31,111,91,0.2);
}

.quick-qty {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.qty-btn {
  font-size: 1.35rem;
  font-weight: 800;
  min-height: 52px;
}

.rooms-list { display: grid; gap: 0.9rem; margin-bottom: 1rem; }
.room-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.room-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.place-list { list-style: none; margin: 0; padding: 0; }
.place-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
.inline-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.inline-add input { margin: 0; }

.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.auth-card {
  width: min(440px, 100%);
  overflow: hidden;
  border-radius: 28px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.auth-visual {
  height: 140px;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.35), transparent 40%),
    linear-gradient(135deg, #1f6f5b, #2a9d8f 55%, #c45c26);
}
.auth-body { padding: 1.35rem 1.3rem 1.5rem; }

@media (min-width: 860px) {
  .app { padding-bottom: 1.5rem; }
  .tabbar {
    position: sticky;
    top: auto;
    bottom: auto;
    order: -1;
    margin: 0.85rem auto 0;
    width: min(920px, calc(100% - 2rem));
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.08);
  }
  .app {
    display: flex;
    flex-direction: column;
  }
  .main { padding-top: 1.25rem; }
}

@media (max-width: 420px) {
  .home-grid { grid-template-columns: 1fr; }
  .photo-picker { grid-template-columns: 1fr; justify-items: start; }
  .row-2 { grid-template-columns: 1fr; }
  .tabbar a span:not(.tab-ico) { font-size: 0.68rem; }
}

/* Catalog UX */
.catalog-tools { margin-bottom: 1rem; display: grid; gap: 0.75rem; }
.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}
.chip-scroll {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}
.chip.active {
  background: color-mix(in srgb, var(--chip, var(--accent)) 18%, white);
  border-color: color-mix(in srgb, var(--chip, var(--accent)) 40%, white);
  color: color-mix(in srgb, var(--chip, var(--accent)) 70%, black);
}
.filters-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.9rem;
}
.filters-panel summary {
  cursor: pointer;
  font-weight: 650;
  padding: 0.75rem 0;
  list-style: none;
}
.filters-panel summary::-webkit-details-marker { display: none; }
.filters-body {
  display: grid;
  gap: 0.75rem;
  padding-bottom: 0.9rem;
}
.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--tabbar-h) + 0.85rem);
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  font-weight: 500;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(31, 111, 91, 0.35);
  z-index: 25;
}
.fab:hover { filter: brightness(1.06); text-decoration: none; color: #fff; }

.more-list {
  display: grid;
  gap: 0.65rem;
}
.more-list a {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}
.more-list strong { display: block; font-family: var(--display); }
.more-ico { font-size: 1.45rem; }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  background: rgba(20, 36, 30, 0.06);
  padding: 0.3rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}
.seg a {
  text-align: center;
  padding: 0.65rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}
.seg a.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.alert-banner {
  display: block;
  margin-bottom: 0.9rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: #fff4e6;
  border: 1px solid rgba(163, 91, 18, 0.28);
  color: #a35b12;
  text-decoration: none;
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--pill, #2A9D8F) 18%, white);
  color: color-mix(in srgb, var(--pill, #2A9D8F) 70%, black);
  font-size: 0.82rem;
  font-weight: 600;
}
.cat-line {
  font-size: 0.82rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--chip, var(--accent)) 65%, black);
}
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
