:root {
  --bg: #f5e9da;
  --card: rgba(255, 255, 255, 0.92);
  --text: #3a2e2a;
  --muted: #7a675c;
  --accent: #6b4f3a;
  --accent-deep: #563c2b;
  --soft: #efe1d0;
  --line: #d8c3ae;
  --danger: #b65d49;
  --success: #476b56;
  --shadow: 0 18px 42px rgba(80, 56, 37, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --pill: 999px;
  --summary-h: 300px;
  --max: 1200px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Noto Serif TC", "PingFang TC", "Microsoft JhengHei", serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 28%),
    radial-gradient(circle at top right, rgba(225, 202, 180, 0.45), transparent 25%),
    linear-gradient(180deg, #f9f0e6 0%, var(--bg) 40%, #f3e3d1 100%);
}

body.locked {
  overflow: hidden;
}

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

.hidden {
  display: none !important;
}

.btn {
  border: none;
  border-radius: 18px;
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  touch-action: manipulation;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(92, 64, 42, 0.12);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #7a5a43, var(--accent));
  color: #fffaf5;
}

.btn-secondary {
  background: #f4ede6;
  color: var(--accent);
}

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

.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--pill);
  border: 1px solid rgba(107, 79, 58, 0.14);
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(107, 79, 58, 0.08);
}

.shell {
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px 16px 36px;
}

.hero,
.panel,
.menu-card,
.summary-card,
.login-card,
.admin-card {
  border: 1px solid rgba(216, 195, 174, 0.82);
  background: var(--card);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 28px 22px;
  margin-bottom: 18px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(251, 245, 238, 0.82));
}

.hero::after {
  content: "";
  position: absolute;
  right: -50px;
  bottom: -80px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(214, 183, 154, 0.32), transparent 68%);
}

.hero-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.hero-copy {
  min-width: 0;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.95rem, 4vw, 3.2rem);
  line-height: 1.15;
}

.hero p {
  margin: 12px 0 0;
  color: var(--muted);
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.outline-btn {
  border: 1px solid rgba(216, 195, 174, 0.95);
  border-radius: var(--pill);
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.outline-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(92, 64, 42, 0.1);
}

.outline-btn:active {
  transform: scale(0.98);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, rgba(249, 240, 230, 0.96), rgba(245, 233, 218, 0.98));
  backdrop-filter: blur(12px);
}

.login-card {
  width: min(100%, 440px);
  border-radius: var(--radius-xl);
  padding: 30px 24px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(251, 245, 238, 0.88));
}

.login-card h1 {
  margin: 18px 0 8px;
  font-size: clamp(1.85rem, 5vw, 2.5rem);
  line-height: 1.15;
}

.login-card p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.8;
}

.login-form,
.stack-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(216, 195, 174, 0.95);
  background: #fff;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(107, 79, 58, 0.45);
  box-shadow: 0 0 0 4px rgba(107, 79, 58, 0.1);
  transform: translateY(-1px);
}

.hint,
.muted {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.7;
}

.error-text {
  min-height: 1.6em;
  color: var(--danger);
  font-size: 0.86rem;
}

.success-text {
  color: var(--success);
}

.category-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-bottom: 22px;
  padding: 4px 2px 6px 0;
  scrollbar-width: none;
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.category-btn {
  flex: 0 0 auto;
  min-width: 0;
  white-space: nowrap;
  text-align: center;
  padding: 12px 18px;
  border-radius: var(--pill);
  border: 1px solid rgba(216, 195, 174, 0.88);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(92, 64, 42, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.category-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(92, 64, 42, 0.1);
}

.category-btn:active {
  transform: scale(0.98);
}

.category-btn.active {
  background: linear-gradient(135deg, #7a5a43, var(--accent));
  color: #fffaf5;
  box-shadow: 0 14px 28px rgba(107, 79, 58, 0.24);
}

.section-head {
  margin-bottom: 16px;
  padding: 0 2px;
}

.section-head h2,
.section-head h3 {
  margin: 0;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.menu-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 150px;
  padding: 18px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(253, 248, 243, 0.92));
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.menu-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.22), transparent 40%);
  pointer-events: none;
}

.menu-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 36px rgba(92, 64, 42, 0.13);
  border-color: rgba(107, 79, 58, 0.28);
}

