/* 內頁共用樣式（沿用 home.css 淺／深色語意色票，零硬編碼色碼） */

/* ---------- 跨頁統一頂欄與純 HTML 「更多」選單 ---------- */
.bar .brand {
  min-height: 44px;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.bar-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out);
}

.bar-pick:active { transform: scale(0.97); }
.bar-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (hover: hover) {
  .bar-pick:hover { background: var(--surface-subtle); }
}

.nav-more {
  position: relative;
}

.nav-more > summary.more-toggle {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  min-width: 64px;
  padding: 0 14px;
}

.nav-more > summary.more-toggle::-webkit-details-marker {
  display: none;
}

.nav-more > summary.more-toggle::after {
  content: "▾";
  font-size: 12px;
  color: var(--muted);
  transition: transform var(--dur-fast) var(--ease-out);
}

.nav-more[open] > summary.more-toggle {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent-soft-ink);
}

.nav-more[open] > summary.more-toggle::after {
  transform: rotate(180deg);
}

.more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  min-width: 196px;
  display: grid;
  padding: 4px 0;
  border: var(--bw-bold) solid var(--border-ink);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  overflow: hidden;
}

.more-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 0 16px;
  border-top: 1px dashed var(--line);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.more-menu a:first-child {
  border-top: 0;
}

.more-menu a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--sticker);
  color: var(--sticker-ink);
}

.more-menu a[aria-current="page"] {
  background: var(--sticker);
  color: var(--sticker-ink);
  font-weight: 900;
}

.more-menu a[aria-current="page"]::after {
  content: "目前";
  font-size: 12px;
  font-weight: 900;
}

@media (hover: hover) {
  .more-menu a:not([aria-current="page"]):hover {
    background: var(--surface-subtle);
  }
}

/* 全部優惠頁：配合統一頂欄高度調整黏性篩選列位置 */
.browse-bar {
  top: calc(61px + env(safe-area-inset-top));
}

