:root {
  --bg: #f6f4ee;
  --paper: #fffefa;
  --paper-strong: #ffffff;
  --line: #ddd8cb;
  --text: #22251f;
  --muted: #70746c;
  --olive: #56654d;
  --olive-dark: #354332;
  --gold: #ad9868;
  --clay: #7f6757;
  --soft: #ebe8df;
  --shadow: 0 10px 28px rgba(49, 54, 43, 0.055);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 56px);
  background: rgba(246, 244, 238, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(44, 49, 40, 0.42);
}

.auth-card {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(100%, 380px);
  padding: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 30px;
  line-height: 1;
}

.auth-close:hover {
  color: var(--olive-dark);
}

.auth-card h2 { margin: 0; }
.auth-logo { width: 76px; height: 76px; object-fit: contain; justify-self: center; }

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 38px);
  letter-spacing: 0;
}

h2 {
  font-size: clamp(25px, 3.4vw, 46px);
  line-height: 1.12;
  letter-spacing: 0;
}

h3 {
  font-size: 18px;
}

.eyebrow {
  color: var(--olive);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 6px;
}

.mode-tabs,
.admin-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.mode-tab,
.admin-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  min-height: 42px;
}

.mode-tab.is-active,
.admin-tab.is-active {
  background: var(--paper-strong);
  color: var(--olive-dark);
  box-shadow: 0 3px 10px rgba(54, 64, 47, 0.055);
}

.account-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.account-button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--olive-dark);
  font-weight: 700;
}

main {
  padding: 34px clamp(18px, 4vw, 56px) 56px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.shop-hero {
  display: block;
  padding: clamp(16px, 2.5vw, 30px) 0 24px;
}

.hero-copy {
  max-width: 650px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
}

.hero-stat {
  display: grid;
  place-items: center;
  min-height: 150px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-stat span {
  color: var(--olive-dark);
  font-size: 48px;
  font-weight: 800;
}

.hero-stat small {
  color: var(--muted);
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1.45fr) 0.75fr minmax(220px, 1.35fr);
  gap: 14px;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.place-filter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lookup-panel {
  display: grid;
  grid-template-columns: auto minmax(320px, 1fr);
  gap: 14px 22px;
  align-items: end;
  margin-top: 14px;
  padding: 16px 18px;
  background: rgba(255, 254, 250, 0.72);
  border: 1px solid var(--line);
}

.lookup-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 1fr) auto;
  gap: 10px;
}

.lookup-form button {
  border: 0;
  background: var(--olive-dark);
  color: white;
  padding: 0 16px;
  font-weight: 800;
}

.lookup-results {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper-strong);
  color: var(--text);
  padding: 12px 13px;
  outline: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(79, 103, 74, 0.13);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 46px;
}

.compact-form .password-toggle,
.password-toggle {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 20px;
  min-height: 12px;
  height: 12px;
  padding: 0;
  transform: translateY(-50%);
  border: 1.5px solid #a8aaa5;
  border-radius: 50% / 62%;
  background: transparent;
}

.password-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #a8aaa5;
}

.password-toggle.is-visible::before {
  content: "";
  position: absolute;
  top: 5px;
  left: -2px;
  width: 22px;
  border-top: 1.5px solid #8d908a;
  transform: rotate(-35deg);
}

.shop-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  margin-top: 26px;
  align-items: start;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading span {
  color: var(--muted);
  font-size: 14px;
}

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

.product-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 16px;
  min-height: 176px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.product-photo,
.mini-photo,
.image-preview {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0)),
    var(--photo-bg, linear-gradient(135deg, #d8c59d, #7a8d68));
  background-size: cover;
  background-position: center;
}

.product-photo {
  min-height: 148px;
}

.product-card h3 {
  margin-bottom: 7px;
}

.product-card p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.meta-line,
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  background: #f0ede4;
  color: var(--olive-dark);
  font-size: 13px;
  font-weight: 700;
}

