:root {
  --bg: #f5f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: rgb(42, 99, 178);
  --accent-dark: rgb(32, 78, 145);
  --danger: #b42318;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 88px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 14px 10px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.brand {
  font-size: 18px;
  font-weight: 750;
}

.cart-link {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  padding: 9px 14px;
  font-weight: 700;
}

.search-input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  padding: 0 14px;
  outline: 0;
}

.search-input:focus {
  border-color: var(--accent);
  background: #fff;
}

.first-category-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 2px;
}

.first-tabs {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.first-tabs::-webkit-scrollbar { display: none; }

.first-tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--text);
  padding: 9px 13px;
  white-space: nowrap;
  font-size: 14px;
}

.first-tab.active {
  background: var(--text);
  border-color: var(--text);
  color: white;
}

.first-menu-toggle {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--accent-dark);
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.first-menu-toggle.active {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: white;
}

.first-menu {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 0 2px;
}

.first-menu-item {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  padding: 8px 6px;
  font-size: 13px;
  line-height: 1.25;
}

.first-menu-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 800;
}

.browse-layout {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 10px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 10px 20px;
}

.second-sidebar {
  position: sticky;
  top: 126px;
  align-self: start;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  border-radius: 12px;
  background: #eef2f7;
  padding: 6px;
}

.second-tab {
  width: 100%;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #4b5563;
  padding: 12px 6px;
  font-size: 13px;
  line-height: 1.25;
}

.second-tab.active {
  background: white;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  font-weight: 750;
}

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

.product-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  min-height: 122px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.product-img {
  width: 100%;
  height: 100%;
  min-height: 122px;
  object-fit: cover;
  display: block;
  background: #edf2f7;
}

.product-body {
  min-width: 0;
  padding: 10px;
  display: grid;
  align-content: space-between;
}

.product-name {
  min-height: 40px;
  font-size: 14px;
  line-height: 1.42;
  font-weight: 650;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.price {
  color: #be123c;
  font-size: 17px;
  font-weight: 800;
}

.add-icon-btn, .primary-btn, .secondary-btn, .danger-btn {
  border: 0;
  border-radius: 10px;
  min-height: 38px;
  padding: 0 12px;
  font-weight: 750;
}

.add-icon-btn, .primary-btn {
  background: var(--accent);
  color: white;
}

.add-icon-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  min-height: 38px;
  border-radius: 50%;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
}

.secondary-btn {
  background: #e5e7eb;
  color: var(--text);
}

.danger-btn {
  background: #fee2e2;
  color: var(--danger);
}

.more-wrap, .empty-state {
  padding: 18px 0 6px;
  text-align: center;
  color: var(--muted);
}

.more-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  padding: 11px 22px;
  color: var(--text);
  font-weight: 750;
}

.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 14px;
}

.cart-page {
  padding-bottom: 250px;
}

.home-hero {
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 14px 12px;
}

.home-title {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 850;
}

.home-subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.home-search {
  margin-top: 14px;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

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

.page-title {
  font-size: 22px;
  font-weight: 800;
  margin: 8px 0 14px;
}

.cart-item, .summary-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.cart-img {
  width: 76px;
  height: 76px;
  border-radius: 6px;
  object-fit: cover;
  background: #edf2f7;
}

.cart-name {
  font-size: 14px;
  line-height: 1.4;
  font-weight: 700;
}

.cart-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

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

.qty-controls button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.cart-footer, .summary-total {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.cart-checkout-card {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: calc(64px + env(safe-area-inset-bottom));
  z-index: 45;
  width: min(calc(100vw - 28px), 792px);
  transform: translateX(-50%);
}

.total-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-weight: 800;
}

.service-fee-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.fee-help {
  width: 17px;
  height: 17px;
  min-height: 17px;
  border: 1px solid #94a3b8;
  border-radius: 50%;
  background: #f8fafc;
  color: #475569;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
}

.fee-tip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 8;
  width: max-content;
  max-width: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17202a;
  color: white;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.fee-tip::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 100%;
  border: 6px solid transparent;
  border-top-color: #17202a;
}

.service-fee-label:hover .fee-tip,
.service-fee-label:focus-within .fee-tip,
.service-fee-label.tip-open .fee-tip {
  opacity: 1;
  transform: translateY(0);
}

.grand-total {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: #be123c;
  font-size: 18px;
}

.footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wide-btn {
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.46);
}

.modal-panel {
  width: min(100%, 440px);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
  padding: 16px;
}

.announcement-panel {
  text-align: center;
}

.modal-title {
  font-size: 21px;
  font-weight: 850;
  margin-bottom: 12px;
}

.announcement-img {
  display: block;
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px 0;
  background: #f8fafc;
}

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

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.form-grid input, .form-grid select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text);
  background: #f8fafc;
  outline: 0;
}

.form-grid input:focus, .form-grid select:focus {
  border-color: var(--accent);
  background: white;
}

.notice {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 12px;
  color: #064e3b;
  line-height: 1.55;
  margin-bottom: 12px;
}

.summary-contact-card {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 16px;
  cursor: pointer;
}

.summary-contact-card:active {
  transform: scale(0.995);
}

.warning {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #7c2d12;
}

.summary-header {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.summary-title {
  font-size: 22px;
  font-weight: 850;
  margin-bottom: 8px;
}

.summary-kv {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.06);
}

.bottom-nav-item {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  font-size: 11px;
}

.bottom-nav-item.active {
  color: var(--accent);
  font-weight: 800;
}

.bottom-nav-icon {
  font-size: 20px;
  line-height: 1;
}

.nav-badge {
  position: absolute;
  top: 7px;
  right: calc(50% - 23px);
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: #be123c;
  color: white;
  font-size: 10px;
  line-height: 17px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 70;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  border-radius: 999px;
  background: rgba(23, 32, 42, 0.92);
  color: white;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 750;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.18);
  pointer-events: none;
}

.admin-page {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

.admin-login {
  max-width: 420px;
  margin: 10vh auto 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.admin-actions {
  display: flex;
  gap: 8px;
}

.admin-filter {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.filter-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  font-weight: 750;
}

.filter-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: white;
}

.admin-order {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.admin-order-card {
  cursor: pointer;
}

.admin-order-card:active {
  transform: scale(0.995);
}

.admin-order-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.admin-detail {
  display: grid;
  gap: 12px;
}

.compact-title {
  margin: 4px 0 0;
  font-size: 18px;
}

.admin-product-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.admin-product-img {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  background: #edf2f7;
}

.admin-status-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.admin-status-row label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 750;
}

.admin-status-row input {
  width: 16px;
  height: 16px;
}

@media (min-width: 760px) {
  .browse-layout {
    grid-template-columns: 140px minmax(0, 1fr);
  }

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

  .product-img {
    min-height: 132px;
  }
}

@media (max-width: 420px) {
  .address-grid {
    grid-template-columns: 1fr;
  }

  .admin-status-row {
    grid-template-columns: 1fr;
  }

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

@media (min-width: 1040px) {
  .product-list {
    max-width: 720px;
  }
}
