:root {
  color-scheme: light;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", Helvetica, Arial, sans-serif;
  --canvas: #f3f5f4;
  --surface: #fff;
  --ink: #132f28;
  --body: #23342e;
  --muted: #52635b;
  --border: #d6e1da;
  --green: #007748;
  --green-hover: #005e39;
  --gutter: clamp(20px, 5vw, 40px);
  --page-width: 600px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  display: grid;
  grid-template-columns: minmax(0, var(--page-width));
  grid-template-rows: auto 1fr;
  justify-content: center;
  min-height: 100svh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.5;
}
button, input { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

:focus-visible {
  outline: 3px solid #245780;
  outline-offset: 4px;
}

h1, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.75rem, 5vw, 2.2rem); line-height: 1.2; letter-spacing: -.04em; }
h1:focus { outline: none; }

.site-header, .shell {
  border-inline: 1px solid var(--border);
  background: var(--surface);
}
.site-header-inner {
  min-height: 78px;
  margin: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.brand-lockup { display: flex; align-items: center; gap: clamp(14px, 3vw, 22px); }
.brand-logo { width: 133px; height: auto; }
.smartcode-logo { width: 108px; height: auto; }
.preview-status { color: var(--muted); font-size: .88rem; white-space: nowrap; }

.shell { min-width: 0; padding: 26px var(--gutter) 40px; }
.venue-photo {
  overflow: hidden;
  aspect-ratio: 2.55 / 1;
  border-radius: 8px;
  background: #dce8df;
}
.venue-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center 58%; }
.lookup-content { padding-top: 23px; }
.section-label { margin-top: 6px; color: var(--muted); font-size: 1rem; }
#receipt-search { display: grid; gap: 17px; margin-top: 25px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--body); font-size: .96rem; font-weight: 650; }
.field input {
  min-width: 0;
  width: 100%;
  min-height: 50px;
  border: 1px solid #aebeb5;
  border-radius: 7px;
  padding: 11px 13px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
}
.field input::placeholder { color: #667770; opacity: 1; }
.field input[aria-invalid="true"] { border-color: #b93642; }
.lookup-feedback { color: #a52635; font-size: .94rem; }

.primary-button, .back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
  line-height: 1.3;
}
.primary-button { padding: 13px 24px; background: var(--green); color: #fff; }
.primary-button:hover { background: var(--green-hover); }
.search-button { width: 100%; margin-top: 5px; }
.back-button {
  padding: 10px 16px;
  border-color: #b7c8be;
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
}
.back-button:hover { background: #e9f3ed; }
.back-button span { font-size: 1.15em; }

.receipt-view { padding-top: 5px; }
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 clamp(22px, 4vw, 32px);
}
.venue-name { margin-top: 7px; color: var(--muted); font-size: clamp(1rem, 2vw, 1.24rem); }

.receipt-list, .receipt-card { border-block: 1px solid var(--border); }
.receipt-list { list-style: none; margin: 0; padding: 0; }
.receipt-list > li + li { border-top: 1px solid var(--border); }
.receipt-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: clamp(11px, 2vw, 24px);
  align-items: center;
  width: 100%;
  min-height: 76px;
  padding: 12px 5px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.receipt-row:hover { background: #f0f7f2; }
.receipt-row-identity { display: grid; gap: 3px; min-width: 0; }
.receipt-row-date { font-weight: 700; }
.receipt-row-number {
  color: var(--muted);
  font-size: .85rem;
  overflow-wrap: anywhere;
}
.receipt-row-amount {
  color: var(--green);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  white-space: nowrap;
}
.receipt-row-chevron {
  width: .55rem;
  height: .55rem;
  margin-right: 4px;
  border: solid var(--muted);
  border-width: 2px 2px 0 0;
  transform: rotate(45deg);
}

.receipt-card { padding: 19px 0 20px; }
.receipt-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px 28px;
  padding-bottom: clamp(18px, 3vw, 29px);
  border-bottom: 1px solid var(--border);
}
.receipt-summary dt, .receipt-details dt { color: var(--muted); }
.receipt-summary dd { margin-top: 2px; font-size: clamp(1.2rem, 3vw, 1.7rem); font-weight: 750; }
.receipt-total { text-align: right; }
.receipt-total dd {
  color: var(--green);
  font-size: clamp(2rem, 4vw, 2.7rem);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.receipt-details { margin-top: 8px; }
.receipt-details > div {
  display: grid;
  grid-template-columns: minmax(84px, 30%) minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.receipt-details > div:last-child { border: 0; padding-bottom: 0; }
.receipt-details dd { color: var(--body); font-variant-numeric: tabular-nums; }
.receipt-actions { display: flex; margin-top: 22px; }
.receipt-actions .primary-button { width: 100%; }

.download-icon {
  width: 15px;
  height: 12px;
  position: relative;
  border: solid currentColor;
  border-width: 0 1.6px 1.6px;
  border-radius: 0 0 2px 2px;
  margin-top: 4px;
}
.download-icon::before, .download-icon::after { position: absolute; content: ""; }
.download-icon::before { left: 5px; top: -5px; width: 1.6px; height: 9px; background: currentColor; }
.download-icon::after {
  left: 3px;
  top: -1px;
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}

@media (max-width: 600px) {
  .site-header, .shell { border-inline: 0; }
  .site-header-inner { min-height: 67px; }
  .brand-logo { width: 110px; }
  .smartcode-logo { width: 83px; }
  .preview-status { font-size: .82rem; }
  .shell { padding-top: 20px; }
  .venue-photo { aspect-ratio: 2.16 / 1; }
  .lookup-content { padding-top: 20px; }
  #receipt-search { gap: 15px; margin-top: 20px; }
  .view-header { align-items: flex-start; }
  .receipt-details > div { gap: 9px; }
}
@media (max-width: 360px) {
  .receipt-row-number { font-size: .77rem; }
  .receipt-row { gap: 8px; }
  .receipt-summary { flex-direction: column; }
  .receipt-total { text-align: left; }
  .back-button { padding-inline: 12px; }
}
