:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --text: #1f2733;
  --muted: #7b8797;
  --line: #dfe7f1;
  --accent: #eb6578;
  --accent-2: #0f72d6;
  --shadow: 0 14px 32px rgba(42, 88, 140, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #eef3f9, #f8fbff);
  color: var(--text);
  overflow-x: hidden;
}

.store-shell {
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  padding-bottom: 88px;
  overflow-x: hidden;
}

.store-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(223, 231, 241, 0.9);
  padding: 14px 16px 12px;
  display: grid;
  gap: 12px;
}

.store-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.store-brand strong {
  font-size: 22px;
  line-height: 1.05;
}

.store-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}

.store-view {
  width: min(100%, 1200px);
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.hero-banner {
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(135deg, #f5f8fd, #ddecff);
  box-shadow: var(--shadow);
}

.hero-banner-inner {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
  align-items: center;
  padding: 18px;
}

.hero-banner h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.hero-banner p {
  margin: 0;
  color: #516274;
  line-height: 1.5;
}

.hero-banner img {
  width: 100%;
  border-radius: 20px;
  object-fit: cover;
  min-height: 160px;
}

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

.category-card,
.product-card,
.cart-card,
.profile-card,
.related-card,
.order-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(223, 231, 241, 0.92);
  box-shadow: var(--shadow);
}

.category-card {
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.category-card-wide {
  min-width: 0;
}

.category-card img {
  width: 100%;
  height: 154px;
  object-fit: cover;
  display: block;
  background: #f0f5fb;
}

.category-card-body {
  padding: 12px;
  text-align: center;
  font-weight: 700;
  min-height: 68px;
  display: grid;
  place-items: center;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
}

.section-head .muted {
  font-size: 13px;
}

.product-list {
  display: grid;
  gap: 12px;
}

.orders-list {
  display: grid;
  gap: 12px;
}

.order-detail {
  display: grid;
  gap: 14px;
}

.product-card {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 12px;
  padding: 10px;
}

.product-card img {
  width: 148px;
  height: 148px;
  border-radius: 14px;
  object-fit: cover;
  background: #f0f5fb;
}

.product-card-body {
  display: grid;
  gap: 8px;
  align-content: start;
}

.product-title {
  font-weight: 800;
  font-size: 17px;
  line-height: 1.25;
}

.product-desc {
  color: #5d6e81;
  font-size: 14px;
  line-height: 1.45;
}

.price-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.icon-btn {
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(42, 88, 140, 0.08);
  min-width: 44px;
  min-height: 44px;
}

.product-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 100vw;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(223,231,241,0.95);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 6px 10px;
  z-index: 30;
}

.nav-tab {
  border: 0;
  background: transparent;
  display: grid;
  gap: 4px;
  justify-items: center;
  color: #5b6c80;
  font-size: 11px;
  font-weight: 700;
}

.nav-tab.active {
  color: var(--text);
}

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

.detail-sheet,
.cart-sheet,
.profile-sheet {
  position: fixed;
  inset: 0;
  background: rgba(18, 29, 44, 0.28);
  z-index: 40;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
}

.detail-sheet.open,
.cart-sheet.open,
.profile-sheet.open {
  display: flex;
}

.sheet-card {
  width: min(calc(100vw - 20px), 920px);
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 20px);
  overflow: auto;
  overflow-x: hidden;
  background: #fff;
  border-radius: 26px 26px 18px 18px;
  box-shadow: 0 30px 50px rgba(22, 43, 69, 0.24);
  min-width: 0;
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.sheet-content {
  padding: 16px;
  display: grid;
  gap: 16px;
  min-width: 0;
  overflow-x: hidden;
}

.detail-image {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: min(44vh, 420px);
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  object-fit: contain;
  background: #f0f5fb;
  display: block;
}

#detail_name,
#detail_description,
.related-card-title {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 800;
  max-width: 100%;
}

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

.secondary-btn {
  background: #edf4fb;
  color: #275584;
}

.related-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(140px, 170px);
  gap: 12px;
  overflow: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  min-width: 0;
}

.related-card {
  padding: 10px;
  scroll-snap-align: start;
  min-width: 0;
  max-width: 170px;
}

.related-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  object-fit: cover;
  background: #f0f5fb;
}

.related-card-title {
  font-size: 14px;
  margin: 8px 0 10px;
  min-height: 36px;
}

.cart-list {
  display: grid;
  gap: 12px;
}

.cart-card {
  padding: 12px;
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 12px;
  align-items: center;
}

.cart-card img {
  width: 88px;
  height: 88px;
  border-radius: 14px;
  object-fit: cover;
  background: #f0f5fb;
}

.qty-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.qty-row button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.cart-summary {
  padding: 16px;
  border-radius: 18px;
  background: #f7fbff;
  border: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.checkout-note {
  font-size: 13px;
  line-height: 1.45;
  color: #58708c;
}

.order-card {
  padding: 14px;
  display: grid;
  gap: 10px;
  cursor: pointer;
}

.order-card-head,
.order-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.order-card-meta {
  color: #67809b;
  font-size: 13px;
}

.order-card-total {
  font-size: 20px;
  font-weight: 800;
  color: #163a63;
}

.order-card-items {
  display: grid;
  gap: 6px;
  color: #44566c;
  font-size: 14px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-new_order { background: #eef6ff; color: #1763b1; }
.status-awaiting_confirmation { background: #eefbff; color: #1480a8; }
.status-confirmed { background: #eefcf3; color: #20804d; }
.status-processing { background: #fff7eb; color: #aa6511; }
.status-invoiced { background: #fff3f3; color: #c84f5b; }
.status-paid { background: #eefcf3; color: #1d8e55; }
.status-deliveries_planned { background: #eef6ff; color: #245ea8; }
.status-in_delivery { background: #f3f1ff; color: #5a52b4; }
.status-completed { background: #eefcf3; color: #1b7f53; }
.status-cancelled { background: #fff1f1; color: #c84545; }
.status-created,
.status-draft { background: #f4f7fb; color: #607188; }

.order-detail-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.order-detail-card {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.order-lines {
  display: grid;
  gap: 10px;
}

.order-line,
.timeline-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.timeline-row {
  padding: 10px 0;
  border-bottom: 1px solid rgba(223, 231, 241, 0.8);
  font-size: 14px;
}

.timeline-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.document-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
  color: #16416d;
  font-size: 14px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}

.muted { color: var(--muted); }

.secondary-btn-small {
  padding: 10px 12px;
  font-size: 14px;
}

@media (max-width: 380px) {
  .sheet-head,
  .sheet-content {
    padding-left: 12px;
    padding-right: 12px;
  }
  .detail-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .detail-actions .price-pill,
  .detail-actions .primary-btn,
  .secondary-btn {
    width: 100%;
    justify-content: center;
  }
  .hero-banner-inner {
    grid-template-columns: 1fr;
  }
  .product-card {
    grid-template-columns: 98px 1fr;
  }
  .product-card img {
    width: 98px;
    height: 98px;
  }
  .order-detail-summary {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 700px) {
  .store-view {
    padding: 20px 24px 24px;
    gap: 18px;
  }
  .hero-banner-inner {
    grid-template-columns: 1.2fr 0.8fr;
  }
  .category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .product-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .related-grid {
    grid-auto-columns: minmax(160px, 1fr);
  }
  .sheet-card {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    border-radius: 30px;
  }
}

@media (min-width: 1024px) {
  .product-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .category-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .product-card {
    grid-template-columns: 176px 1fr;
  }
  .product-card img {
    width: 176px;
    height: 176px;
  }
  .detail-image {
    max-height: min(58vh, 520px);
  }
}
