/* Giao diện chung cho trang giới thiệu, đăng ký, quản lý chủ quán và chủ hệ thống */
:root {
  --brand: #d9381e; --brand-d: #b02a14; --brand-l: #fde7e1;          /* cùng bộ màu với trang chủ "tờ bill" */
  --bg: #f6f1e7; --card: #fffdf8; --paper: #fffdf8; --line: #ded5c4; --text: #1f1b16; --ink: #1f1b16; --mute: #6b6258;
  --sans: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, 'Courier New', monospace;
  --ok: #15803d; --warn: #b45309; --bad: #dc2626; --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.muted { color: var(--mute); }
.small { font-size: 13px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 160px; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.btn { appearance: none; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #f5f5f4; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
label.f { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--text); }
.input:focus { outline: 2px solid var(--brand-l); border-color: var(--brand); }
textarea.input { min-height: 70px; resize: vertical; }
.help { font-size: 12px; color: var(--mute); margin-top: 3px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #f5f5f4; color: var(--mute); }
.badge.new { background: #fee2e2; color: var(--bad); } .badge.ok { background: #dcfce7; color: var(--ok); } .badge.warn { background: #fef3c7; color: var(--warn); } .badge.blue { background: #dbeafe; color: #1d4ed8; }
.err { color: var(--bad); font-weight: 600; font-size: 14px; min-height: 1.2em; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d6d3d1; border-radius: 999px; transition: .15s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); } .switch input:checked + span::before { transform: translateX(18px); }

/* trang giới thiệu */
.nav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.nav .wrap { display: flex; justify-content: space-between; align-items: center; height: 58px; }
.logo { font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; }
.logo b { color: var(--brand); }
.hero { padding: 48px 0 28px; text-align: center; }
.hero h1 { font-size: clamp(26px, 5vw, 42px); }
.hero p { font-size: 17px; color: var(--mute); max-width: 640px; margin: 0 auto 20px; }
.feat { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 28px 0; }
.feat .card h3 { font-size: 16px; }
.section { padding: 28px 0; }
#map, #smap { height: 260px; border-radius: 12px; border: 1px solid var(--line); }
.sugg { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #fff; max-height: 180px; overflow: auto; }
.sugg li { padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--line); }
.sugg li:hover { background: var(--brand-l); }
footer.site { padding: 28px 0 40px; color: var(--mute); font-size: 13px; text-align: center; }

/* trang quản lý */
.top { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 54px; gap: 8px; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--mute); border-radius: 8px; cursor: pointer; position: relative; }
.tabs button.on { background: var(--brand-l); color: var(--brand); }
.tabs .dot { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; padding: 0 4px; }
@media (max-width: 720px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); justify-content: space-around; padding: 4px; z-index: 40; }
  .tabs button { flex: 1; font-size: 12px; padding: 8px 2px; }
  main.pad { padding-bottom: 80px; }
}
main.pad { padding: 16px 16px 40px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chips button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.order { border-left: 4px solid var(--line); }
.order.s-new { border-left-color: var(--bad); } .order.s-confirmed, .order.s-making { border-left-color: #f59e0b; } .order.s-delivering { border-left-color: #3b82f6; } .order.s-done { border-left-color: var(--ok); } .order.s-cancelled { opacity: .6; }
.order pre { white-space: pre-wrap; margin: 8px 0; font: inherit; background: #fafaf9; border-radius: 8px; padding: 8px 10px; }
.item { display: flex; gap: 12px; align-items: center; }
.item img { width: 54px; height: 54px; object-fit: cover; border-radius: 10px; background: #f5f5f4; flex: none; }
.item .grow { flex: 1; min-width: 0; } .item .grow b, .item .grow span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .grow b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }   /* tên món dài xuống 2 dòng thay vì bị cắt */
.stickyhead { position: sticky; top: 54px; z-index: 20; background: var(--bg); padding: 10px 0; margin-bottom: 4px; }   /* nút Lưu luôn thấy được khi cuộn trang dài */
.bar { height: 8px; background: #f5f5f4; border-radius: 99px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--brand); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px; }
@media (min-width: 720px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #1c1917; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 200; font-weight: 600; }
.kv { display: flex; gap: 6px; margin-bottom: 6px; } .kv input:first-child { flex: 2; } .kv input:nth-child(2) { flex: 1; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; } table.t th, table.t td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }

/* chọn giao diện menu (trang quản lý) */
.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.theme { display: block; border: 2px solid var(--line); border-radius: 14px; padding: 8px; cursor: pointer; background: #fff; }
.theme input { position: absolute; opacity: 0; pointer-events: none; }
.theme.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-l); }
.theme b { display: block; margin: 2px 0; }
.tprev { height: 96px; border-radius: 10px; margin-bottom: 6px; position: relative; overflow: hidden; border: 1px solid var(--line); }
.tprev.am-ap { background: #faf9f6; } .tprev.tuoi-mat { background: #fff; } .tprev.toi-sang { background: #1c1917; }

/* icon (Lucide) */
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -4px; }
.btn .ic { width: 16px; height: 16px; vertical-align: -3px; }
.btn.sm .ic { width: 15px; height: 15px; }
.feat h3 { display: flex; align-items: center; gap: 8px; } .feat h3 .ic { color: var(--brand); }
.tabs button { display: inline-flex; align-items: center; gap: 6px; }
.tabs button .ic { width: 18px; height: 18px; vertical-align: 0; }
.sugg li .ic { color: var(--brand); vertical-align: -2px; margin-right: 2px; }
@media (max-width: 720px) {
  .tabs button { flex-direction: column; gap: 2px; font-size: 11px; }
  .tabs button .ic { width: 22px; height: 22px; }
  .tabs .dot { top: 0; right: 18%; }
}

/* nút về trang chủ Menu Link ở các trang quản lý */
.homelink { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--mute); text-decoration: none; padding: 7px 10px; border-radius: 8px; white-space: nowrap; order: 3; }
.homelink:hover { background: var(--brand-l); color: var(--brand); }
.homelink .ic { width: 18px; height: 18px; vertical-align: 0; }
.homelink.back { order: 0; padding-left: 0; }
@media (max-width: 720px) { .top .homelink { margin-left: auto; } .top .tabs { order: 2; } }

/* thanh đầu trang: không bao giờ xếp chồng, kể cả màn hình rất hẹp */
.nav .wrap { height: auto; min-height: 58px; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
.nav .row { flex-wrap: nowrap; gap: 6px; }
.nav .btn, .nav .logo { white-space: nowrap; }
.feat .card { text-align: left; }
@media (max-width: 400px) {
  .nav .btn.sm { padding: 6px 10px; font-size: 12px; }
  .logo { font-size: 16px; }
  .hide-s { display: none; }
  .hero { padding-top: 28px; } .hero p { font-size: 15px; }
}

html { scroll-padding-top: 72px; }

/* chọn vị trí quán: GPS + dán link Google Maps */
.locopts { margin: 8px 0; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; background: #fffaf0; }
.locopts > .btn { width: 100%; justify-content: center; }
.locopts .or { text-align: center; font-size: 12px; color: var(--mute); margin: 10px 0 6px; }
.btn.loading { opacity: .6; cursor: progress; }
.locopts .btn { white-space: nowrap; }

/* trang quản trị trên điện thoại: bảng -> thẻ */
@media (max-width: 720px) {
  .card:has(> table.cards) { padding: 0; border: 0; background: none; box-shadow: none; overflow: visible !important; }
  table.cards, table.cards tbody { display: block; }
  table.cards tr.hd { display: none; }
  table.cards tr { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; margin-bottom: 10px; }
  table.cards td { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; border: 0; border-bottom: 1px dashed var(--line); padding: 8px 0; text-align: right; word-break: break-word; }
  table.cards td:last-child { border-bottom: 0; }
  table.cards td::before { content: attr(data-l); flex: none; color: var(--mute); font-size: 12px; font-weight: 700; text-align: left; }
  table.cards td:first-child { display: block; text-align: left; font-size: 15px; }
  table.cards td:first-child::before { display: none; }
  table.cards td:last-child:has(.row) { display: block; text-align: left; }
  table.cards td:last-child:has(.row)::before { display: block; margin-bottom: 6px; }
  table.cards .row { gap: 8px; }
  table.cards .btn.sm { padding: 9px 12px; font-size: 13px; }
  .row.between { gap: 4px 12px; }
}

/* Cài đặt: các mục gập lại cho đỡ dài; giao diện chọn bằng ảnh thật */
details.sec { padding: 0; }
details.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary h3 { margin: 0; font-size: 16px; }
details.sec > summary::after { content: ''; width: 9px; height: 9px; border-right: 2px solid var(--mute); border-bottom: 2px solid var(--mute); transform: rotate(45deg); transition: transform .15s; flex: none; margin-right: 4px; }
details.sec[open] > summary::after { transform: rotate(-135deg); }
details.sec > .stack { padding: 0 16px 16px; }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme { display: block; border: 2px solid var(--line); border-radius: 12px; padding: 8px; background: var(--paper); cursor: pointer; position: relative; }
.theme.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-l); }
.theme input { position: absolute; opacity: 0; pointer-events: none; }
.theme .tshot { width: 100%; height: auto; aspect-ratio: 3/4; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 8px; }
.theme b { display: block; font-size: 14px; }
.theme .small { font-size: 12px; line-height: 1.35; }
@media (max-width: 520px) { .theme .small { display: none; } .theme b { font-size: 13px; } }

/* quản lý thực đơn */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; flex: 1; min-width: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 7px 13px; font: 600 13px/1 var(--sans); color: var(--text); cursor: pointer; white-space: nowrap; }
.chip i { font-style: normal; color: var(--mute); font-weight: 600; margin-left: 3px; }
.chip.on { background: var(--text); color: var(--paper); border-color: var(--text); } .chip.on i { color: inherit; opacity: .7; }
.chip.sm { padding: 6px 11px; font-size: 12px; }
.selbar { position: sticky; top: 54px; z-index: 15; background: var(--paper); border: 1px solid var(--text); border-radius: 12px; padding: 10px; margin-bottom: 10px; display: grid; gap: 8px; box-shadow: 0 6px 16px -10px rgba(0,0,0,.4); }
.item.picked { border-color: var(--brand); background: var(--brand-l); }
.item .pick { width: 20px; height: 20px; flex: none; accent-color: var(--brand); }
.item .grow span { white-space: normal; }

/* việc cần làm cho quán mới + khối QR */
.onboard { border: 1px dashed var(--text); background: var(--paper); margin-bottom: 12px; }
.onboard .step { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--text); padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.onboard .step i { flex: none; width: 24px; height: 24px; border: 2px solid var(--text); border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 14px; }
.onboard .step.ok i { background: var(--ok); border-color: var(--ok); color: #fff; }
.onboard .step.ok b { text-decoration: line-through; color: var(--mute); }
.onboard .step small { display: block; color: var(--mute); font-size: 12px; line-height: 1.35; }
.qrbox { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; border-top: 1px dashed var(--line); padding-top: 12px; }
.qrbox #qr-box { width: 148px; height: 148px; flex: none; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.qrbox #qr-box svg { display: block; width: 100%; height: 100%; }
.qrbox > .stack { flex: 1 1 180px; }

/* Hộp nhập (thêm món, thêm nhiều món…): nền phía sau mờ đi và KHÔNG cuộn được, để tập trung vào việc đang nhập */
.overlay { background: rgba(31,27,22,.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overscroll-behavior: contain; }
.sheet { background: var(--paper); overscroll-behavior: contain; box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); }
body:has(.overlay:not(.hidden)) { overflow: hidden; }

/* Chọn giao diện: viền "đang chọn" đi theo ô vừa bấm (không phụ thuộc lúc trang vừa vẽ) */
.theme.on:not(:has(input:checked)) { border-color: var(--line); box-shadow: none; }
.theme:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-l); }
.theme:has(input:checked) b::after { content: ' ✓'; color: var(--brand); }

/* danh mục */
.chip.dim { opacity: .55; text-decoration: line-through; }
.chip.manage { border-style: dashed; color: var(--brand); background: transparent; }
.catpick .newcat { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.catrow { display: grid; gap: 10px; padding: 12px; }
.catrow.off { opacity: .7; background: #f4efe4; }
.catrow .btn[disabled] { opacity: .35; }

/* gia hạn */
.mono { font-family: var(--mono); }
.billqr { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.billqr img { width: 220px; height: 220px; border: 1px solid var(--line); border-radius: 12px; background: #fff; flex: none; }
.expiry { display: block; padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; border: 1px dashed var(--warn); background: #fef3c7; color: var(--text); text-decoration: none; }
.expiry.bad { border-color: var(--bad); background: #fee2e2; }
