:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef4ef;
  --ink: #17211c;
  --muted: #68756e;
  --line: #d9e2dc;
  --primary: #176b57;
  --primary-dark: #0e4f40;
  --accent: #ef7d55;
  --accent-soft: #ffe2d5;
  --gold: #c79b45;
  --danger: #b93838;
  --shadow: 0 22px 60px rgba(23, 33, 28, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding: 12px clamp(18px, 4vw, 56px);
  background: rgba(246, 247, 244, 0.88);
  border-bottom: 1px solid rgba(217, 226, 220, 0.78);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: var(--primary);
  border-radius: 8px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

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

.nav-link,
.cart-button,
.icon-button {
  min-height: 42px;
  padding: 9px 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.nav-link.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.cart-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cart-button strong {
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  color: #fff;
  font-size: 13px;
  background: var(--accent);
  border-radius: 999px;
}

.cart-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--primary);
  font-weight: 900;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(420px, 1.08fr);
  gap: clamp(28px, 6vw, 84px);
  align-items: center;
  min-height: calc(100vh - 76px);
  padding: clamp(44px, 7vw, 92px) clamp(18px, 5vw, 72px) 40px;
}

.hero-copy {
  max-width: 720px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 18px;
  font-size: clamp(44px, 6vw, 86px);
  line-height: 1.04;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.18;
}

h3 {
  margin-bottom: 10px;
  font-size: 20px;
}

.hero-copy p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
  font-size: 18px;
}

.hero-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.button.primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.secondary:hover,
.button.compact:hover {
  border-color: var(--primary);
}

.button.compact {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 14px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.stats span,
.kpi-grid article {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats strong {
  color: var(--primary);
}

.hero-media {
  position: relative;
}

.hero-media img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  padding: 32px clamp(18px, 5vw, 72px) 10px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 87, 0.12);
}

.search-box {
  min-width: min(280px, 100%);
}

.select-box {
  min-width: 152px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  padding: 18px clamp(18px, 5vw, 72px) 82px;
}

.product-card {
  display: flex;
  min-height: 440px;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(23, 33, 28, 0.06);
}

.product-art {
  display: grid;
  aspect-ratio: 1 / 0.78;
  place-items: center;
  color: rgba(23, 33, 28, 0.68);
  font-size: 48px;
  font-weight: 900;
  background: linear-gradient(135deg, #edf8f2, #ffd9ca);
}

.product-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
}

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

.badge {
  padding: 5px 9px;
  color: var(--primary);
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.stock {
  color: var(--muted);
  font-size: 13px;
}

.product-body p {
  color: var(--muted);
}

.price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.price {
  color: var(--primary-dark);
  font-size: 24px;
  font-weight: 900;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 36px;
  text-align: center;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 33, 28, 0.42);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  width: min(460px, 100%);
  height: 100%;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-head,
.cart-summary,
.panel-head,
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cart-items {
  display: grid;
  gap: 10px;
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.qty-control {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.qty-control button {
  width: 34px;
  border: 0;
  background: #fff;
}

.qty-control span {
  display: grid;
  min-width: 34px;
  place-items: center;
  border-inline: 1px solid var(--line);
}

.link-button {
  padding: 0;
  color: var(--danger);
  background: transparent;
  border: 0;
  font-weight: 800;
}

.cart-summary {
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 18px;
}

.cart-summary strong {
  color: var(--primary);
  font-size: 24px;
}

.checkout-form,
.login-card,
.panel {
  display: grid;
  gap: 14px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.form-message {
  min-height: 24px;
  margin: 0;
  color: var(--primary);
  font-weight: 800;
}

.admin-login {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  min-height: calc(100vh - 76px);
  padding: clamp(44px, 7vw, 92px) clamp(18px, 5vw, 72px);
}

.admin-login p:not(.eyebrow) {
  max-width: 660px;
  color: var(--muted);
  font-size: 18px;
}

.admin-panel {
  padding: 44px clamp(18px, 5vw, 72px) 80px;
}

.hidden {
  display: none;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.kpi-grid article {
  display: grid;
  gap: 6px;
}

.kpi-grid span {
  color: var(--muted);
}

.kpi-grid strong {
  color: var(--primary-dark);
  font-size: 30px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: start;
}

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

.wide {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 13px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.order-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.order-total {
  color: var(--primary-dark);
  font-weight: 900;
}

.hint {
  color: var(--muted);
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #fff;
  background: var(--primary-dark);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(16px);
  transition: 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1160px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-layout,
  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .topbar,
  .toolbar,
  .admin-head,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .nav,
  .controls {
    width: 100%;
  }

  .nav-link,
  .cart-button {
    flex: 1;
    justify-content: center;
  }

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

  .admin-login,
  .product-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .brand small,
  .cart-button span:not(.cart-icon) {
    display: none;
  }

  .hero,
  .admin-login {
    padding-top: 32px;
  }

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

  .product-card {
    min-height: auto;
  }
}
