:root {
  --bg: #f6efe3; --card: #fffdf8; --ink: #2b1d1a; --muted: #7a6a62;
  --wine: #7b1e2e; --wine-dark: #5a1421; --gold: #b8892f; --line: #e3d6c3;
  --ok: #2e7d4f; --warn: #c26a00; --bad: #b3261e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Segoe UI', Arial, sans-serif; font-size: 20px; color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column; user-select: none; -webkit-user-select: none;
}
input { user-select: text; -webkit-user-select: text; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 14px; min-height: 56px; padding: 0 22px; }
button:disabled { opacity: .35; cursor: default; }
.primary { background: var(--wine); color: #fff; font-weight: 700; }
.primary:active { background: var(--wine-dark); }
.ghost { background: transparent; color: var(--wine); border: 2px solid var(--line); }
.danger { background: var(--bad); color: #fff; }

header {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: var(--wine); color: #fff;
}
header h1 { margin: 0; font: 700 30px 'David', 'Times New Roman', serif; white-space: nowrap; }
header input {
  flex: 1; min-width: 0; height: 52px; border-radius: 26px; border: 0; padding: 0 22px; font-size: 20px;
}
header .ghost { color: #fff; border-color: rgba(255,255,255,.4); min-height: 48px; font-size: 16px; padding: 0 14px; }

#tabs { display: flex; gap: 10px; padding: 12px 20px; overflow-x: auto; background: var(--bg); border-bottom: 1px solid var(--line); }
#tabs button { background: var(--card); border: 2px solid var(--line); color: var(--ink); white-space: nowrap; font-weight: 600; }
#tabs button.active { background: var(--wine); border-color: var(--wine); color: #fff; }
#tabs small { opacity: .7; font-weight: 400; margin-inline-start: 6px; }

main { flex: 1; overflow-y: auto; padding: 8px 20px 120px; -webkit-overflow-scrolling: touch; }
.section h2 {
  font: 700 26px 'David', 'Times New Roman', serif; color: var(--wine); margin: 26px 0 4px;
  padding-bottom: 6px; border-bottom: 2px solid var(--gold);
}
.section .sub { color: var(--muted); font-size: 16px; margin-bottom: 8px; }
.wine {
  display: flex; align-items: center; gap: 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 12px 18px; margin: 10px 0;
}
.wine.active { border-color: var(--wine); box-shadow: 0 0 0 2px var(--wine) inset; }
.wine.out { opacity: .5; }
.wine .info { flex: 1; min-width: 0; }
.wine .name { font-weight: 700; font-size: 22px; }
.wine .meta { font-size: 16px; color: var(--muted); margin-top: 2px; }
.badge { display: inline-block; border-radius: 10px; padding: 1px 10px; font-size: 15px; font-weight: 600; margin-inline-start: 8px; }
.badge.low { background: #fff0d9; color: var(--warn); }
.badge.out { background: #fde4e2; color: var(--bad); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 64px; min-height: 64px; padding: 0; font-size: 34px; line-height: 1; background: var(--wine); color: #fff; }
.stepper button.minus { background: var(--card); color: var(--wine); border: 2px solid var(--wine); }
.stepper .qty { min-width: 56px; text-align: center; font-size: 30px; font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

footer {
  position: fixed; inset-inline: 0; bottom: 0; display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; background: var(--card); border-top: 3px solid var(--wine);
  box-shadow: 0 -6px 20px rgba(0,0,0,.12);
}
footer[hidden] { display: none; }
#cartSummary { flex: 1; font-weight: 700; font-size: 22px; }
#checkoutBtn { min-height: 64px; font-size: 22px; padding: 0 34px; }

#overlay { position: fixed; inset: 0; background: rgba(30,15,12,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
#overlay[hidden] { display: none; }
.modal {
  background: var(--card); border-radius: 22px; padding: 26px; width: min(720px, 100%); max-height: 94vh;
  overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
}
.modal.wide { width: min(1000px, 100%); height: 94vh; }
.modal h3 { margin: 0; font: 700 28px 'David', 'Times New Roman', serif; color: var(--wine); }
.modal .row { display: flex; gap: 12px; align-items: center; }
.modal .actions { display: flex; gap: 12px; margin-top: 6px; }
.modal .actions .primary { flex: 1; }
.modal input[type=text], .modal input[type=number], .modal input[type=month], .modal select {
  font: inherit; height: 56px; width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 0 14px; background: #fff;
}
.modal label { display: block; font-size: 16px; color: var(--muted); margin-bottom: 4px; }
.lines { border: 1px solid var(--line); border-radius: 12px; }
.lines div { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.lines div:last-child { border-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chips button { background: #fff; border: 2px solid var(--line); min-height: 52px; }
.chips button.sel { background: var(--wine); color: #fff; border-color: var(--wine); }
.error { color: var(--bad); font-weight: 600; min-height: 1.2em; }
.success { text-align: center; padding: 30px 10px; }
.success .big { font-size: 80px; }
.success h3 { font-size: 34px; }

.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad button { background: #fff; border: 2px solid var(--line); font-size: 30px; min-height: 72px; }
.pin-dots { text-align: center; font-size: 40px; letter-spacing: 12px; height: 56px; }

.tabsrow { display: flex; gap: 8px; flex-wrap: wrap; }
.tabsrow button { min-height: 48px; background: #fff; border: 2px solid var(--line); font-size: 18px; }
.tabsrow button.active { background: var(--wine); color: #fff; border-color: var(--wine); }
table { width: 100%; border-collapse: collapse; font-size: 17px; }
th, td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--card); }
td .mini { min-height: 42px; font-size: 15px; padding: 0 12px; border-radius: 10px; background: #fff; border: 2px solid var(--line); color: var(--wine); margin-inline-end: 6px; }
.voided { text-decoration: line-through; color: var(--muted); }
.banner { background: #fff0d9; color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: 17px; font-weight: 600; }
.scroll { flex: 1; overflow: auto; min-height: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) {
  header h1 { font-size: 22px; } .cols { grid-template-columns: 1fr; }
  .wine { flex-wrap: wrap; } .stepper { margin-inline-start: auto; }
}

/* winery tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; padding-top: 16px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  min-height: 210px; padding: 18px 12px; background: var(--card); border: 2px solid var(--line); border-radius: 22px; color: var(--ink);
}
.tile:active { border-color: var(--wine); background: #f3e6e1; }
.tile.out { opacity: .5; }
.tile-icon {
  width: 84px; height: 84px; border-radius: 50%; background: var(--wine); color: #fff; margin-bottom: 6px;
  display: flex; align-items: center; justify-content: center; font: 700 44px 'David', 'Times New Roman', serif;
  box-shadow: 0 0 0 4px var(--card), 0 0 0 6px var(--gold);
}
.tile-name { font-weight: 700; font-size: 24px; line-height: 1.15; }
.tile-meta { font-size: 16px; color: var(--muted); }
.tile-count {
  position: absolute; top: 10px; inset-inline-start: 10px; min-width: 40px; height: 40px; border-radius: 20px; padding: 0 10px;
  background: var(--ok); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.detail-head { display: flex; align-items: center; gap: 16px; margin: 14px 0 4px; }
.detail-head h2 { font: 700 30px 'David', 'Times New Roman', serif; color: var(--wine); margin: 0; }
.detail-head .back { background: var(--wine); color: #fff; font-weight: 700; white-space: nowrap; }

.tile-icon.has-logo { background: #fff; padding: 12px; box-shadow: 0 0 0 2px var(--line), 0 0 0 5px var(--gold); }
.tile-icon img { max-width: 100%; max-height: 100%; object-fit: contain; }
