:root {
  --bg: #f0f4f2;
  --bg-elevated: #ffffff;
  --text: #14201a;
  --muted: #5a6b63;
  --accent: #0d6e4f;
  --accent-hover: #0a5a40;
  --accent-soft: #e3f3ec;
  --border: #d5e0da;
  --danger: #b42318;
  --shadow: 0 8px 28px rgba(20, 32, 26, 0.08);
  --radius: 14px;
  --header-h: 56px;
  --nav-h: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

a {
  color: var(--accent);
}

img {
  max-width: 100%;
  display: block;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--header-h);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}

.site-logo__mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #0d6e4f, #15966b);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.site-logo__text {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-header__actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 0.85rem;
  position: relative;
}

.header-btn__icon {
  font-size: 1.05rem;
  line-height: 1;
}

.header-btn__label {
  display: none;
}

@media (min-width: 640px) {
  .header-btn__label {
    display: inline;
  }
}

.cart-pill {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Main */
.page-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: calc(1.5rem + var(--nav-h) + var(--safe-bottom));
}

@media (min-width: 900px) {
  .page-main {
    padding-bottom: 2rem;
  }

  .mobile-nav {
    display: none;
  }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

@media (min-width: 900px) {
  .site-footer {
    margin-bottom: 0;
  }
}

.site-footer__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  font-size: 0.9rem;
}

.site-footer__name {
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.site-footer__line {
  margin: 0.2rem 0;
}

/* Mobile nav */
.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.mobile-nav__item {
  flex: 1 1 0;
  min-width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.45rem 0.35rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.68rem;
  position: relative;
}

.mobile-nav__item.is-active {
  color: var(--accent);
}

.mobile-nav__icon {
  font-size: 1.2rem;
  line-height: 1;
}

.mobile-nav__badge {
  position: absolute;
  top: 4px;
  left: 55%;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Typography & layout */
.page-title {
  margin: 0 0 1rem;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-lead {
  margin: -0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
}

/* Hero */
.store-hero {
  background: linear-gradient(135deg, #0b3d2e 0%, #0d6e4f 55%, #15966b 100%);
  color: #fff;
  border-radius: calc(var(--radius) + 4px);
  padding: 1.25rem 1.25rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.store-hero__title {
  margin: 0;
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: 800;
}

.store-hero__meta {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  opacity: 0.92;
}

.store-hero__meta a {
  color: #fff;
  text-decoration: underline;
}

/* Search */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  background: var(--bg-elevated);
}

.search-bar input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1.1rem;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--accent);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--accent-soft);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.4rem 0.65rem;
  font-size: 0.875rem;
  border-radius: 10px;
}

/* Cards */
.card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(20, 32, 26, 0.04);
}

.card--flat {
  box-shadow: none;
}

/* Product grid */
.catalog-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 560px) {
  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  }
}

.product-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  text-decoration: none;
  color: inherit;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.product-card__media {
  aspect-ratio: 1;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.product-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card__placeholder {
  font-size: 2rem;
  opacity: 0.35;
}

.product-card__body {
  padding: 0.65rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.25rem;
}

.product-card__name {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card__price {
  font-weight: 800;
  color: var(--accent);
  font-size: 1rem;
  margin-top: auto;
}

.product-card__stock {
  font-size: 0.75rem;
  color: var(--muted);
}

.stock-ok {
  color: #1a7f4b;
}

.stock-low {
  color: #b45309;
}

/* Product page */
.product-page {
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .product-page {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.product-gallery {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.product-gallery img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-detail h1 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  line-height: 1.25;
}

.product-detail__price {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.qty-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
}

.qty-row__ctrl {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-elevated);
}

.qty-row__btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--accent);
}

.qty-row__val {
  min-width: 36px;
  text-align: center;
  font-weight: 700;
}

/* Cart */
.cart-line {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.cart-line__thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
}

.cart-line__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-line__title {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 0.25rem;
}

.cart-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1rem 0 0.5rem;
  font-size: 1.1rem;
}

.cart-summary strong {
  font-size: 1.35rem;
  color: var(--accent);
}

/* Forms */
.form label {
  display: block;
  margin: 0.85rem 0 0.3rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.form input,
.form textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg);
}

.form input:focus,
.form textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--muted);
}

.back-link:hover {
  color: var(--accent);
}

.load-more-wrap {
  text-align: center;
  margin: 1.25rem 0;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
}

.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.success-card {
  text-align: center;
  padding: 1.5rem 1rem;
}

.success-card__icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.skeleton {
  background: linear-gradient(90deg, #e8eeeb 25%, #f5f8f6 50%, #e8eeeb 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius);
  min-height: 200px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
