:root {
  --bg: #f7f3ee;
  --card: #ffffff;
  --ink: #2a1a1c;
  --muted: #7a6a6c;
  --line: #e6dcd3;
  --wine: #8c2f39;
  --wine-dark: #6d222b;
  --ok: #2f7a4b;
  --ok-bg: #e5f3ea;
  --warn: #9a5b00;
  --warn-bg: #fff3d6;
  --err: #b3261e;
  --err-bg: #fde7e5;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
header.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--wine); color: #fff;
}
header.bar h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 600; }
header.bar button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); }
.conn { width: 10px; height: 10px; border-radius: 50%; background: #9fe0b5; }
.conn.down { background: #ffb4a9; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
button, .btn {
  font: inherit; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); padding: 10px 14px; cursor: pointer;
  min-height: 44px;
}
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--wine); color: #fff; border-color: var(--wine); font-weight: 600; }
.primary:active { background: var(--wine-dark); }
.big { width: 100%; padding: 18px; font-size: 20px; }
.danger { color: var(--err); }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin: 12px 0; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Order list */
.order-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin: 8px 0; padding: 12px 14px; }
.order-item .no { font-weight: 700; font-size: 20px; min-width: 64px; }
.chip { font-size: 13px; padding: 3px 9px; border-radius: 999px; background: #eee; white-space: nowrap; }
.chip.new { background: #e8eefc; color: #2b4a9b; }
.chip.preparing { background: var(--warn-bg); color: var(--warn); }
.chip.ready { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.chip.collected, .chip.cancelled { background: #eee; color: var(--muted); }
.chip.draft { background: #f1e8e8; color: var(--wine); }
.order-item.ready { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok-bg); }

/* Order screen */
.order-head { text-align: center; padding: 18px 12px; }
.order-head .no { font-size: 56px; font-weight: 800; letter-spacing: .02em; color: var(--wine); line-height: 1; }
.order-head .hint { margin-top: 6px; color: var(--muted); font-size: 15px; }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photo { position: relative; width: 84px; height: 112px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #ddd; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .tag { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; background: rgba(0,0,0,.6); color: #fff; padding: 2px 4px; text-align: center; }
.reading { display: flex; gap: 12px; align-items: center; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--wine); border-radius: 50%; animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { border-radius: 12px; padding: 10px 14px; margin: 10px 0; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.domain { font-weight: 700; margin: 14px 0 4px; color: var(--wine); }
.line { padding: 10px 0; border-top: 1px solid var(--line); }
.line:first-of-type { border-top: 0; }
.line.flagged { background: var(--warn-bg); margin: 0 -16px; padding: 10px 16px; }
.line .name { font-weight: 600; }
.line .flag { font-size: 14px; color: var(--warn); margin-top: 4px; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 44px; padding: 0; font-size: 22px; }
.qty input { width: 56px; text-align: center; font: inherit; font-size: 20px; font-weight: 700; padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; }
.line-total { min-width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
.crossed { font-size: 14px; color: var(--muted); text-decoration: line-through; }
select, input[type=text], input[type=email], input[type=tel], textarea {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.total { display: flex; justify-content: space-between; font-size: 24px; font-weight: 800; padding: 6px 0; }
.actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 12px; }
.sent-banner { text-align: center; }
.hidden { display: none !important; }
input[type=file] { display: none; }
.promo { font-size: 14px; color: var(--ok); margin-top: 6px; }
.promo.hint { color: var(--warn); }
.gift { color: #5b2a8c; font-size: 15px; }
button.link { background: none; border: 0; color: #5b2a8c; padding: 6px 0; min-height: 0; font-size: 15px; }
.subtotal { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 15px; padding: 2px 0; }
