:root {
  --ink: #14231c;
  --ink-soft: #3d5248;
  --paper: #f3f0e8;
  --paper-deep: #e7e2d4;
  --accent: #0f6b4c;
  --accent-hover: #0b543b;
  --danger: #a33b2d;
  --line: rgba(20, 35, 28, 0.12);
  --shadow: 0 18px 50px rgba(20, 35, 28, 0.12);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(15, 107, 76, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(163, 120, 45, 0.12), transparent 50%),
    linear-gradient(165deg, #f7f4ec 0%, var(--paper) 45%, #ebe6da 100%);
  line-height: 1.5;
}

a {
  color: var(--accent);
}

.shell {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3.5rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.75rem, 4vw, 2.4rem);
  letter-spacing: -0.02em;
  margin: 0;
}

.brand-sub {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.panel {
  margin-top: 1.75rem;
  background: rgba(255, 252, 245, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 1.5rem;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.stack {
  display: grid;
  gap: 0.9rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input[type="email"],
input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  font: inherit;
  color: var(--ink);
  background: #fffdf8;
}

input:focus {
  outline: 2px solid rgba(15, 107, 76, 0.35);
  border-color: var(--accent);
}

.btn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #f7fff9;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.btn-apple {
  background: #111;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.btn-apple:hover:not(:disabled) {
  background: #000;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.error {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: rgba(163, 59, 45, 0.1);
  color: var(--danger);
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.stat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 1.25rem;
}

.stat {
  padding: 1.15rem 1.2rem;
  border-radius: 16px;
  background: linear-gradient(160deg, #fffef9, var(--paper-deep));
  border: 1px solid var(--line);
}

.stat .label {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat .value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  margin: 0.25rem 0 0;
  letter-spacing: -0.03em;
}

.stat .detail {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.category-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.category-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.category-list li:last-child {
  border-bottom: none;
}

.category-list .cnt {
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-weight: 650;
}

.total-line {
  margin: 1rem 0 0;
  font-weight: 750;
}

.loading {
  color: var(--ink-soft);
}

.app-nav {
  display: flex;
  gap: 0.4rem;
  margin-top: 1.25rem;
  padding: 0.3rem;
  border-radius: 14px;
  background: rgba(255, 252, 245, 0.7);
  border: 1px solid var(--line);
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
}

.app-nav-link {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
}

.app-nav-link:hover {
  color: var(--ink);
  background: rgba(15, 107, 76, 0.08);
}

.app-nav-link.is-active {
  color: #f7fff9;
  background: var(--accent);
}

.products-toolbar {
  margin-top: 1.25rem;
  padding-bottom: 1rem;
}

.toolbar-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.search-field {
  display: block;
  width: 100%;
  margin: 0;
}

.search-field input[type="search"],
.search-field input {
  display: block;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  font: inherit;
  font-size: 16px; /* avoids iOS Safari zoom-on-focus */
  color: var(--ink);
  background: #fffdf8;
  -webkit-appearance: none;
  appearance: none;
}

.search-field input:focus {
  outline: 2px solid rgba(15, 107, 76, 0.35);
  border-color: var(--accent);
}

#ack-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}

#ack-all[hidden] {
  display: none !important;
}

.usage-line {
  margin: 0.75rem 0 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.product-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.product-card {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) minmax(5.5rem, auto);
  grid-template-areas:
    "thumb main price"
    "thumb main remove";
  gap: 0.5rem 0.85rem;
  align-items: start;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(255, 252, 245, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(20, 35, 28, 0.06);
  cursor: pointer;
}

.product-card:focus {
  outline: 2px solid rgba(15, 107, 76, 0.45);
  outline-offset: 2px;
}

.product-card.is-unseen {
  background: rgba(230, 190, 40, 0.18);
  border-color: rgba(180, 140, 20, 0.28);
}

.product-card.is-oos .product-name {
  color: var(--ink-soft);
}

.product-thumb {
  grid-area: thumb;
  width: 60px;
  height: 60px;
  object-fit: contain;
  border-radius: 10px;
  background: #f0ebe0;
  border: 1px solid var(--line);
}

.product-thumb-placeholder {
  background:
    linear-gradient(135deg, #efe9dc, #e2dccf);
}

.product-main {
  grid-area: main;
  min-width: 0;
}

.product-name {
  margin: 0;
  font-weight: 650;
  font-size: 0.98rem;
  line-height: 1.35;
}

.product-card.is-unseen .product-name {
  font-weight: 750;
}

.store-link {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
}

.store-link:hover {
  text-decoration: underline;
}

.price-block {
  grid-area: price;
  display: grid;
  justify-items: end;
  gap: 0.15rem;
  text-align: right;
  min-width: 5.5rem;
}

.price {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.price-drop {
  color: #0f6b4c;
}

.was-price {
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-decoration: line-through;
}

.savings {
  font-size: 0.82rem;
  font-weight: 750;
  color: var(--danger);
}

.price-block.out-of-stock .price {
  color: var(--ink-soft);
  font-size: 0.88rem;
  white-space: pre-line;
  text-align: right;
}

.btn-remove {
  grid-area: remove;
  justify-self: end;
  padding: 0.45rem 0.75rem;
  min-height: 36px;
  font-size: 0.8rem;
  font-weight: 650;
  -webkit-appearance: none;
  appearance: none;
  background: #fffdf8;
  color: var(--danger);
  border: 1px solid rgba(163, 59, 45, 0.25);
}

.btn-add {
  grid-area: remove;
  justify-self: end;
  padding: 0.45rem 0.75rem;
  min-height: 36px;
  font-size: 0.8rem;
  font-weight: 650;
  -webkit-appearance: none;
  appearance: none;
  background: #fffdf8;
  color: var(--accent);
  border: 1px solid rgba(15, 107, 76, 0.28);
}

.btn-add:disabled {
  opacity: 0.65;
  color: var(--ink-soft);
}

.product-meta {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
}

.catalogue-toolbar {
  margin-top: 1.25rem;
}

.catalogue-form {
  display: grid;
  gap: 0.85rem;
}

.char-hint {
  margin: -0.35rem 0 0;
  font-size: 0.82rem;
}

.catalogue-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.filter-field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink-soft);
  margin: 0;
}

.filter-field input,
.filter-field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fffdf8;
  -webkit-appearance: none;
  appearance: none;
}

.filter-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--ink-soft);
}

.remember-check {
  margin-top: 0.15rem;
}

.remember-hint {
  margin: -0.35rem 0 0;
  font-size: 0.82rem;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin: 1rem 0 0;
  align-items: center;
}

.auth-links a {
  font-weight: 650;
  text-decoration: none;
}

.auth-links a:hover {
  text-decoration: underline;
}

.suggestions {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  overflow: hidden;
}

.suggestion-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 0.75rem 0.9rem;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}

