:root {
  --bg: #f6f6f4; --surface: #ffffff; --surface-2: #f0f0ed; --surface-3: #e5e5e1;
  --text: #121212; --muted: #6e6e6a; --faint: #a3a39e; --line: #ebebe7;
  --accent: #111111; --on-accent: #ffffff;
  --pos: #068a52; --pos-soft: #e3f5ec; --neg: #d4471c; --neg-soft: #fcebe4; --warn: #b7791f; --warn-soft: #fdf3dc;
  --shadow: 0 1px 2px rgba(18, 18, 18, .04); --shadow-lg: 0 12px 40px rgba(18, 18, 18, .14);
  --r: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0b; --surface: #161616; --surface-2: #1f1f1f; --surface-3: #2a2a2a;
    --text: #f2f2f0; --muted: #9a9a95; --faint: #61615d; --line: #242424;
    --pos: #34d399; --pos-soft: #10291f; --neg: #fb7f55; --neg-soft: #2e1710; --warn: #fbbf24; --warn-soft: #2d2410;
    --shadow: none; --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.i { flex: none; display: block; }
#app { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 120px); min-height: 100vh; }
.boot { display: grid; place-items: center; min-height: 70vh; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--text); animation: spin .7s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Shop header ---------- */
.shop-head { display: flex; gap: 14px; align-items: center; margin: 4px 0 6px; }
.shop-logo { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; font-size: 28px; background: var(--accent); color: var(--on-accent); flex: none; box-shadow: var(--shadow-lg); }
.shop-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.shop-head .tag { color: var(--muted); font-size: 14px; }
.shop-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.meta-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 550; box-shadow: var(--shadow); }
.meta-chip.open { color: var(--pos); }
.meta-chip.closed { color: var(--neg); }

/* ---------- Generic ---------- */
.card { background: var(--surface); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.section { margin-top: 24px; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 10px; }
.section-h h2 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.step-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; margin-right: 8px; vertical-align: 2px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.list { background: var(--surface); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; position: relative; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; color: inherit; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 16px; height: 1px; background: var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; }
.row .s { color: var(--muted); font-size: 13px; }
.row .end { text-align: right; flex: none; font-weight: 600; }
.row.sel { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.row.sel .radio { background: var(--accent); border-color: var(--accent); }
.row.sel .radio::after { opacity: 1; }
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface-3); flex: none; position: relative; }
.radio::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--on-accent); opacity: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 0; background: var(--surface); border-radius: 999px; padding: 9px 15px; font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); color: var(--text); }
.chip.on { background: var(--accent); color: var(--on-accent); }
.chip:disabled { opacity: .35; cursor: default; }

.dates { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; scroll-snap-type: x proximity; }
.dates::-webkit-scrollbar { display: none; }
.date { flex: none; width: 58px; padding: 10px 0; border-radius: 16px; border: 0; background: var(--surface); text-align: center; cursor: pointer; box-shadow: var(--shadow); scroll-snap-align: start; color: var(--text); }
.date .dw { font-size: 12px; color: var(--muted); font-weight: 600; }
.date .dd { font-size: 20px; font-weight: 700; line-height: 1.2; }
.date .dm { font-size: 11px; color: var(--muted); }
.date.on { background: var(--accent); color: var(--on-accent); }
.date.on .dw, .date.on .dm { color: inherit; opacity: .8; }
.date:disabled { opacity: .3; cursor: default; }

