/* ====== Page Shell ====== */
.page {
  display: none;
  flex-direction: column;
  background: var(--cream);
  min-height: 100vh;
  animation: pageFadeIn .25s ease;
}
.page.active { display: flex; }
@keyframes pageFadeIn { from { opacity: .6; } to { opacity: 1; } }

.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 60px;
  -webkit-overflow-scrolling: touch;
}
.page-scroll::-webkit-scrollbar { display: none; }

/* ====== Top Bar ====== */
.topbar {
  background: var(--navy);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 52px;
}
.tb-left { display: flex; align-items: center; gap: 8px; }
.tb-left img { height: 28px !important; border-radius: 4px !important; filter: brightness(0) invert(1); flex-shrink: 0; }
.tb-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .3px;
}
.tb-right { display: flex; align-items: center; gap: 8px; }
.tb-btn {
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.1);
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
}
.tb-btn:hover { background: rgba(255,255,255,.18); }
.tb-btn:active { transform: scale(.96); }

.tb-back {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 20px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  line-height: 1;
}
.tb-back:active { transform: scale(.9); background: rgba(255,255,255,.2); }

.tb-cart {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.tb-cart:active { transform: scale(.92); }

.cart-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #f59e0b;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
  box-shadow: 0 2px 6px rgba(239,68,68,.3);
}

/* ====== Tab Bar ====== */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--screen-max);
  background: #fff;
  border-top: .5px solid rgba(0,0,0,.06);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.04);
}
.tab-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 0 4px; cursor: pointer; border: none;
  background: none; font-family: inherit;
  transition: all .2s; position: relative;
  text-decoration: none; color: inherit;
}
.tab-item:active { transform: scale(.92); }
.tab-icon { width: 24px; height: 24px; line-height: 1; margin-bottom: 1px; display: flex; align-items: center; justify-content: center; }
.tab-icon svg { width: 22px; height: 22px; stroke: var(--gray); }
.tab-item.on .tab-icon svg { stroke: var(--navy); }
.tab-label { font-size: 10px; color: var(--gray); font-weight: 400; letter-spacing: .2px; }
.tab-item.on .tab-label { color: var(--navy); font-weight: 600; }
.tab-item.on .tab-icon { transform: translateY(-1px); }

/* Active indicator */
.tab-item.on::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2.5px;
  background: var(--gold);
  border-radius: 0 0 3px 3px;
}

/* ====== Modal Overlay ====== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(14,26,43,.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.show { opacity: 1; visibility: visible; }

.modal-content {
  background: var(--cream);
  width: 100%;
  max-width: var(--screen-max);
  border-radius: 24px 24px 0 0;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.32,.72,0,1);
  max-height: 88vh;
  overflow-y: auto;
}
.modal-overlay.show .modal-content { transform: translateY(0); }

.modal-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: .5px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  border-radius: 24px 24px 0 0;
}
.modal-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.modal-close {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.06);
  cursor: pointer; font-family: inherit;
  display: flex; align-items: center;
  justify-content: center; transition: all .2s;
}
.modal-close:hover { background: rgba(0,0,0,.12); }
.modal-close:active { transform: scale(.9); background: rgba(0,0,0,.18); }
.modal-close svg { stroke: #475569; }
.modal-body { padding: 20px; }
.modal-footer { padding: 0 20px 20px; }

/* ====== Back to Top ====== */
.back-top { position: fixed; bottom: 90px; right: 20px; width: 40px; height: 40px; border-radius: 50%; background: var(--navy); color: #fff; border: none; display: none; align-items: center; justify-content: center; cursor: pointer; z-index: 99; box-shadow: 0 2px 12px rgba(0,0,0,.15); transition: all .2s; font-size: 18px; }
.back-top.show { display: flex; }
.back-top:active { transform: scale(.9); }
