@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap");

:root {
  --espresso: #2D1A0E;
  --burgundy: #461312;
  --ruby: #6C0B25;
  --olive: #64652A;
  --sage: #B5AD80;
  --cream: #FDFAEB;

  --paper: #FFFDF5;
  --ink: var(--espresso);
  --muted: #776B5C;
  --line: rgba(45, 26, 14, 0.12);

  --success: var(--olive);
  --warning: #9B762E;
  --danger: var(--ruby);

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;

  --shadow: 0 18px 50px rgba(45, 26, 14, 0.08);
  --shadow-soft: 0 10px 24px rgba(45, 26, 14, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(181, 173, 128, 0.48), transparent 32rem),
    radial-gradient(circle at 92% 10%, rgba(108, 11, 37, 0.14), transparent 28rem),
    linear-gradient(145deg, var(--cream), #F6F0DB);
  font-family: "DM Sans", system-ui, sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.055;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='.9'/%3E%3C/svg%3E");
}

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

button {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(100, 101, 42, 0.25);
  outline-offset: 2px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 80px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 18px;
  color: var(--cream);
  background: linear-gradient(145deg, var(--burgundy), var(--ruby));
  box-shadow: var(--shadow-soft);
}

.brand-mark svg {
  width: 33px;
  height: 33px;
}

.brand-mark path {
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.1rem;
  line-height: 1.1;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.header-action,
.primary-button,
.secondary-button,
.danger-button {
  min-height: 42px;
  border-radius: 14px;
  padding: 0 16px;
  border: 0;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.header-action,
.primary-button {
  color: var(--cream);
  background: linear-gradient(135deg, var(--burgundy), var(--ruby));
  box-shadow: 0 10px 22px rgba(108, 11, 37, 0.16);
}

.secondary-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 253, 245, 0.7);
}

.danger-button {
  color: var(--ruby);
  border: 1px solid rgba(108, 11, 37, 0.16);
  background: rgba(108, 11, 37, 0.06);
}

.header-action:hover,
.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.main-nav {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 18px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(255, 253, 245, 0.56);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.nav-item {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.nav-item.is-active {
  color: var(--cream);
  background: var(--espresso);
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 16px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 210px;
  gap: 24px;
  padding: clamp(24px, 5vw, 48px);
  overflow: hidden;
  border-radius: var(--radius-lg);
  color: var(--cream);
  background:
    radial-gradient(circle at 80% 15%, rgba(181, 173, 128, 0.32), transparent 20rem),
    linear-gradient(135deg, var(--espresso), var(--burgundy) 52%, var(--ruby));
  box-shadow: var(--shadow);
  position: relative;
}

.hero::after {
  position: absolute;
  right: -60px;
  bottom: -150px;
  width: 360px;
  height: 360px;
  border: 1px solid rgba(253, 250, 235, 0.16);
  border-radius: 50%;
  content: "";
}

.hero h1,
.section-heading h1 {
  margin: 5px 0 8px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.hero p,
.section-heading p {
  max-width: 640px;
  margin: 0;
  line-height: 1.55;
}

.hero p {
  color: rgba(253, 250, 235, 0.72);
}

.eyebrow {
  color: var(--sage);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: max-content;
  border: 1px solid rgba(253, 250, 235, 0.22);
  border-radius: 999px;
  padding: 10px 10px 10px 18px;
  color: var(--cream);
  background: rgba(253, 250, 235, 0.1);
  cursor: pointer;
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 1;
}

.hero-button span {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--espresso);
  background: var(--sage);
  font-weight: 700;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.panel {
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 245, 0.72);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.panel-heading,
.section-heading,
.product-topline,
.house-tools,
.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading {
  margin-bottom: 16px;
}

.panel h2,
.dialog-heading h2 {
  margin: 0;
  font-size: 1.08rem;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.section-heading {
  align-items: flex-end;
  padding: 12px 2px;
}

.section-heading h1 {
  margin-bottom: 7px;
  color: var(--burgundy);
}

.section-heading p {
  color: var(--muted);
}

.text-button,
.edit-button,
.remove-button {
  border: 0;
  padding: 0;
  color: var(--ruby);
  background: transparent;
  cursor: pointer;
  font-weight: 600;
}

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

.quick-card {
  display: flex;
  min-height: 116px;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: left;
  background:
    linear-gradient(150deg, rgba(181, 173, 128, 0.15), transparent 56%),
    rgba(255, 253, 245, 0.74);
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.quick-card:hover {
  transform: translateY(-2px);
  border-color: rgba(100, 101, 42, 0.32);
  box-shadow: var(--shadow-soft);
}

.quick-name {
  font-weight: 700;
}

.quick-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.stock-pill {
  margin-top: auto;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 700;
}

.stock-high {
  color: var(--olive);
  background: rgba(100, 101, 42, 0.12);
}

.stock-mid {
  color: var(--warning);
  background: rgba(181, 173, 128, 0.22);
}

.stock-low {
  color: var(--ruby);
  background: rgba(108, 11, 37, 0.09);
}

.simple-list {
  display: grid;
}

.simple-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.simple-list-item:last-child {
  border-bottom: 0;
}

.simple-list-item small {
  color: var(--muted);
}

.house-tools {
  margin-bottom: 14px;
}

.search-field {
  flex: 1;
}

.search-field span,
.add-form label span,
.field span {
  display: block;
  margin: 0 0 6px 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.search-field input,
.add-form input,
.field input,
.field select,
.field textarea,
.note-area {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 253, 245, 0.82);
}

.search-field input,
.add-form input,
.field input,
.field select {
  min-height: 46px;
}

.field textarea,
.note-area {
  min-height: 116px;
  resize: vertical;
}

.tab-row,
.folder-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-row {
  margin-bottom: 9px;
}

.folder-row {
  margin-bottom: 18px;
}

.filter-chip,
.folder-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--muted);
  background: rgba(255, 253, 245, 0.66);
  cursor: pointer;
}

.filter-chip.is-active {
  color: var(--cream);
  border-color: transparent;
  background: var(--olive);
}

.folder-chip.is-active {
  color: var(--burgundy);
  border-color: rgba(108, 11, 37, 0.18);
  background: rgba(108, 11, 37, 0.07);
}

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

.product-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 245, 0.7);
}

.product-image {
  display: grid;
  width: 92px;
  height: 112px;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  color: var(--cream);
  background: linear-gradient(145deg, var(--olive), var(--sage));
  cursor: pointer;
  font-size: 2rem;
  font-weight: 700;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-content {
  min-width: 0;
}

.product-topline {
  align-items: flex-start;
}

.product-topline h3 {
  margin: 0;
  font-size: 1rem;
}

.product-topline p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.edit-button {
  font-size: 0.78rem;
}

.stock-picker {
  display: flex;
  gap: 5px;
  margin: 13px 0 9px;
}

.stock-picker button {
  flex: 1;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(255, 253, 245, 0.76);
  cursor: pointer;
  font-size: 0.72rem;
}

.stock-picker .is-active {
  border-color: transparent;
  font-weight: 700;
}

.stock-picker .is-active.stock-high {
  color: var(--cream);
  background: var(--olive);
}

.stock-picker .is-active.stock-mid {
  color: var(--espresso);
  background: var(--sage);
}

.stock-picker .is-active.stock-low {
  color: var(--cream);
  background: var(--ruby);
}

.add-shopping-button {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(70, 19, 18, 0.12);
  border-radius: 10px;
  color: var(--burgundy);
  background: rgba(70, 19, 18, 0.05);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
}

.add-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
}

.add-form label {
  flex: 1;
}

.shopping-list,
.weekly-list {
  display: grid;
}

.shopping-item,
.weekly-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
}

.shopping-item:last-child,
.weekly-item:last-child {
  border-bottom: 0;
}

.shopping-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--olive);
}