.price {
  color: var(--olive-dark);
  font-size: 20px;
  font-weight: 800;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.select-button,
.primary-button,
.compact-form button {
  border: 0;
  background: var(--olive-dark);
  color: white;
  min-height: 44px;
  padding: 11px 16px;
  font-weight: 800;
}

.secondary-button {
  border: 1px solid var(--olive-dark);
  background: transparent;
  color: var(--olive-dark);
  min-height: 42px;
  padding: 10px 14px;
  justify-self: start;
}

.select-button {
  min-height: 38px;
  padding: 8px 12px;
}

.order-panel,
.form-panel,
.uploader-orders,
.phone-admin,
.admin-context {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.report-workspace {
  align-self: stretch;
  padding: 34px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.order-workspace,
.member-workspace {
  align-self: stretch;
  padding: 34px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.order-workspace h2,
.member-workspace h2 {
  margin-top: 0;
}

.order-search-field {
  width: min(680px, 100%);
  margin: 22px 0;
}

.report-workspace h2 {
  margin-top: 0;
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 980px;
  margin: 22px 0;
}

.report-period {
  display: flex;
  align-items: end;
  gap: 16px;
}

.report-period > label {
  width: min(240px, 100%);
}

.report-custom-range {
  display: flex;
  gap: 10px;
}

.report-custom-range label {
  min-width: 160px;
}

.order-panel {
  position: sticky;
  top: 120px;
  max-height: calc(100vh - 138px);
  overflow-y: auto;
  padding: 16px;
  scroll-margin-top: 88px;
}

.order-panel .stack {
  gap: 10px;
  margin-top: 12px;
}

.order-panel .stack label {
  gap: 5px;
}

.order-panel .stack input,
.order-panel .stack select,
.order-panel .stack textarea {
  padding: 9px 10px;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

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

.location-pair label {
  min-width: 0;
}

.delivery-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

.delivery-toggle input {
  width: auto;
}

.remote-delivery-fields {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: #f0ede4;
  border-left: 3px solid var(--gold);
}

.choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 12px;
  max-height: 178px;
  overflow: auto;
  padding: 10px;
  background: white;
  border: 1px solid var(--line);
}

.country-choice-list {
  grid-template-columns: 1fr;
}

.choice-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
}

.choice-option input {
  width: auto;
  flex: 0 0 auto;
}

.choice-all {
  position: sticky;
  top: -10px;
  z-index: 1;
  padding: 5px 0;
  background: white;
  color: var(--olive-dark);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}

.muted,
.fineprint {
  color: var(--muted);
  line-height: 1.6;
}

.fineprint {
  font-size: 13px;
}

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

.selected-item {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 12px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.selected-item span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.pickup-info {
  display: grid;
  gap: 6px;
  padding: 13px;
  background: #f0ede4;
  border-left: 3px solid var(--gold);
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.pickup-info strong {
  color: var(--olive-dark);
}

.pickup-info span {
  display: block;
}

.mini-photo {
  width: 62px;
  height: 62px;
}

.page-intro {
  margin-bottom: 24px;
}

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

.form-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.uploader-orders {
  margin-top: 24px;
  padding: 22px;
}

.uploader-history-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.uploader-history-heading h3 {
  margin: 0;
}

.uploader-history-heading .order-search-field {
  margin: 0;
}

.image-preview {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  color: rgba(255, 255, 255, 0.9);
  background-color: #7f8a70;
  text-align: center;
  padding: 18px;
  overflow: hidden;
}

.admin-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.phone-admin {
  max-width: 420px;
  min-height: 720px;
  padding: 18px;
}

.phone-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.phone-top h2 {
  font-size: 28px;
}

#pendingBadge {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--olive-dark);
  color: white;
}

.admin-page {
  display: none;
  margin-top: 16px;
}

.admin-page.is-active {
  display: block;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-row {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.admin-row strong {
  display: block;
}

.admin-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-top: 3px;
}

.deal-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
  align-items: end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.deal-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.deal-form input,
.deal-form select {
  min-width: 0;
}

.deal-form button {
  min-height: 38px;
}

.compact-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 16px;
}

.member-search {
  margin: 0 0 12px;
}

.member-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.member-actions button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--paper-strong);
  color: var(--olive-dark);
}

.member-actions .danger-button {
  color: #9b3f2c;
}

.compact-form select,
.compact-form input + input {
  grid-column: 1 / -1;
}

.settings-groups {
  display: grid;
  gap: 22px;
}

.settings-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 14px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.admin-context {
  padding: clamp(24px, 4vw, 44px);
}

.admin-context p {
  max-width: 680px;
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.8;
}

.context-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 34px;
}

.context-grid div {
  padding: 18px 0;
  border-top: 2px solid var(--gold);
}

.context-grid strong,
.context-grid span {
  display: block;
}

.context-grid span {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 340px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: var(--olive-dark);
  color: white;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1050px) {
  .shop-layout,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .order-panel {
    position: static;
    padding: 16px;
  }

  .order-panel .stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
  }

  .order-panel .stack > .selected-item,
  .order-panel .stack > #addressField,
  .order-panel .stack > .location-pair,
  .order-panel .stack > .pickup-info,
  .order-panel .stack > #shippingInfo,
  .order-panel .stack > button,
  .order-panel .stack > .fineprint {
    grid-column: 1 / -1;
  }

  .order-panel .stack label {
    gap: 5px;
  }

  .order-panel .stack input,
  .order-panel .stack select,
  .order-panel .stack textarea {
    padding: 9px 10px;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .deal-form {
    grid-template-columns: 1fr;
  }

  .location-pair {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-tabs {
    overflow-x: auto;
  }

  .account-tools {
    justify-content: space-between;
  }

  main {
    padding-top: 20px;
  }

  .shop-hero,
  .filters,
  .lookup-panel,
  .editor-grid,
  .context-grid {
    grid-template-columns: 1fr;
  }

  .uploader-history-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .place-filter {
    grid-template-columns: 1fr 1fr;
  }

  .lookup-form {
    grid-template-columns: 1fr;
  }

  .hero-stat {
    min-height: 110px;
  }

  .product-card {
    grid-template-columns: 1fr;
  }

.product-photo {
  position: relative;
  aspect-ratio: 4 / 3;
  }

  .phone-admin {
    min-height: auto;
  }
}

.remote-purchase-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 9px;
  background: #b14d31;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 2px 7px rgba(79, 37, 26, 0.28);
}

@media (max-width: 480px) {
  .order-panel .stack {
    grid-template-columns: 1fr;
  }
}