.suggestion-item:hover {
  background: rgba(15, 107, 76, 0.08);
}

.suggestions li:last-child .suggestion-item {
  border-bottom: none;
}

.load-more-wrap {
  margin-top: 1rem;
  display: grid;
  gap: 0.5rem;
  justify-items: center;
}

.load-more-wrap .btn {
  min-width: 160px;
  min-height: 44px;
}

.toast {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: rgba(15, 107, 76, 0.12);
  color: var(--accent-hover);
  font-size: 0.9rem;
  font-weight: 650;
}

.back-row {
  margin: 1rem 0 0;
}

.back-link {
  font-weight: 700;
  text-decoration: none;
  color: var(--ink-soft);
}

.back-link:hover {
  color: var(--accent);
}

.detail {
  display: grid;
  gap: 1rem;
  margin-top: 0.75rem;
}

.detail .panel {
  margin-top: 0;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.detail-image {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 14px;
  background: #f0ebe0;
  border: 1px solid var(--line);
}

.detail-image-placeholder {
  background: linear-gradient(135deg, #efe9dc, #e2dccf);
}

.detail-title {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.detail-desc {
  margin: 0.65rem 0 0;
  white-space: pre-wrap;
}

.detail-prices {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.2rem;
}

.detail-price {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.detail-actions .btn,
.detail-actions .store-cta {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.history-list,
.similar-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.similar-card {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffdf8;
}

.similar-card.is-selected {
  border-color: rgba(15, 107, 76, 0.45);
  background: rgba(15, 107, 76, 0.08);
}

.similar-top {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.similar-name-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  font-weight: 650;
  color: var(--accent);
  cursor: pointer;
  line-height: 1.35;
}

.similar-name-btn:hover {
  text-decoration: underline;
}

.similar-card.is-selected .similar-name-btn {
  font-weight: 750;
  color: var(--ink);
}

.similar-open {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  border-radius: 10px;
  border: 1px solid rgba(15, 107, 76, 0.22);
  background: #fff;
}

.similar-open:hover {
  background: rgba(15, 107, 76, 0.08);
}

.similar-open.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.similar-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.4rem;
  font-size: 0.92rem;
}

.compare-dialog {
  width: min(640px, calc(100% - 1.5rem));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.1rem 1.2rem;
  background: #fffdf8;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.compare-dialog::backdrop {
  background: rgba(20, 35, 28, 0.45);
}

.compare-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
}

.compare-dialog-header .section-title {
  margin: 0;
}

.compare-close {
  min-height: 40px;
}

.compare-chart-wrap {
  height: 280px;
}

.chart-legend {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
}

.history-price,
.similar-price {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history-when {
  color: var(--ink-soft);
  text-align: right;
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 1.25rem, 920px);
    padding-top: 1.5rem;
  }

  .panel {
    padding: 1.15rem;
  }

  .product-card {
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-areas:
      "thumb main"
      "thumb price"
      "remove remove";
  }

  .price-block {
    justify-items: start;
    text-align: left;
  }

  .btn-remove,
  .btn-add {
    justify-self: start;
  }

  .product-thumb {
    width: 52px;
    height: 52px;
  }

  .detail-hero {
    grid-template-columns: 1fr;
  }

  .detail-image {
    max-width: 220px;
  }
}