.shopping-item > span {
  flex: 1;
  min-width: 0;
}

.shopping-item strong,
.shopping-item small {
  display: block;
}

.shopping-item small {
  margin-top: 3px;
  color: var(--muted);
}

.shopping-item em {
  color: var(--muted);
  font-size: 0.75rem;
  font-style: normal;
}

.weekly-item {
  justify-content: space-between;
}

.weekly-item > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.remove-button {
  font-size: 1.2rem;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 24px 12px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed rgba(45, 26, 14, 0.16);
  border-radius: var(--radius-md);
}

.product-dialog {
  width: min(650px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: var(--radius-lg);
  color: var(--ink);
  background: transparent;
}

.product-dialog::backdrop {
  background: rgba(45, 26, 14, 0.46);
  backdrop-filter: blur(5px);
}

.dialog-card {
  max-height: calc(100vh - 32px);
  padding: 22px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at top right, rgba(181, 173, 128, 0.26), transparent 22rem),
    var(--cream);
  box-shadow: 0 32px 80px rgba(45, 26, 14, 0.28);
}

.dialog-heading {
  margin-bottom: 18px;
}

.dialog-close {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 245, 0.72);
  cursor: pointer;
  font-size: 1.5rem;
}

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

.field-wide {
  grid-column: 1 / -1;
}

.image-preview:empty {
  display: none;
}

.image-preview {
  width: 110px;
  height: 110px;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.form-message {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--ruby);
  font-size: 0.82rem;
}

.dialog-actions {
  margin-top: 14px;
}

.dialog-spacer {
  flex: 1;
}

.is-hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1000;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 999px;
  color: var(--cream);
  background: var(--espresso);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

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

@media (max-width: 900px) {
  .layout-two {
    grid-template-columns: 1fr;
  }

  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
    padding-bottom: 90px;
  }

  .site-header {
    margin-bottom: 12px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 15px;
  }

  .brand-mark svg {
    width: 29px;
    height: 29px;
  }

  .header-action {
    min-height: 40px;
    padding-inline: 12px;
  }

  .main-nav {
    position: fixed;
    right: 10px;
    bottom: 10px;
    left: 10px;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 0;
    border-radius: 18px;
  }

  .nav-item {
    padding: 11px 6px;
    font-size: 0.78rem;
  }

  .hero {
    min-height: 260px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 24px;
  }

  .hero-button {
    align-self: stretch;
    justify-content: space-between;
  }

  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-card {
    min-height: 105px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-heading .primary-button {
    width: 100%;
  }

  .house-tools,
  .add-form {
    align-items: stretch;
    flex-direction: column;
  }

  .product-card {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .product-image {
    width: 76px;
    height: 100px;
  }

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

  .field-wide {
    grid-column: auto;
  }

  .dialog-actions {
    flex-wrap: wrap;
  }

  .dialog-spacer {
    display: none;
  }

  .dialog-actions button {
    flex: 1;
  }
}

@media (max-width: 390px) {
  .brand small {
    display: none;
  }

  .quick-grid {
    grid-template-columns: 1fr;
  }
}
