/* Restaurant dashboard + login. Works on phones, tablets and laptops. */
:root {
  /* Dark green and white */
  --bg: #f3f7f5; --surface: #fff; --ink: #10261c; --muted: #5d7066; --line: #dde7e1;
  --accent: #154734; --accent-ink: #fff; --accent-soft: #e9f2ed; --danger: #b3261e; --gold: #154734;
  --radius: 14px; --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
h1 { font: 600 28px/1.15 var(--serif); }
h2 { font: 600 22px/1.2 var(--serif); }
h3 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.center-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.spinner.small { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.narrow { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 14px; }
.card.empty { text-align: center; color: var(--muted); padding: 40px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.tight { gap: 2px; }
.row.wrap { flex-wrap: wrap; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; }
.grow { flex: 1; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 14px; }
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  font: 500 14px var(--sans); color: var(--ink); text-decoration: none; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px;
}
.btn:hover { border-color: #b7cabe; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.file-btn { display: inline-flex; flex-direction: row; }
.icon { border: 0; background: none; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px; color: var(--muted); }
.icon:hover:not(:disabled) { background: var(--bg); color: var(--ink); }
.icon:disabled { opacity: .3; cursor: default; }

/* App bar */
.appbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand-mark { font: 600 18px var(--serif); color: var(--accent); display: inline-flex; align-items: center; gap: 8px; }
.brand-mark .logo-mark { width: 1.5em; height: 1.5em; flex: none; }
.appbar { background: var(--accent); color: #fff; border-bottom-color: var(--accent); }
.appbar .brand-mark, .appbar .r-name { color: #fff; }
.appbar .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .35); }
.appbar .btn:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .6); }
.appbar .btn.ghost { border-color: transparent; }
.appbar select { background: #fff; color: var(--ink); border-color: transparent; }
.restaurant-switch { display: flex; align-items: center; gap: 10px; flex: 1 0 auto; }
.restaurant-switch select { width: auto; max-width: 280px; font-weight: 600; padding: 7px 10px; }
.r-name { font-weight: 600; }
.appbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.status-pill[data-s=demo] { background: #fdf0d8; color: #8a5a00; }
.status-pill[data-s=past_due], .status-pill[data-s=cancelled] { background: #fbe4e2; color: var(--danger); }

.tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; font: 500 14px var(--sans); color: var(--muted); padding: 12px 14px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }

.tab-panel { max-width: 1000px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.panel-head p { margin: 4px 0 0; max-width: 560px; }

.links-fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 14px; }
.links-fieldset legend { padding: 0 6px; }
.links-fieldset .show-links { font-weight: 600; margin-top: 4px; }
.links-fieldset > p { margin: 4px 0 10px; }

/* Owner view */
.plan-box { --tone: #2e7d32; --tone-soft: var(--accent-soft); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 12px; }
.plan-box[data-tone="wait"] { --tone: #8a5a00; --tone-soft: #fbf0d9; }
.plan-box[data-tone="off"] { --tone: #5d7066; --tone-soft: #eef1ef; }
.plan-box a { color: var(--accent); font-weight: 600; }
.pb-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pb-icon { width: 40px; height: 40px; border-radius: 999px; background: var(--tone-soft); color: var(--tone); display: flex; align-items: center; justify-content: center; flex: none; }
.pb-icon svg { width: 20px; height: 20px; }
.pb-title { flex: 1 1 220px; min-width: 0; }
.pb-title h3 { margin: 0; font: 600 16px var(--sans); color: var(--ink); }
.pb-title p { margin: 2px 0 0; }
.pb-pill { flex: none; font-size: 12px; font-weight: 600; color: var(--tone); background: var(--tone-soft); border-radius: 999px; padding: 4px 10px; }
.pb-cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 24px; padding-top: 12px; border-top: 1px solid var(--line); }
.pb-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pb-cell span { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.pb-cell strong { color: var(--ink); font-weight: 600; }
.banner { background: #fbe4e2; color: var(--danger); padding: 10px 24px; font-size: 14px; font-weight: 500; }
.banner a, .owner-note a { color: inherit; font-weight: 600; }
.owner-note { font-size: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.owner-note .on-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.owner-note .on-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft, #e2eee7); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.owner-note .on-icon svg { width: 20px; height: 20px; }
.owner-note .on-title { flex: 1 1 220px; min-width: 0; }
.owner-note h3 { margin: 0; font: 600 16px var(--sans); color: var(--ink); }
.owner-note .on-title p { margin: 2px 0 0; overflow-wrap: anywhere; }
.owner-note .on-btn { flex: none; }
.owner-note .on-list { margin: 0; padding: 12px 0 0; border-top: 1px solid var(--line); list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; }
@media (max-width: 600px) { .owner-note .on-list { grid-template-columns: minmax(0, 1fr); } }
.owner-note .on-list li { position: relative; padding-left: 22px; color: var(--ink); }
.owner-note .on-list li::before { content: ""; position: absolute; left: 2px; top: 4px; width: 10px; height: 6px; border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); }
.owner-note .on-foot { margin: 0; font-size: 13px; }

/* Stats strip */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 2fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.stat b { font: 600 24px var(--serif); line-height: 1.1; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.busiest { justify-content: flex-start; gap: 8px; }
.bt-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.bt-head strong { font-size: 14px; color: var(--ink); }
.bt-head span { font-size: 12px; }
.bt-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bt-list li { display: grid; grid-template-columns: 18px minmax(64px, auto) minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13px; }
.bt-rank { width: 18px; height: 18px; border-radius: 999px; background: var(--accent-soft); color: var(--accent) !important; font-size: 11px !important; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.bt-label { color: var(--ink) !important; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-bar { height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.bt-bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.bt-n { color: var(--ink) !important; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; min-width: 2ch; }
.bt-empty { margin: 0; font-size: 13px; color: var(--muted); }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stat.busiest { grid-column: 1 / -1; } }
.billing-state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.billing-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; margin-bottom: 10px; }
.pay-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pay-method { margin: 4px 0 2px; flex-wrap: wrap; }
.pay-method button { padding: 8px 12px; }
.pay-history { margin: 6px 0 10px; font-size: 14px; }
.pay-history table { width: 100%; border-collapse: collapse; }
.pay-history th, .pay-history td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.pay-history th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.pay-history td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pay-history .wrap-x { overflow-x: auto; }
.billing-extra select { width: auto; }
.billing-form .span-all { grid-column: 1 / -1; margin: 0; }
.b-preview { font-size: 15px; }
.billing-extra { border-top: 1px solid var(--line); padding-top: 12px; margin-bottom: 12px; }
.billing-extra input { width: 100px; }
.billing-extra p { margin: 6px 0 0; }
.billing-form input:disabled { background: var(--bg); color: var(--muted); }
#billing-card > p.small { margin: 0; }
@media (max-width: 720px) { .billing-form, .pay-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px) { .billing-form, .pay-form { grid-template-columns: minmax(0, 1fr); } }

/* Menu editor */
.category { padding: 0; overflow: hidden; }
.category.hidden-cat { opacity: .7; }
.cat-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.cat-title { display: flex; align-items: baseline; gap: 10px; }
.cat-title h3 { font: 600 19px var(--serif); }
.item-list { list-style: none; margin: 0; padding: 0; }
.item-row { display: grid; grid-template-columns: 52px 1fr auto auto auto; align-items: center; gap: 14px; padding: 10px 16px 10px 20px; border-bottom: 1px solid var(--line); }
.item-row.sold .item-name, .item-row.sold .thumb { opacity: .5; }
.thumb { width: 52px; height: 52px; border-radius: 10px; background: var(--bg); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-main { border: 0; background: none; text-align: left; padding: 0; cursor: pointer; min-width: 0; font: inherit; color: inherit; display: flex; flex-direction: column; }
.item-main:hover .item-name { text-decoration: underline; }
.item-name { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.item-sub { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-price { font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.tag.special { background: var(--accent-soft); border-color: #c9ddd1; color: var(--accent); }

.switch { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 40px; height: 24px; border-radius: 12px; background: #cbd8d0; position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch em { font-style: normal; font-size: 13px; color: var(--muted); width: 62px; }

.add-cat-row { display: flex; }
.add-row { padding: 12px 16px 14px 20px; background: #f8fbf9; }
.add-dish { border-style: dashed; color: var(--accent); font-weight: 600; }
.add-dish:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Tables */
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.table-card, .general-qr { display: flex; gap: 18px; align-items: flex-start; }
.qr-box { width: 120px; height: 120px; flex: none; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.table-info { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.table-info .link { font-size: 12px; }
.general-qr h3 { margin-bottom: 4px; }
.general-qr p { margin: 0 0 8px; }

/* Details */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span2 { grid-column: 1 / -1; }
.logo-edit, .photo-edit { grid-column: 1 / -1; display: flex; gap: 16px; align-items: center; }
.logo-preview { width: 72px; height: 72px; border-radius: 50%; border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; background: var(--bg); flex: none; }
.logo-preview img, .photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.logo-preview span { font: 600 30px var(--serif); color: var(--accent); }
.photo-preview { width: 96px; height: 96px; border-radius: 12px; border: 1px dashed var(--line); overflow: hidden; display: grid; place-items: center; background: var(--bg); flex: none; }
.photo-edit p { margin: 6px 0 0; }
#invite-form input { flex: 1; }
.login-status { display: flex; align-items: center; gap: 8px; margin: 12px 0; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c9c1b4; flex: none; }
.dot.ok { background: #2e7d32; } .dot.wait { background: #d9a441; }
#admin-card { display: flex; flex-direction: column; gap: 12px; border-color: #c9ddd1; background: #f6faf7; }
#admin-card select { max-width: 280px; }
#people-card p { margin: 4px 0 0; }

/* Onboarding */
.slug-field { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.slug-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.slug-prefix { padding: 10px 0 10px 12px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.slug-field input { border: 0; box-shadow: none !important; padding-left: 2px; }

/* Dialogs */
.modal { border: 0; border-radius: 18px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); }
.modal::backdrop { background: rgba(20, 16, 10, .45); }
.modal form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 0; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); }
.small-modal { width: min(420px, calc(100vw - 24px)); }
.small-modal h2 { font-size: 20px; margin-bottom: 6px; }
.small-modal p { margin: 0 0 10px; }
.special-dates { margin-top: 8px; gap: 12px; }
.special-dates label { flex: 1; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 100; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.admin-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.admin-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg); border-radius: 10px; min-width: 0; }
.admin-list .grow { min-width: 0; overflow-wrap: anywhere; }
#admin-form .row input { flex: 1; }

/* Login */
.stack { display: flex; flex-direction: column; gap: 14px; }
.login-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font: 500 14px var(--sans); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.login-card #msg { margin-top: 14px; }
.login-card h1 { margin-bottom: 4px; }
.login-card .brand-mark { margin-bottom: 18px; }
.sent { background: var(--accent-soft); border-radius: 12px; padding: 14px; }

/* Phones */
@media (max-width: 720px) {
  .appbar, .tabs { padding-left: 14px; padding-right: 14px; }
  .tab-panel { padding: 16px 12px; }
  .item-row { grid-template-columns: 44px 1fr auto; gap: 10px; padding: 10px 12px; }
  .thumb { width: 44px; height: 44px; }
  .item-row .switch { grid-column: 2 / 3; }
  .item-row .switch em { width: auto; }
  .item-row .move { grid-column: 3; grid-row: 2; justify-self: end; }
  .add-row { padding: 12px; }
  .add-dish { width: 100%; }
  .table-grid { grid-template-columns: 1fr; }
  .table-card { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .cat-head { padding: 12px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat.busiest { grid-column: 1 / -1; }
}

.qr-big { display: block; width: min(320px, 100%); margin: 0 auto 12px; image-rendering: pixelated; }

/* Segmented choice (billing: how they pay) */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: 7px; font: 500 14px var(--sans); color: var(--ink); cursor: pointer; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
