:root {
  --bg: #fffaf3;
  --surface: #ffffff;
  --surface-soft: #fff4df;
  --text: #30251d;
  --muted: #796b60;
  --brand: #a3401d;
  --brand-dark: #783018;
  --accent: #f2b544;
  --danger: #bd2e2e;
  --success: #227a4a;
  --border: #ead9c7;
  --shadow: 0 12px 30px rgba(87, 47, 20, 0.10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #fff8ec 0%, #fffdf9 45%, #fff8ec 100%);
  color: var(--text);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: rgba(255, 250, 243, 0.92);
  border-bottom: 1px solid rgba(234, 217, 199, 0.85);
}
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: .03em;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), #d46a32);
  color: white;
  box-shadow: var(--shadow);
  font-size: 22px;
}
.header-link {
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--muted);
  font-weight: 700;
}

.container {
  width: min(100% - 28px, 1120px);
  margin: 0 auto;
  padding: 22px 0 54px;
}
.hero {
  padding: 28px 22px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 90% 12%, rgba(242,181,68,.28), transparent 35%),
    linear-gradient(135deg, #772d16, #b84720 60%, #d46a32);
  color: white;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
  position: relative;
}
.hero::after {
  content: "🐔";
  position: absolute;
  right: 15px;
  bottom: -24px;
  font-size: 112px;
  opacity: .15;
  transform: rotate(-8deg);
}
.hero h1 { margin: 0 0 8px; font-size: clamp(28px, 6vw, 46px); line-height: 1.15; }
.hero p { margin: 0; opacity: .9; max-width: 680px; line-height: 1.75; }

.layout { display: grid; gap: 18px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 8px 26px rgba(65, 39, 23, .06);
}
.card h2, .card h3 { margin-top: 0; }
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  margin-bottom: 14px;
}
.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--brand);
  font-size: 14px;
}

.form-grid { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label, .field-label { font-size: 14px; color: var(--muted); font-weight: 800; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fffefa;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 13px;
  outline: none;
  transition: .2s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(242,181,68,.18);
}
textarea { min-height: 92px; resize: vertical; }

.store-options, .slot-grid { display: grid; gap: 10px; }
.store-option { position: relative; }
.store-option input { position: absolute; opacity: 0; pointer-events: none; }
.store-option label {
  display: block;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface);
  transition: .2s ease;
}
.store-option input:checked + label {
  border-color: var(--brand);
  background: #fff3e8;
  box-shadow: 0 0 0 4px rgba(163,64,29,.10);
}
.store-name { font-weight: 900; margin-bottom: 4px; }
.store-address { color: var(--muted); font-size: 13px; }

.slot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.slot-btn {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 8px;
  background: white;
  color: var(--text);
  font-weight: 800;
  position: relative;
}
.slot-btn:hover:not(:disabled), .slot-btn.active {
  border-color: var(--brand);
  background: #fff2e6;
  color: var(--brand-dark);
}
.slot-btn:disabled {
  cursor: not-allowed;
  background: #f2efeb;
  color: #aaa198;
  text-decoration: line-through;
}
.slot-meta { display: block; font-size: 10px; margin-top: 3px; font-weight: 600; opacity: .8; }

.product-list { display: grid; gap: 12px; }
.product-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 12px;
  background: linear-gradient(180deg, #fff, #fffcf8);
}
.product-top { display: flex; justify-content: space-between; gap: 12px; }
.product-name { font-weight: 900; font-size: 17px; }
.product-desc { color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.5; }
.product-price { font-weight: 900; color: var(--brand); white-space: nowrap; }
.product-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.qty-control {
  display: inline-grid;
  grid-template-columns: 38px 48px 38px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: white;
}
.qty-control button { border: 0; background: #fff3e8; height: 40px; font-weight: 900; color: var(--brand-dark); }
.qty-control input { border: 0; border-radius: 0; text-align: center; padding: 0; height: 40px; background: white; }

.order-summary {
  position: sticky;
  bottom: 12px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  color: white;
  background: rgba(74, 35, 19, .96);
  box-shadow: 0 14px 36px rgba(52, 27, 14, .24);
  margin-top: 16px;
}
.total-label { font-size: 12px; opacity: .8; }
.total-price { font-size: 23px; font-weight: 900; }
.primary-btn, .secondary-btn, .danger-btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 900;
}
.primary-btn { color: #4d2a00; background: var(--accent); }
.primary-btn:hover { filter: brightness(.98); transform: translateY(-1px); }
.primary-btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.secondary-btn { color: var(--brand-dark); background: #fff0e3; border: 1px solid #f0c9b1; }
.danger-btn { color: white; background: var(--danger); }
.full-btn { width: 100%; }

.notice {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff4d9;
  border: 1px solid #efd69f;
  color: #765314;
  font-size: 13px;
  line-height: 1.6;
}
.empty-state { text-align: center; padding: 28px 14px; color: var(--muted); }
.hidden { display: none !important; }
.error-text { color: var(--danger); font-size: 13px; }
.success-box {
  padding: 22px;
  text-align: center;
  border-radius: 18px;
  background: #effaf4;
  border: 1px solid #bce2ca;
}
.success-box h2 { color: var(--success); }
.order-number { font-size: 24px; font-weight: 900; letter-spacing: .08em; color: var(--brand); }

/* Admin */
.admin-shell { display: grid; gap: 18px; }
.admin-login { max-width: 460px; margin: 54px auto; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metric-card { padding: 16px; border-radius: 15px; background: var(--surface-soft); border: 1px solid var(--border); }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 800; }
.metric-value { font-size: 26px; font-weight: 900; margin-top: 5px; }
.filter-grid { display: grid; gap: 10px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 9px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 980px; background: white; }
th, td { padding: 11px 10px; border-bottom: 1px solid #f0e6dc; text-align: left; vertical-align: top; font-size: 13px; }
th { background: #fff6eb; color: #665343; position: sticky; top: 0; z-index: 1; }
.order-items-cell { min-width: 230px; line-height: 1.7; }
.status-select { min-width: 105px; padding: 8px; }
.status-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 900; }
.status-new { background: #fff0c9; color: #795400; }
.status-confirmed { background: #e5f0ff; color: #24558f; }
.status-completed { background: #def5e7; color: #1d6a41; }
.status-cancelled { background: #f6dddd; color: #8f2a2a; }
.slot-admin-grid { display: grid; gap: 10px; }
.slot-admin-row {
  display: grid;
  grid-template-columns: 70px 1fr 90px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.toggle { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.toggle input { width: auto; }
.small-note { color: var(--muted); font-size: 12px; line-height: 1.5; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 18px 0 36px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 16px;
  border-radius: 12px;
  color: white;
  background: #3c2a1f;
  box-shadow: var(--shadow);
  transition: .25s ease;
  z-index: 50;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 700px) {
  .container { padding-top: 30px; }
  .layout { grid-template-columns: minmax(0, 1.6fr) minmax(280px, .9fr); align-items: start; }
  .side-column { position: sticky; top: 88px; display: grid; gap: 18px; }
  .store-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .slot-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .product-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .slot-admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
