:root {
  --bg: #f7f4ee;
  --panel: #fffdf8;
  --ink: #1d160f;
  --muted: #6b5d50;
  --line: #e1d7c7;
  --brand: #1f6d5b;
  --brand-dark: #165548;
  --warn: #9c3b22;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 500px at 20% -10%, #efe4cf 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
}

.container {
  width: min(1100px, 92%);
  margin: 0 auto;
}

.scan-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.95);
  backdrop-filter: blur(4px);
}

.nav-wrap {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  text-decoration: none;
  color: var(--ink);
  font-family: "Cormorant Garamond", serif;
  font-size: 1.45rem;
  font-weight: 700;
}

nav {
  display: flex;
  gap: 14px;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.scan-layout {
  padding: 20px 0 28px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
  align-items: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(49, 36, 18, 0.06);
}

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

h1, h2 {
  margin: 0 0 8px;
  font-family: "Cormorant Garamond", serif;
}

.note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.reader {
  width: 100%;
  min-height: 280px;
  border: 1px dashed #b9a27a;
  border-radius: 12px;
  overflow: hidden;
  background: #f2ece0;
}

.pill {
  border: 1px solid #bdd7cd;
  background: #ecf7f2;
  color: #1f6d5b;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.actions-row,
.manual-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.manual-row {
  grid-template-columns: 1fr auto;
}

input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  width: 100%;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-muted {
  background: #ede4d6;
  color: #3f3325;
}

.message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--warn);
  font-size: 0.92rem;
}

.scan-history-block {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff9ef;
  padding: 10px;
}

.scan-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.clear-history-btn {
  border: 0;
  background: transparent;
  color: #8c3d2b;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
}

.scan-history-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 170px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.scan-history-list li {
  border: 1px solid #e8dbc4;
  border-radius: 8px;
  background: #fff;
  padding: 6px 8px;
}

.scan-history-empty {
  color: var(--muted);
  font-size: 0.86rem;
}

.scan-history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.scan-history-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.scan-history-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
}

.scan-history-status {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
}

.scan-status-ok {
  color: #1f6d5b;
  background: #e8f6f1;
  border: 1px solid #bdd7cd;
}

.scan-status-fail {
  color: #9c3b22;
  background: #fff0ed;
  border: 1px solid #efc0b2;
}

.scan-status-info {
  color: #5b4b3a;
  background: #f8efe1;
  border: 1px solid #e5d1b5;
}

.scan-history-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.scan-copy-btn {
  border: 1px solid #d9c9ad;
  border-radius: 999px;
  background: #fff;
  color: #5b4b3a;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}

.scan-copy-btn:hover {
  background: #f6ecdc;
}

.cart-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.cart-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 10px;
  align-items: center;
}

.cart-item img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  background: #efe3d0;
}

.cart-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.qty {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.qty button {
  width: 24px;
  height: 24px;
  border: 1px solid #d7c4a8;
  background: #fff;
  border-radius: 7px;
  cursor: pointer;
}

.remove-btn {
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: #8c3d2b;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
}

.totals {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
  display: grid;
  gap: 6px;
}

.totals div {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grand {
  font-size: 1.08rem;
}

.checkout-block {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.paypal-shell {
  margin-top: 10px;
  min-height: 45px;
}

.receipt-card {
  grid-column: 1 / -1;
}

.receipt-code {
  margin: 6px 0 0;
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  font-weight: 800;
}

.receipt-qr {
  margin-top: 10px;
  width: 180px;
  min-height: 180px;
}

@media (max-width: 900px) {
  .scan-layout {
    grid-template-columns: 1fr;
  }

  .receipt-card {
    grid-column: auto;
  }
}