.times { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.time { border: 0; background: var(--surface); border-radius: 12px; padding: 11px 0; font-weight: 600; font-size: 14px; cursor: pointer; box-shadow: var(--shadow); color: var(--text); font-variant-numeric: tabular-nums; }
.time.on { background: var(--accent); color: var(--on-accent); }
.time-group { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 14px 4px 8px; }

.field { display: block; margin-bottom: 14px; }
.field > span, .label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 2px 7px; }
.input { width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid transparent; background: var(--surface); outline: none; font-size: 16px; }
.sheet .input, .card .input { background: var(--surface-2); }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 80px; resize: vertical; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > * { flex: 1; min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 20px; border-radius: 999px; border: 0; background: var(--surface-2); font-weight: 650; cursor: pointer; color: var(--text); transition: transform .1s; text-align: center; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.dark { background: var(--text); color: var(--bg); }
.btn.wa { background: #25d366; color: #fff; }
.btn.danger { background: var(--neg-soft); color: var(--neg); }
.btn.ghost { background: none; color: var(--muted); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }
.stack > * + * { margin-top: 10px; }

.bar-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.bar-bottom .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 12px; align-items: center; }
.bar-bottom .sum { flex: 1; min-width: 0; font-size: 13px; }
.bar-bottom .sum b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--pos-soft); color: var(--pos); }
.pill.bad { background: var(--neg-soft); color: var(--neg); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

.done-hero { text-align: center; padding: 28px 18px; }
.done-hero .tick { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; background: var(--accent); color: var(--on-accent); }
.done-hero h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 600; text-align: right; }

/* ---------- Admin ---------- */
.top { display: flex; align-items: center; gap: 10px; margin: 2px 0 14px; }
.top h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--surface); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); color: var(--text); flex: none; }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 0; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; position: relative; white-space: nowrap; }
.tabs button.on { color: var(--text); }
.tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); border-radius: 2px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--surface); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 20px; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); }
.appt { display: flex; gap: 12px; padding: 14px 16px; position: relative; }
.appt + .appt::before { content: ""; position: absolute; top: 0; left: 16px; right: 16px; height: 1px; background: var(--line); }
.appt .when { width: 62px; flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.appt .when small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.appt .grow { flex: 1; min-width: 0; }
.appt .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.appt.dim { opacity: .55; }
.appt.block { background: repeating-linear-gradient(-45deg, transparent 0 8px, var(--surface-2) 8px 16px); }
.hours-row { display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hours-row:last-child { border-bottom: 0; }
.hours-row .times-in { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hours-row select { min-height: 38px; padding: 6px 8px; border-radius: 10px; border: 0; background: var(--surface-2); font-size: 14px; }
.edit-row { display: grid; grid-template-columns: 1fr 72px 82px 36px; gap: 6px; margin-bottom: 6px; }
.edit-row .input { min-height: 44px; padding: 8px 10px; font-size: 15px; }
.qr-wrap { background: #fff; border-radius: 18px; padding: 18px; display: grid; place-items: center; }
.qr-wrap img, .qr-wrap canvas { width: 220px !important; height: 220px !important; }
code.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; background: var(--surface-2); padding: 10px 12px; border-radius: 12px; display: block; }
.switch { position: relative; width: 48px; height: 28px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- Sheet, dialog, toast ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 28px 28px 0 0; padding: 6px 18px calc(env(safe-area-inset-bottom) + 22px); animation: up .26s cubic-bezier(.2, .8, .2, 1); }
.sheet::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 4px auto 14px; }
.sheet h2 { margin: 0 0 16px; font-size: 21px; letter-spacing: -.02em; }
@keyframes up { from { transform: translateY(100%); } }
.dialog-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 24px; }
.dialog { background: var(--surface); border-radius: 24px; padding: 22px 20px 18px; width: 100%; max-width: 360px; box-shadow: var(--shadow-lg); }
.dialog h3 { margin: 0 0 8px; font-size: 19px; }
.dialog p { margin: 0 0 18px; color: var(--muted); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 96px); z-index: 50; background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; max-width: calc(100% - 32px); box-shadow: var(--shadow-lg); }
.empty { text-align: center; padding: 30px 18px; color: var(--muted); }
.empty b { color: var(--text); display: block; margin-bottom: 2px; }
.powered { text-align: center; font-size: 12px; color: var(--faint); margin-top: 28px; }
.powered a { text-decoration: underline; }

/* ---------- Print: counter QR poster ---------- */
.poster { display: none; }
@media print {
  body * { visibility: hidden; }
  .poster, .poster * { visibility: visible; }
  .poster { display: block; position: fixed; inset: 0; text-align: center; padding: 60px 40px; font-family: system-ui, sans-serif; color: #000; background: #fff; }
  .poster h1 { font-size: 48px; margin: 0 0 6px; }
  .poster .qr-wrap img, .poster .qr-wrap canvas { width: 360px !important; height: 360px !important; }
}