/* ---------- 最省點法頁：超商小白單收據＋避免固定結算列遮蔽頁尾 ---------- */
body:has(.order-bar) {
  padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

.order-page {
  padding-bottom: 120px;
}

body:has(.order-bar) .order-page {
  padding-bottom: 24px;
}

.order-result {
  scroll-margin-top: 76px;
}

.order-menu > .muted-note {
  margin-top: 12px;
}

.order-bar {
  max-width: 640px;
  margin: 0 auto;
  border-left: var(--bw-mid) solid var(--border-ink);
  border-right: var(--bw-mid) solid var(--border-ink);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.order-receipt {
  position: relative;
  border: var(--bw-bold) solid var(--border-ink);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-hero);
  padding: 16px 15px 14px;
  margin-bottom: 18px;
}

.order-receipt::after {
  content: "";
  position: absolute;
  left: calc(-1 * var(--bw-bold));
  right: calc(-1 * var(--bw-bold));
  bottom: -10px;
  height: 10px;
  pointer-events: none;
  background-image:
    linear-gradient(135deg, var(--surface) 50%, transparent 50%),
    linear-gradient(225deg, var(--surface) 50%, transparent 50%);
  background-size: 16px 10px;
  background-position: 0 0, 0 0;
  background-repeat: repeat-x;
  filter: drop-shadow(0 2.5px 0 var(--border-ink));
}

.order-receipt .order-total {
  padding: 0 0 12px;
  background: transparent;
  border: 0;
  border-bottom: 1.5px dashed var(--dash);
  border-radius: 0;
  justify-items: start;
}

.order-receipt .order-total-top {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}

.order-receipt .order-total strong {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
}

.order-receipt .order-save {
  display: inline-flex;
  align-items: center;
  margin-top: 2px;
  padding: 2px 9px;
  border-radius: 5px;
  background: var(--good-soft);
  color: var(--good-ink);
  border: 1.5px solid var(--good);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  transform: rotate(var(--tilt-neg));
}

.order-receipt .order-steps {
  margin: 12px 0 0;
  gap: 10px;
}

.order-receipt .order-step {
  border: 1.5px solid var(--border-ink);
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
}

.order-receipt .order-step-head strong {
  font-weight: 800;
  line-height: 1.35;
}

.order-receipt .order-step-head span {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.receipt-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1.5px dashed var(--dash);
  text-align: center;
}

.receipt-barcode {
  width: min(210px, 72%);
  height: 24px;
  margin: 0 auto 4px;
  opacity: 0.85;
  background: repeating-linear-gradient(
    90deg,
    var(--border-ink) 0 2px, transparent 2px 4px,
    var(--border-ink) 4px 5px, transparent 5px 8px,
    var(--border-ink) 8px 11px, transparent 11px 13px,
    var(--border-ink) 13px 14px, transparent 14px 16px,
    var(--border-ink) 16px 19px, transparent 19px 22px,
    var(--border-ink) 22px 23px, transparent 23px 26px
  );
}

.receipt-serial {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.order-alts li {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1.5px dashed var(--border-ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 2px 2px 0 var(--border-ink);
}

.order-alt-items {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-secondary);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.order-alts .code-row {
  margin-top: 2px;
}

.order-alts .order-conditions {
  margin-top: 2px;
}

/* ---------- 意見回饋 & 許願池：即時字數計數與驗證提示 ---------- */
.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.char-count {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.char-count.is-invalid {
  color: var(--danger);
}

.char-count.is-valid {
  color: var(--good);
}

.field-hint {
  font-size: 12.5px;
  color: var(--danger);
}

.field-hint[hidden] {
  display: none;
}

/* ---------- 資料說明頁（/data） ---------- */
.data-page {
  max-width: 720px;
}

body:has(.data-page) .foot {
  max-width: 720px;
}

.data-header {
  display: grid;
  gap: 6px;
}

.data-status {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--ink-secondary);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

@media (min-width: 600px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.kpi-card {
  display: grid;
  gap: 2px;
  padding: 11px 12px;
  border: var(--bw-mid) solid var(--border-ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 3px 3px 0 var(--border-ink);
}

.kpi-card strong {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.kpi-card span {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink-secondary);
}

.kpi-card small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.data-section {
  margin-top: 24px;
}

.section-head {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.section-head .sub-title {
  margin: 0;
}

.store-statuses {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-items: start;
}

@media (min-width: 600px) {
  .store-statuses {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.store-status-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.store-status-card[open] {
  grid-column: 1 / -1;
}

.store-status-card summary {
  display: grid;
  gap: 4px;
  min-height: 44px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
}

.store-status-card summary::-webkit-details-marker {
  display: none;
}

.store-status-card summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

.store-status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.store-status-head strong {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-status-head::after {
  content: "▾";
  flex: none;
  font-size: 12px;
  color: var(--muted);
}

.store-status-card[open] .store-status-head::after {
  content: "▴";
}

.store-state {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  max-width: 100%;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  border: 1px solid var(--line);
}

.store-state[data-state="RANKABLE"] {
  background: var(--good-soft);
  color: var(--good-ink);
  border-color: transparent;
}

.store-state[data-state="CATALOG_ONLY"],
.store-state[data-state="ON_PAGE_NO_END_DATE"] {
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
  border-color: transparent;
}

.store-state[data-state="BLOCKED_SOURCE_ACCESS"] {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.store-status-body {
  display: grid;
  gap: 6px;
  padding: 8px 10px 10px;
  border-top: 1px dashed var(--line);
  font-size: 13.5px;
  color: var(--ink-secondary);
}

.store-status-body p {
  margin: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.store-status-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}

.inventory-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

@media (min-width: 540px) {
  .inventory-toolbar {
    grid-template-columns: minmax(190px, 230px) minmax(0, 1fr);
  }
}

.inventory-toolbar .field select,
.inventory-toolbar .field input {
  min-height: 44px;
  padding: 9px 12px;
  font-size: 15px;
}

.inventory-items {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.inventory-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.inventory-row summary {
  display: grid;
  gap: 4px;
  min-height: 44px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.inventory-row summary::-webkit-details-marker {
  display: none;
}

.inventory-row summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

.inv-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
}

.inv-store {
  font-weight: 700;
  color: var(--ink-secondary);
}

.inv-tier {
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  border: 1px solid var(--line);
}

.inv-tier[data-tier="rankable_deal"] {
  background: var(--good-soft);
  color: var(--good-ink);
  border-color: transparent;
}

.inv-tier[data-tier="official_entry"] {
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
  border-color: transparent;
}

.inv-state {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.inv-state[data-state="expired"] {
  color: var(--danger);
  font-weight: 600;
}

.inv-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.inventory-row[open] summary {
  border-bottom: 1px dashed var(--line);
}

.inv-body {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
  font-size: 13.5px;
  color: var(--ink-secondary);
}

.inv-detail {
  margin: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.inv-meta {
  display: grid;
  gap: 4px;
  margin: 0;
}

.inv-meta div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inv-meta dt {
  color: var(--muted);
  min-width: 72px;
}

.inv-meta dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.inv-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.data-rules-list {
  margin: 8px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-secondary);
  line-height: 1.55;
}

.more-menu > .account:empty + a {
  border-top: 0;
}

.more-menu .admin-link {
  color: var(--accent-soft-ink);
  background: var(--accent-soft);
  font-size: 13.5px;
}

/* ---------- 許願與回饋雙分頁切換列 ---------- */
.hub-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 16px;
}

.hub-tab {
  min-height: 46px;
  padding: 0 12px;
  border: var(--bw-mid) solid var(--border-ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out);
}

.hub-tab[aria-selected="true"] {
  background: var(--sticker);
  color: var(--sticker-ink);
  border-width: var(--bw-bold);
}

.hub-tab:active { transform: translate(1px, 1px); }
.hub-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 最優點法：8 大品牌分組與跨店拼餐小白單 ---------- */
.order-store-groups {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.order-store-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.order-group-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  min-width: 34px;
}

.order-store-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.order-store-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1.5px dashed var(--dash);
}

.order-store-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.order-store-section-head strong {
  font-size: 15.5px;
  font-weight: 900;
  color: var(--ink);
}

.order-store-section-head span {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--good);
}

@media (prefers-reduced-motion: reduce) {
  .bar-pick,
  .nav-more > summary.more-toggle::after,
  .more-menu a,
  .hub-tab {
    transition: none;
  }
}