.menu-card:active {
  transform: scale(0.985);
}

.menu-card.has-qty {
  border-color: rgba(107, 79, 58, 0.3);
  box-shadow: 0 18px 36px rgba(107, 79, 58, 0.14);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.item-meta {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.item-name {
  margin: 0;
  font-size: 1.14rem;
  line-height: 1.3;
  word-break: break-word;
}

.item-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.89rem;
  line-height: 1.65;
}

.price-chip {
  flex: 0 0 auto;
  min-width: 76px;
  padding: 10px 14px;
  border-radius: var(--pill);
  background: var(--soft);
  color: var(--accent);
  font-weight: 700;
  text-align: center;
}

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

.card-badge {
  color: var(--muted);
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.card-badge::before {
  content: "";
  width: 24px;
  height: 1px;
  background: rgba(107, 79, 58, 0.24);
}

.qty-control {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: var(--pill);
  border: 1px solid rgba(216, 195, 174, 0.84);
  background: rgba(250, 243, 236, 0.96);
}

.qty-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  font-size: 1.2rem;
  box-shadow: 0 8px 16px rgba(92, 64, 42, 0.08);
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.qty-btn:hover {
  background: #f7efe7;
}

.qty-btn:active {
  transform: scale(0.92);
  box-shadow: inset 0 0 0 1px rgba(107, 79, 58, 0.16);
}

.qty-value {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.order-page .shell {
  padding-bottom: calc(var(--summary-h) + 36px);
}

.order-summary {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(245, 233, 218, 0.55), rgba(245, 233, 218, 0.96) 18%, rgba(245, 233, 218, 0.99));
  backdrop-filter: blur(18px);
}

.summary-card {
  max-width: calc(var(--max) + 8px);
  margin: 0 auto;
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 -6px 34px rgba(92, 64, 42, 0.14);
}

.summary-inner {
  display: grid;
  gap: 14px;
  padding: 16px;
}

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

.summary-head h3 {
  margin: 0;
  font-size: 1rem;
}

.summary-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-items {
  display: grid;
  gap: 10px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.summary-empty {
  padding: 18px 16px;
  border: 1px dashed rgba(216, 195, 174, 0.92);
  border-radius: 18px;
  background: #fdf9f5;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
  font-size: 0.92rem;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(216, 195, 174, 0.75);
  background: #fffdfb;
}

.summary-name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  word-break: break-word;
}

.summary-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-subtotal {
  align-self: center;
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

.total-box {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(216, 195, 174, 0.78);
  background: linear-gradient(180deg, #fff, #fbf3eb);
}

.total-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.total-value {
  margin-top: 4px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

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

.admin-layout {
  display: grid;
  gap: 16px;
}

.admin-grid {
  display: grid;
  gap: 16px;
}

.admin-card {
  border-radius: var(--radius-xl);
  padding: 22px;
}

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

.toolbar-actions,
.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.product-item,
.order-item {
  border: 1px solid rgba(216, 195, 174, 0.82);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 253, 251, 0.92);
}

.product-head,
.order-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.product-meta,
.order-meta {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.7;
}

.pill-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--pill);
  font-size: 0.78rem;
  background: #f4ede6;
  color: var(--accent);
}

.pill-status.inactive {
  background: #f0e6e2;
  color: var(--danger);
}

.product-form-grid,
.filters-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.order-items-list {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(216, 195, 174, 0.9);
  display: grid;
  gap: 8px;
}

.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  z-index: 60;
  min-width: 220px;
  max-width: calc(100vw - 32px);
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(58, 46, 42, 0.94);
  color: #fffaf5;
  text-align: center;
  box-shadow: 0 18px 28px rgba(58, 46, 42, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 640px) {
  :root {
    --summary-h: 252px;
  }

  .shell {
    padding-left: 22px;
    padding-right: 22px;
  }

  .hero,
  .login-card {
    padding: 34px 30px;
  }

  .category-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    overflow: visible;
  }

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

  .summary-inner {
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
    align-items: start;
  }

  .summary-side,
  .admin-grid {
    display: grid;
    gap: 12px;
  }

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

@media (min-width: 960px) {
  :root {
    --summary-h: 238px;
  }

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

  .admin-layout {
    grid-template-columns: minmax(380px, 420px) minmax(0, 1fr);
    align-items: start;
  }
}
