:root {
  --brand-orange: #E8934A;
  --brand-orange-dark: #D97B33;
  --brand-maroon: #8B3A2B;
  --brand-cream: #FFF8F0;
  --brand-text: #3B2A20;
}
* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: #f6f5f2;
  color: #2b2b2b;
}
img { max-width: 100%; }

/* ===== Header / Progress ===== */
.top-bar {
  background: var(--brand-orange);
  color: #fff;
  padding: 14px 20px;
}
.brand-banner {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 14px;
}
.top-bar h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 1px;
}
.top-bar .tagline {
  font-size: 13px;
  opacity: 0.92;
  margin: 2px 0 10px;
}
.progress-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.progress-bar-outer {
  flex: 1 1 200px;
  max-width: 400px;
  height: 12px;
  background: rgba(255,255,255,0.35);
  border-radius: 6px;
  overflow: hidden;
}
.progress-bar-inner {
  height: 100%;
  background: #fff;
  border-radius: 6px;
  transition: width .4s ease;
}
.progress-text { white-space: nowrap; font-weight: 600; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #eee;
}
.tag-chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--brand-maroon);
  color: var(--brand-maroon);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.tag-chip.active {
  background: var(--brand-maroon);
  color: #fff;
}

/* ===== 縣市／行政區選單 ===== */
.district-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #fbfaf8;
  border-bottom: 1px solid #eee;
}
.city-select {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--brand-orange-dark);
  background: #fff;
  color: var(--brand-text);
  font-size: 14px;
  font-weight: 600;
  flex: 1 1 160px;
  min-width: 0;
}

/* ===== Map ===== */
#map {
  width: 100%;
  height: 46vh;
  min-height: 320px;
}
.map-key-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

/* ===== Store list ===== */
.list-header {
  padding: 14px 20px 4px;
  font-size: 14px;
  color: #666;
}
.store-list {
  padding: 8px 20px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.store-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  cursor: pointer;
  overflow: hidden;
}
.store-photo {
  display: block;
  width: calc(100% + 28px);
  margin: -14px -14px 10px;
  height: 140px;
  object-fit: cover;
}
.store-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}
.store-card .meta {
  font-size: 13px;
  color: #555;
  line-height: 1.6;
}
.store-card .qty-line {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-maroon);
}
.store-card .qty-note {
  font-size: 11px;
  color: #999;
}
.store-card .tags {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.mini-tag {
  font-size: 11px;
  background: #f0e6d8;
  color: #8a5a2b;
  padding: 2px 8px;
  border-radius: 999px;
}
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: #999;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  max-width: 420px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
  position: relative;
}
.modal-box h2 {
  margin: 0 0 10px;
  font-size: 18px;
}
.modal-photo {
  display: block;
  width: calc(100% + 40px);
  margin: -20px -20px 12px;
  height: 200px;
  object-fit: cover;
}
.photo-attribution {
  font-size: 10px;
  color: #999;
  text-align: right;
  margin: -6px 0 10px;
}
.photo-attribution a { color: #999; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: #999;
}
.modal-row { margin: 8px 0; font-size: 14px; line-height: 1.6; }
.modal-row b { color: #333; }
.modal-qty-note {
  background: #fff4e5;
  border: 1px solid #ffdca0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: #8a5a00;
  margin: 8px 0;
}
.modal-rules {
  background: #f6f5f2;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  white-space: pre-wrap;
  margin-top: 6px;
}
.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.btn-primary { background: var(--brand-maroon); color: #fff; }
.btn-secondary { background: #eee; color: #333; }

/* ===== Admin ===== */
.admin-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}
.admin-login {
  max-width: 340px;
  margin: 100px auto;
  background: #fff;
  padding: 28px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.admin-login h2 { margin-top: 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: #555; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}
.field textarea { min-height: 70px; resize: vertical; }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.admin-tab-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
.admin-tab-btn.active { background: var(--brand-maroon); color: #fff; border-color: var(--brand-maroon); }
.admin-panel { display: none; background: #fff; border-radius: 10px; padding: 18px; }
.admin-panel.active { display: block; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { border-bottom: 1px solid #eee; padding: 8px 6px; text-align: left; vertical-align: top; }
.admin-table td.actions { white-space: nowrap; }
.tag-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tag-checks label { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.error-msg { color: var(--brand-maroon); font-size: 13px; margin-top: 8px; }
.success-msg { color: #2a8c4a; font-size: 13px; margin-top: 8px; }
.form-actions { margin-top: 14px; display: flex; gap: 8px; }
.admin-panel { overflow-x: auto; }

/* ===== RWD：平板以下 ===== */
@media (max-width: 720px) {
  .admin-login { margin: 40px 16px; max-width: none; }
  .top-bar { padding: 12px 16px; }
  .brand-banner { margin-bottom: 10px; }
  .top-bar h1 { font-size: 19px; }
  .filter-bar, .district-bar { padding: 10px 16px; }
  .district-bar { flex-direction: column; align-items: stretch; }
  .city-select { flex: none; width: 100%; }
  #map { height: 40vh; min-height: 260px; }
  .list-header { padding: 12px 16px 4px; }
  .store-list { padding: 8px 16px 32px; grid-template-columns: 1fr; }
  .admin-wrap { padding: 16px 12px 48px; }
  .admin-tabs { flex-wrap: wrap; }
  .admin-tab-btn { flex: 1 1 auto; padding: 8px 10px; font-size: 13px; }
}

/* ===== RWD：小型手機 ===== */
@media (max-width: 380px) {
  .top-bar h1 { font-size: 17px; }
  .progress-text { font-size: 12px; }
  .tag-chip { padding: 5px 10px; font-size: 12px; }
  .modal-box { padding: 16px; }
  .btn-row { flex-direction: column; }
}
