:root {
  --bg: #f6efe6;
  --ink: #2b1a12;
  --muted: #7a5c4c;
  --card: #fffaf4;
  --line: #eadccc;
  --accent: #c45c26;
  --accent-dark: #9b3f14;
  --good: #2f6b45;
  --shadow: 0 12px 30px rgba(43, 26, 18, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

body.has-checkout {
  padding-bottom: calc(140px + env(safe-area-inset-bottom));
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px 24px;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 1.7rem;
}

.item,
.checkout,
.history-card {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.page-note,
.empty {
  margin: 0 0 14px;
  color: var(--muted);
}

.history-toolbar,
.page-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.history-toolbar .page-note {
  margin: 0;
}

.item-list {
  display: grid;
  gap: 12px;
}

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 14px;
  border-radius: var(--radius);
}

.item.active {
  border-color: #efb38a;
  background: #fff7f0;
}

.item.sold-out {
  opacity: 0.72;
}

.item h3 {
  margin: 0;
  font-size: 1.05rem;
}

.price {
  font-weight: 700;
  color: var(--accent-dark);
}

.meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.88rem;
}

.qty {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty button,
.ghost-btn,
.primary-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.qty button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #f0e4d6;
  color: var(--ink);
  font-size: 1.3rem;
}

.qty button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.qty-value {
  min-width: 1.6rem;
  text-align: center;
  font-weight: 700;
  font-size: 1.15rem;
}

.line-total {
  grid-column: 1 / -1;
  text-align: right;
  font-weight: 700;
}

.checkout {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(720px, 100%);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  gap: 12px;
}

body.has-checkout .checkout {
  display: grid;
}

.checkout-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

#grandTotal {
  font-size: 1.8rem;
}

.checkout-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}

.ghost-btn,
.primary-btn,
.text-btn {
  min-height: 46px;
  border-radius: 14px;
  padding: 0 14px;
}

.ghost-btn {
  background: #f0e4d6;
  color: var(--ink);
}

.primary-btn {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

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

.text-btn {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 170px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body:not(.has-checkout) .toast {
  bottom: 24px;
}

.stock-item {
  align-items: center;
}

.stock-field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.stock-field input {
  width: 88px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
  padding: 0 8px;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-card {
  padding: 14px;
  border-radius: var(--radius);
}

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

.history-head time {
  color: var(--muted);
  font-size: 0.88rem;
}

.history-card ul {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.history-card li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px dashed var(--line);
}

@media (min-width: 700px) {
  .item-list {
    grid-template-columns: 1fr 1fr;
  }
}
