:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #281e22;
  background: #f7f3ef;
  --wine: #451f2d;
  --accent: #773951;
  --line: #ded3d5;
  --muted: #63565c;
  --surface: #fffdfa;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p { margin: 0; }
h1 { font-family: Georgia, serif; font-weight: 700; font-size: clamp(1.7rem, 5vw, 2.45rem); }
h2 { font-size: 1.24rem; line-height: 1.2; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .46; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid #227b70;
  outline-offset: 3px;
}

.frame { max-width: 70rem; margin-inline: auto; padding-inline: clamp(.85rem, 3vw, 1.65rem); }
.masthead { color: #fff9f5; background: var(--wine); }
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem 1.25rem;
  padding-block: .8rem;
}
nav { display: flex; gap: .3rem; }
nav button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: .6rem;
  background: transparent;
  color: inherit;
  font-weight: 650;
  padding: .35rem .7rem;
}
nav button[aria-current] { border-color: #b98594; background: #67394b; }
main { padding-block: 1.2rem max(1.5rem, env(safe-area-inset-bottom)); }
.order-layout { display: grid; align-items: start; gap: 1.35rem; }
.section-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem .8rem; margin-bottom: .75rem; }
.section-title span, .muted { color: var(--muted); font-size: .9rem; }
.products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.product {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  min-height: 76px;
  border-radius: .8rem;
  border: 1px solid var(--line);
  background: var(--surface);
}
.product.selected { background: #f9ecf0; border-color: #a46179; }
.product-add {
  border: 0;
  border-radius: .75rem 0 0 .75rem;
  background: transparent;
  color: inherit;
  text-align: left;
  display: grid;
  align-content: center;
  gap: .25rem;
  padding: .55rem .35rem .55rem .65rem;
  overflow-wrap: anywhere;
}
.product-add:active { background: #f3dbe3; }
.product-add span { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.product-stepper { display: grid; align-content: center; justify-items: center; padding-top: .3rem; }
.product-stepper span { font-size: .92rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.product-stepper button, .stepper button {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 1.35rem;
}

.checkout, .stats-cards > div, table, details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .9rem;
}
.checkout { display: grid; gap: .85rem; padding: 1rem; }
.return-row { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: .6rem; }
.stepper output { min-width: 1.4rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.breakdown { border-top: 1px solid var(--line); padding-top: .65rem; margin: 0; }
.breakdown div { display: flex; justify-content: space-between; gap: .45rem; line-height: 1.65; }
.breakdown dd { margin: 0; font-variant-numeric: tabular-nums; }
.total {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .25rem .7rem;
  padding: .75rem;
  border-radius: .65rem;
  background: #f5e6eb;
  color: var(--wine);
}
.total span { font-weight: 700; }
.total strong { font-size: clamp(1.65rem, 6vw, 2.3rem); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.checkout-actions { display: grid; gap: .45rem; }
.primary, .secondary, .quiet { min-height: 46px; padding: .45rem .7rem; border-radius: .6rem; font-weight: 700; }
.primary { color: white; border: 1px solid var(--wine); background: var(--wine); }
.secondary { color: var(--wine); border: 1px solid #aa8793; background: var(--surface); }
.quiet { color: var(--muted); border: 1px solid transparent; background: none; }
#order-status { color: #25604f; }
#save-error { color: #9c2635; }

.stats-heading { justify-content: space-between; align-items: center; }
.stats-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.7rem, 1fr)); gap: .6rem; }
.stats-cards > div { padding: .75rem; }
.stats-cards dd { margin: .25rem 0 0; font-size: 1.45rem; font-weight: 750; color: var(--wine); }
.stats-detail { display: grid; gap: 1rem; align-items: start; }
table { width: 100%; border-spacing: 0; text-align: left; }
caption { text-align: left; margin-bottom: .45rem; font-weight: 700; }
th, td { padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th:last-child, td:last-child { text-align: right; }
details { padding: .85rem; }
summary { font-weight: 700; cursor: pointer; min-height: 28px; }
#history { list-style: none; margin: 0; padding: 0; }
#history li { display: grid; gap: .2rem; padding-block: .6rem; border-top: 1px solid var(--line); }
#history span { font-size: .9rem; color: var(--muted); }

dialog { width: min(91vw, 24rem); max-height: 90dvh; padding: 1rem; border: 1px solid var(--line); border-radius: .9rem; color: inherit; background: var(--surface); }
dialog::backdrop { background: #281e22a8; }
dialog form { display: grid; gap: .65rem; }
input { width: 100%; min-height: 48px; color: inherit; background: white; border: 1px solid #aa8793; border-radius: .55rem; padding: .55rem; font-size: 1.15rem; }

@media (min-width: 50rem) {
  .order-layout { grid-template-columns: 1fr 22rem; }
  .products { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-detail { grid-template-columns: 1fr 1fr; }
  .checkout { position: sticky; top: 1rem; }
}

@media (max-width: 49.99rem) {
  .checkout .total {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    border-radius: 0;
    border-top: 1px solid #dbb7c5;
    padding: .5rem max(.9rem, 3vw) max(.5rem, env(safe-area-inset-bottom));
  }
  body:has(#order-screen:not([hidden])) main { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
}
