:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #e85d04;
  --primary-dark: #c44d00;
  --green: #16a34a;
  --red: #dc2626;
  --blue: #2563eb;
  --yellow: #ca8a04;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
h1, h2, h3, h4 { margin: 0 0 .5rem; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 1rem; }

button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: .5rem .9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  justify-content: center;
}
button:hover { background: #f3f4f6; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #15803d; }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: #b91c1c; }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { background: #1d4ed8; }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }

input, select, textarea {
  font: inherit;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
textarea { resize: vertical; min-height: 60px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .75rem; }
.check { display: flex; align-items: center; gap: .4rem; color: var(--text); font-size: .95rem; }
.check input { width: auto; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.badge {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: #eef2f7;
  color: #374151;
}
.badge-pending { background: #fee2e2; color: #991b1b; }
.badge-preparing { background: #fef3c7; color: #92400e; }
.badge-ready { background: #dcfce7; color: #166534; }
.badge-served { background: #dbeafe; color: #1e40af; }
.badge-cancelled { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }
.badge-help { background: #fde68a; color: #78350f; }

.veg, .nonveg {
  display: inline-block; width: 14px; height: 14px; border: 2px solid; border-radius: 3px; position: relative; vertical-align: middle;
}
.veg { border-color: var(--green); }
.nonveg { border-color: var(--red); }
.veg::after, .nonveg::after {
  content: ''; position: absolute; inset: 2px; border-radius: 50%;
}
.veg::after { background: var(--green); }
.nonveg::after { background: var(--red); }

/* Top bar */
.topbar {
  background: #1f2430;
  color: #fff;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.topbar button { background: transparent; color: #fff; border-color: #4b5563; }
.topbar button:hover { background: #374151; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--red); display: inline-block; }
.conn.on { background: #22c55e; }

/* Tabs */
.tabs { display: flex; gap: .25rem; background: #fff; border-bottom: 1px solid var(--border); padding: 0 1rem; overflow-x: auto; position: sticky; top: 52px; z-index: 19; }
.tabs button { border: none; border-bottom: 3px solid transparent; border-radius: 0; padding: .8rem 1rem; white-space: nowrap; background: none; }
.tabs button.active { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; }
.tab-count { background: var(--red); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; margin-left: .25rem; }

main.container { padding: 1rem; max-width: 1400px; margin: 0 auto; }

/* Table */
table.data { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.data th, table.data td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { background: #f9fafb; font-size: .8rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
table.data tr:last-child td { border-bottom: none; }
.num { text-align: right !important; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; padding: 1.25rem; }
.modal-head { display: flex; align-items: center; margin-bottom: 1rem; }
.modal-head h3 { margin: 0; flex: 1; }

/* Toasts */
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.toast { background: #1f2430; color: #fff; padding: .6rem 1rem; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.2); transition: opacity .4s; }
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-warn { background: var(--yellow); }
.toast.hide { opacity: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: .2rem; }

/* Admin table grid */
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.tbl-card { border-left: 5px solid #d1d5db; cursor: pointer; transition: transform .1s; }
.tbl-card:hover { transform: translateY(-2px); }
.tbl-card.occupied { border-left-color: var(--blue); }
.tbl-card.alert { border-left-color: var(--red); animation: pulse 1.2s infinite; }
.tbl-card.inactive { opacity: .5; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); } 50% { box-shadow: 0 0 0 6px rgba(220,38,38,0); } }

.help-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; margin-bottom: .5rem; }

/* Kitchen */
.kitchen-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .kitchen-cols { grid-template-columns: 1fr; } }
.kcol h2 { font-size: 1rem; display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-radius: 8px; color: #fff; }
.kcol.pending h2 { background: var(--red); }
.kcol.preparing h2 { background: var(--yellow); }
.kcol.ready h2 { background: var(--green); }
.ticket { margin-bottom: .75rem; border-top: 4px solid var(--border); }
.ticket.pending { border-top-color: var(--red); }
.ticket.preparing { border-top-color: var(--yellow); }
.ticket.ready { border-top-color: var(--green); }
.ticket.late .ticket-time { color: var(--red); font-weight: 700; }
.ticket-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .5rem; }
.ticket-head .tname { font-size: 1.25rem; font-weight: 800; }
.ticket ul { list-style: none; padding: 0; margin: 0 0 .75rem; }
.ticket li { padding: .3rem 0; border-bottom: 1px dashed var(--border); }
.ticket li .qty { font-weight: 800; margin-right: .4rem; }
.ticket .inote { color: var(--red); font-size: .85rem; margin-left: 1.6rem; }
.onote { background: #fef2f2; color: #991b1b; padding: .4rem .6rem; border-radius: 6px; margin-bottom: .6rem; font-size: .9rem; }

/* Customer */
.c-header { background: linear-gradient(135deg, var(--primary), #f48c06); color: #fff; padding: 1.25rem 1rem 1rem; }
.c-header h1 { font-size: 1.4rem; margin: 0; }
.c-cats { display: flex; gap: .5rem; overflow-x: auto; padding: .75rem 1rem; background: #fff; position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--border); }
.c-cats button { white-space: nowrap; border-radius: 999px; }
.c-cats button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.c-menu { padding: 1rem; padding-bottom: 140px; max-width: 760px; margin: 0 auto; }
.c-menu h2 { font-size: 1.1rem; margin: 1.25rem 0 .75rem; scroll-margin-top: 70px; }
.mitem { display: flex; gap: .75rem; padding: .9rem; margin-bottom: .75rem; }
.mitem img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; flex-shrink: 0; background: #eee; }
.mitem .info { flex: 1; min-width: 0; }
.mitem .name { font-weight: 700; }
.mitem .desc { color: var(--muted); font-size: .85rem; margin: .25rem 0 .4rem; }
.mitem.unavailable { opacity: .55; }
.qty-ctl { display: inline-flex; align-items: center; border: 1px solid var(--primary); border-radius: 8px; overflow: hidden; }
.qty-ctl button { border: none; border-radius: 0; color: var(--primary); font-weight: 800; padding: .3rem .7rem; background: #fff; }
.qty-ctl span { min-width: 1.8rem; text-align: center; font-weight: 700; }
.add-btn { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.c-bottom { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--border); padding: .6rem 1rem; display: flex; gap: .5rem; z-index: 30; box-shadow: 0 -2px 10px rgba(0,0,0,.06); }
.c-bottom button { flex: 1; padding: .8rem; font-weight: 700; }
.help-fab { position: fixed; right: 1rem; bottom: 80px; z-index: 31; border-radius: 999px; padding: .8rem 1.1rem; background: var(--red); color: #fff; border: none; box-shadow: 0 4px 14px rgba(220,38,38,.4); font-weight: 700; }
.help-fab:hover { background: #b91c1c; }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 760px; max-height: 85vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 1rem 1rem 1.5rem; }
.sheet-head { display: flex; align-items: center; margin-bottom: .75rem; }
.sheet-head h3 { flex: 1; margin: 0; }
.line { display: flex; gap: .5rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.totals { margin-top: .75rem; }
.totals div { display: flex; justify-content: space-between; padding: .2rem 0; }
.totals .grand { font-weight: 800; font-size: 1.1rem; border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .3rem; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.help-grid button { padding: 1rem .5rem; flex-direction: column; font-size: .95rem; }
.help-grid button .ico { font-size: 1.6rem; }
.progress { display: flex; gap: 4px; margin: .5rem 0; }
.progress span { flex: 1; height: 6px; border-radius: 3px; background: var(--border); }
.progress span.done { background: var(--green); }
.center-msg { text-align: center; padding: 3rem 1rem; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-wrap .card { width: 100%; max-width: 360px; padding: 1.5rem; }
.role-switch { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.role-switch button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* QR print */
.qr-print-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.qr-card { text-align: center; padding: 1rem; border: 2px dashed var(--border); border-radius: var(--radius); background: #fff; page-break-inside: avoid; }
.qr-card img { width: 200px; height: 200px; }
@media print {
  .no-print, .topbar, .tabs { display: none !important; }
  body { background: #fff; }
  main.container { padding: 0; }
}
.qr-card.inactive { opacity: .5; }

/* ---------- v2 UX additions ---------- */
.confirm-bg { z-index: 300; animation: fade .15s; }
.confirm-box { max-width: 400px; animation: pop .18s ease-out; }
.confirm-box p { color: var(--muted); margin: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
@keyframes slideup { from { transform: translateY(100%); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
.bump { animation: bump .35s ease-out; }
.sheet { animation: slideup .22s ease-out; }
.modal { animation: pop .18s ease-out; }
.toast { animation: pop .2s ease-out; }

/* Order tracker with labelled steps */
.tracker { display: flex; margin: .75rem 0 .5rem; position: relative; }
.tracker .step { flex: 1; text-align: center; position: relative; font-size: .72rem; color: var(--muted); }
.tracker .step .dot { width: 30px; height: 30px; margin: 0 auto .25rem; border-radius: 50%; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: .95rem; position: relative; z-index: 1; transition: background .3s; }
.tracker .step::before { content: ''; position: absolute; top: 15px; left: -50%; width: 100%; height: 3px; background: var(--border); }
.tracker .step:first-child::before { display: none; }
.tracker .step.done .dot { background: #bbf7d0; }
.tracker .step.done::before, .tracker .step.current::before { background: var(--green); }
.tracker .step.current .dot { background: var(--green); box-shadow: 0 0 0 4px #bbf7d0; animation: pulse-green 1.6s infinite; }
.tracker .step.current { color: var(--text); font-weight: 700; }
.tracker .step.done { color: var(--text); }
@keyframes pulse-green { 50% { box-shadow: 0 0 0 7px rgba(34,197,94,.15); } }
.status-msg { font-size: .9rem; background: #f0fdf4; color: #166534; padding: .45rem .65rem; border-radius: 8px; }
.status-msg.cancelled { background: #f3f4f6; color: var(--muted); }

/* Menu item interactivity */
.mitem { cursor: pointer; transition: box-shadow .15s, transform .1s; }
.mitem:active { transform: scale(.99); }
.mitem.in-cart { box-shadow: 0 0 0 2px var(--primary); }
.item-hero { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; margin-bottom: .75rem; }
.c-cats button { transition: background .15s; }
.cart-pill { background: rgba(255,255,255,.25); border-radius: 999px; padding: 0 .5rem; margin-left: .25rem; }

/* Help options */
.help-grid button { position: relative; min-height: 96px; transition: transform .1s, border-color .15s; }
.help-grid button:active { transform: scale(.97); }
.help-grid button.requested { border-color: var(--green); background: #f0fdf4; }
.help-grid .price-tag { position: absolute; top: 6px; right: 8px; background: var(--primary); color: #fff; font-size: .7rem; padding: 0 .4rem; border-radius: 999px; }
.help-grid .free-tag { position: absolute; top: 6px; right: 8px; background: #dcfce7; color: #166534; font-size: .7rem; padding: 0 .4rem; border-radius: 999px; }
.open-req { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; border-radius: 8px; background: #fffbeb; border: 1px solid #fde68a; margin-bottom: .5rem; font-size: .9rem; }

/* Admin ready-to-serve panel */
.serve-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; margin-bottom: .5rem; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }
.empty { text-align: center; color: var(--muted); padding: 1rem; font-size: .9rem; }
.tbl-card .elapsed { font-size: .75rem; color: var(--muted); }
.kcol.served h2 { background: var(--blue); }

/* Kitchen item tick-off */
.ticket li { cursor: pointer; user-select: none; }
.ticket li.done { text-decoration: line-through; color: var(--muted); }
.ticket li.done .qty::before { content: '✓ '; color: var(--green); }
.ticket .big-btn { flex: 1; padding: .7rem; font-weight: 700; font-size: 1rem; }

/* Orders board status chips */
.status-chips { display: flex; gap: .25rem; flex-wrap: wrap; }
.status-chips button { padding: .2rem .55rem; font-size: .78rem; border-radius: 999px; }
.status-chips button.on.pending { background: #fee2e2; border-color: #fca5a5; }
.status-chips button.on.preparing { background: #fef3c7; border-color: #fcd34d; }
.status-chips button.on.ready { background: #dcfce7; border-color: #86efac; }
.status-chips button.on.served { background: #dbeafe; border-color: #93c5fd; }
.status-chips button.on.cancelled { background: #e5e7eb; }
.help-opt-row { display: grid; grid-template-columns: 56px 1fr 110px auto auto; gap: .5rem; align-items: center; margin-bottom: .5rem; }
@media (max-width: 600px) { .help-opt-row { grid-template-columns: 48px 1fr 80px; } }

/* =========================================================
   v3 – backgrounds, motion and responsive layout
   ========================================================= */
:root { --topbar-h: 56px; --pattern: url('/img/pattern.svg'); }
html { -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; }
img { max-width: 100%; }

/* Soft food-pattern backdrop for staff screens */
body.bg-pattern::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--pattern) repeat, radial-gradient(circle at 10% 0%, #fff4ec 0, transparent 45%), radial-gradient(circle at 90% 100%, #eef4ff 0, transparent 45%);
  background-size: 360px, auto, auto; opacity: .55;
  filter: grayscale(.2);
}
body.bg-pattern::after { content: ''; position: fixed; inset: 0; z-index: -1; background: rgba(245,246,248,.86); pointer-events: none; }

.topbar { min-height: var(--topbar-h); background: linear-gradient(90deg, #1f2430, #2b2f3d 60%, #3a2a24); box-shadow: 0 2px 10px rgba(0,0,0,.15); flex-wrap: wrap; }
.topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tabs { top: var(--topbar-h); backdrop-filter: blur(8px); background: rgba(255,255,255,.92); }
.tabs .ti { font-size: 1.05rem; }

/* Entrance animations */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes flash { 0% { box-shadow: 0 0 0 3px rgba(232,93,4,.65); } 100% { box-shadow: var(--shadow); } }
@keyframes shake { 0%,100% { transform: rotate(0); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 80% { transform: rotate(5deg); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes shimmer { 100% { background-position: -200% 0; } }
@keyframes gradientMove { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
.rise { animation: rise .35s ease-out both; animation-delay: calc(var(--i, 0) * 40ms); }
.flash { animation: flash 1.6s ease-out; }
.view-enter { animation: rise .25s ease-out; }
.card.hoverable { transition: transform .15s, box-shadow .15s; }
.card.hoverable:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.08); }
.stat { position: relative; overflow: hidden; }
.stat::after { content: attr(data-icon); position: absolute; right: .6rem; bottom: -.4rem; font-size: 2.6rem; opacity: .12; }
.skeleton { border-radius: var(--radius); min-height: 90px; background: linear-gradient(90deg, #eceef1 25%, #f6f7f9 50%, #eceef1 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
button { transition: background .15s, transform .08s, box-shadow .15s; }
button:active:not(:disabled) { transform: scale(.97); }
.badge-help { animation: shake 1s ease-in-out 2; }

/* Order / bill codes */
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .02em; background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; border-radius: 6px; padding: 0 .35rem; font-size: .82rem; white-space: nowrap; }
.code.bill { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.copyable { cursor: copy; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: .5rem 0; border-left: 3px solid var(--border); }
.timeline li { position: relative; padding: .2rem 0 .6rem 1rem; }
.timeline li::before { content: ''; position: absolute; left: -8px; top: .45rem; width: 13px; height: 13px; border-radius: 50%; background: var(--green); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--green); }
.timeline li.cancelled::before { background: var(--muted); box-shadow: 0 0 0 1px var(--muted); }
.tracker .step .t { display: block; font-size: .65rem; color: var(--muted); font-weight: 400; }

/* Responsive data table -> stacked cards on small screens */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data tbody tr { transition: background .12s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: #fff7ed; }
.layout-menu { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 1rem; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; }
.filters .grow { flex: 1; min-width: 180px; }

/* Customer – hero, thumbs, animations */
.c-header { position: relative; overflow: hidden; padding: 1.5rem 1rem 1.1rem; background: linear-gradient(135deg, #e85d04, #f48c06, #dc2f02); background-size: 200% 200%; animation: gradientMove 12s ease infinite; }
.c-header::before { content: ''; position: absolute; inset: 0; background: var(--pattern); background-size: 260px; opacity: .18; pointer-events: none; }
.c-header.has-cover { background: #222; animation: none; }
.c-header.has-cover::before { background: var(--cover) center/cover no-repeat; opacity: 1; animation: kenburns 20s ease-in-out infinite alternate; }
.c-header.has-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.7)); }
.c-header > * { position: relative; z-index: 1; }
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.12); } }
.c-header .hero-emoji { position: absolute; right: 1rem; top: 1rem; font-size: 3rem; animation: float 3s ease-in-out infinite; z-index: 1; }
.mthumb { width: 96px; height: 96px; flex-shrink: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; background: linear-gradient(135deg, #fff1e6, #ffe0c7); }
.mitem img, .mthumb { transition: transform .25s; }
.mitem:hover img, .mitem:hover .mthumb { transform: scale(1.05) rotate(-1deg); }
.mitem.reveal { opacity: 0; transform: translateY(14px); }
.mitem.reveal.in { opacity: 1; transform: none; transition: opacity .4s ease-out, transform .4s ease-out; }
.help-fab.pending { animation: float 2s ease-in-out infinite; background: var(--yellow); box-shadow: 0 4px 14px rgba(202,138,4,.45); }
.item-hero-emoji { height: 160px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 5rem; background: linear-gradient(135deg, #fff1e6, #ffd6b3); margin-bottom: .75rem; }
.bill-box { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .5rem .75rem; background: #eff6ff; border-radius: 8px; margin-bottom: .75rem; font-size: .9rem; }

/* Login */
.login-wrap { background: linear-gradient(135deg, #1f2430, #3a2a24, #e85d04); background-size: 300% 300%; animation: gradientMove 14s ease infinite; position: relative; overflow: hidden; }
.login-wrap::before { content: ''; position: absolute; inset: 0; background: var(--pattern); background-size: 300px; opacity: .14; }
.login-wrap .card { position: relative; animation: pop .35s ease-out; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-logo { font-size: 2.6rem; animation: float 3s ease-in-out infinite; display: inline-block; }

/* Kitchen ticket entrance */
.ticket.new-ticket { animation: rise .35s ease-out, flash 2s ease-out; }

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
  .kitchen-cols { grid-template-columns: repeat(3, minmax(260px, 1fr)); overflow-x: auto; }
}

/* ---------- Phone / small tablet ---------- */
@media (max-width: 760px) {
  :root { --topbar-h: 52px; }
  body { font-size: 15px; }
  main.container { padding: .75rem; }
  .topbar { padding: .5rem .75rem; gap: .5rem; }
  .topbar h1 { font-size: 1rem; flex: 1; }
  .topbar .hide-sm, .hide-sm { display: none !important; }
  .topbar button { padding: .4rem .55rem; }

  /* Admin tabs become a bottom navigation bar */
  .tabs { position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 40; padding: 0 0 env(safe-area-inset-bottom); justify-content: space-around; border-top: 1px solid var(--border); border-bottom: none; box-shadow: 0 -4px 14px rgba(0,0,0,.06); }
  .tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0; padding: .45rem .2rem; font-size: .68rem; border-bottom: none; border-top: 3px solid transparent; min-width: 0; position: relative; }
  .tabs button.active { border-top-color: var(--primary); border-bottom-color: transparent; }
  .tabs .ti { font-size: 1.25rem; }
  .tabs .tab-count { position: absolute; top: 2px; right: 18%; margin: 0; }
  body.has-bottom-nav main.container { padding-bottom: 84px; }
  body.has-bottom-nav #toasts { bottom: 76px; }

  .stats { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .stat .value { font-size: 1.25rem; }
  .stat .label { font-size: .75rem; }
  .table-grid { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .layout-menu { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .panel-grid { gap: .75rem; }
  .help-item, .serve-item { flex-wrap: wrap; }
  .filters input, .filters select, .filters .grow { flex: 1 1 140px; width: 100%; }

  table.data.responsive thead { display: none; }
  table.data.responsive, table.data.responsive tbody, table.data.responsive tr, table.data.responsive td { display: block; width: 100%; }
  table.data.responsive { background: transparent; box-shadow: none; }
  table.data.responsive tr { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: .6rem; padding: .4rem .2rem; }
  table.data.responsive td { border: none; padding: .3rem .75rem; display: flex; gap: .75rem; justify-content: space-between; text-align: right; }
  table.data.responsive td::before { content: attr(data-label); font-size: .72rem; text-transform: uppercase; color: var(--muted); text-align: left; flex-shrink: 0; padding-top: .1rem; }
  table.data.responsive td.full { display: block; text-align: left; }
  table.data.responsive td.full::before { display: block; margin-bottom: .2rem; }
  table.data.responsive td:empty { display: none; }

  /* Modals become full-height bottom sheets */
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { max-width: 100% !important; width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; animation: slideup .25s ease-out; padding: 1rem; }
  .confirm-bg { align-items: center; padding: 1rem; }
  .confirm-box { border-radius: var(--radius); }

  .kitchen-cols { grid-template-columns: 1fr; overflow: visible; }
  .kcol h2 { position: sticky; top: var(--topbar-h); z-index: 5; }
  .ticket .big-btn { padding: .85rem; }

  .qr-print-grid { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .qr-card { padding: .6rem; }
  .qr-card img { width: 100%; height: auto; }
  .mitem img, .mthumb { width: 84px; height: 84px; }
}

@media (max-width: 380px) {
  .table-grid, .qr-print-grid { grid-template-columns: 1fr; }
  .help-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Large screens: two-column customer menu ---------- */
@media (min-width: 1100px) {
  .c-menu { max-width: 1100px; }
  .c-menu .cat-items { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
  .sheet { max-width: 680px; border-radius: 16px; margin-bottom: 2rem; }
  .sheet-bg { align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  body.bg-pattern::before, body.bg-pattern::after { display: none; }
}

/* Fluid sizing so nothing forces horizontal scroll on narrow phones */
main.container > *, .card, .grid > *, .grid-2 > *, .layout-menu > * { min-width: 0; }
.card { overflow-wrap: anywhere; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.stats { grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); }
.table-grid { grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
.qr-print-grid { grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); }
.filters .grow { min-width: min(180px, 100%); }
.row.wrap > *, .filters > * { min-width: 0; }
@media (max-width: 760px) {
  .code { white-space: normal; overflow-wrap: anywhere; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-grid, .qr-print-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row { flex-wrap: wrap; }
  .modal-head { flex-wrap: wrap; gap: .4rem; }
  .help-opt-row { grid-template-columns: 44px minmax(0, 1fr) 70px; }
  .help-opt-row > :nth-child(4), .help-opt-row > :nth-child(5) { justify-self: start; }
  input, select, textarea { font-size: 16px; } /* prevents iOS zoom-on-focus */
}
@media (max-width: 340px) {
  .stats, .table-grid, .qr-print-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Tablets: give wide tables the full width */
@media (max-width: 1100px) {
  .layout-menu, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .kitchen-cols { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
}
@media (max-width: 760px) {
  .kitchen-cols { grid-template-columns: minmax(0, 1fr); }
}
input.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,.15); animation: shake .4s; }

/* =========================================================
   v4 – colourful motion
   ========================================================= */
:root {
  --rainbow: linear-gradient(90deg, #ff595e, #ff924c, #ffca3a, #8ac926, #1982c4, #6a4c93, #f15bb5, #ff595e);
  --sunset: linear-gradient(135deg, #ff6a00, #ee0979);
  --ocean: linear-gradient(135deg, #00c6ff, #0072ff);
  --lime: linear-gradient(135deg, #a8e063, #56ab2f);
  --grape: linear-gradient(135deg, #b06ab3, #4568dc);
  --gold: linear-gradient(135deg, #f7971e, #ffd200);
}
.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 9999; }
.fx-fly { position: fixed; z-index: 9998; width: 44px; height: 44px; font-size: 32px; display: flex; align-items: center; justify-content: center; pointer-events: none; filter: drop-shadow(0 6px 10px rgba(0,0,0,.25)); }
.fx-fly img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 3px solid #fff; }
.fx-ripple { position: absolute; border-radius: 50%; transform: scale(0); opacity: .45; pointer-events: none; animation: fxRipple .6s ease-out forwards; mix-blend-mode: multiply; }
.btn-primary .fx-ripple, .btn-green .fx-ripple, .btn-blue .fx-ripple, .btn-red .fx-ripple { mix-blend-mode: screen; opacity: .55; }
@keyframes fxRipple { to { transform: scale(1); opacity: 0; } }
.fx-pop { animation: fxPop .6s cubic-bezier(.3,1.6,.5,1); }
@keyframes fxPop { 0% { transform: scale(1); } 35% { transform: scale(1.18) rotate(-3deg); } 65% { transform: scale(.95) rotate(2deg); } 100% { transform: scale(1); } }
.fx-floater { position: absolute; bottom: -40px; pointer-events: none; opacity: .55; animation: fxFloat linear infinite; z-index: 0; filter: saturate(1.3); }
@keyframes fxFloat {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: .65; }
  90% { opacity: .5; }
  100% { transform: translateY(-115vh) rotate(360deg); opacity: 0; }
}
@keyframes hue { to { filter: hue-rotate(360deg); } }
@keyframes rainbowSlide { to { background-position: 200% 0; } }
@keyframes glowPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,89,94,.0), var(--shadow); } 50% { box-shadow: 0 0 22px 4px rgba(255,146,76,.45), var(--shadow); } }
@keyframes wobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-12deg) scale(1.1); } 75% { transform: rotate(12deg) scale(1.1); } }
@keyframes bounceIn { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }

/* Rainbow strip under top bars and above bottom bars */
.topbar { position: sticky; }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--rainbow); background-size: 200% 100%; animation: rainbowSlide 6s linear infinite; }
.c-bottom::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--rainbow); background-size: 200% 100%; animation: rainbowSlide 6s linear infinite; }

/* Primary buttons: moving sunset gradient + glow on hover */
.btn-primary { background: linear-gradient(120deg, #ff6a00, #ee0979, #ff6a00); background-size: 200% 100%; border-color: transparent; transition: background-position .5s, box-shadow .2s, transform .08s; }
.btn-primary:hover:not(:disabled) { background-position: 100% 0; box-shadow: 0 6px 18px rgba(238,9,121,.35); }
.btn-green { background: linear-gradient(120deg, #56ab2f, #16a34a, #a8e063); background-size: 200% 100%; border-color: transparent; }
.btn-green:hover:not(:disabled) { background-position: 100% 0; box-shadow: 0 6px 18px rgba(86,171,47,.35); }
.btn-blue { background: linear-gradient(120deg, #0072ff, #00c6ff, #0072ff); background-size: 200% 100%; border-color: transparent; }
.btn-blue:hover:not(:disabled) { background-position: 100% 0; box-shadow: 0 6px 18px rgba(0,114,255,.35); }

/* Colourful stat cards */
.stats .stat::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--g, var(--sunset)); }
.stats .stat:nth-child(5n+1) { --g: var(--sunset); }
.stats .stat:nth-child(5n+2) { --g: var(--ocean); }
.stats .stat:nth-child(5n+3) { --g: var(--lime); }
.stats .stat:nth-child(5n+4) { --g: var(--grape); }
.stats .stat:nth-child(5n+5) { --g: var(--gold); }
.stats .stat .value { background: linear-gradient(90deg, #1f2430, #6a4c93); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stats .stat::after { animation: float 4s ease-in-out infinite; opacity: .18; }
.stats .stat:hover::after { animation: wobble .6s ease-in-out; }

/* Tabs: gradient active indicator + icon bounce */
.tabs button.active { color: #ee0979; border-bottom-color: #ee0979; }
@media (max-width: 760px) { .tabs button.active { border-top-color: #ee0979; border-bottom-color: transparent; } }
.tabs button.active .ti { display: inline-block; animation: bounceIn .45s ease-out; }
.tabs button:hover .ti { display: inline-block; animation: wobble .5s ease-in-out; }

/* Gradient toasts with a bouncing entrance */
.toast { background: linear-gradient(135deg, #434343, #1f2430); animation: bounceIn .4s ease-out; font-weight: 600; }
.toast-success { background: linear-gradient(135deg, #56ab2f, #16a34a); }
.toast-error { background: linear-gradient(135deg, #ff416c, #ff4b2b); }
.toast-warn { background: linear-gradient(135deg, #f7971e, #ffb300); color: #1f2430; }
.toast-info { background: linear-gradient(135deg, #4568dc, #b06ab3); }

/* Order / bill codes shimmer */
.code { background: linear-gradient(110deg, #fff7ed 40%, #ffe4c7 50%, #fff7ed 60%); background-size: 250% 100%; animation: shimmer 3.5s linear infinite; }
.code.bill { background: linear-gradient(110deg, #eff6ff 40%, #dbeafe 50%, #eff6ff 60%); background-size: 250% 100%; }

/* Colourful status badges */
.badge-pending { background: linear-gradient(135deg, #ffe0e0, #ffc9c9); }
.badge-preparing { background: linear-gradient(135deg, #fff3c4, #ffe08a); }
.badge-ready { background: linear-gradient(135deg, #d3f9d8, #a9e8b6); animation: glowPulse 2s ease-in-out infinite; }
.badge-served { background: linear-gradient(135deg, #dbeafe, #c3d8ff); }

/* Cards: gradient border glow on hover */
.card.hoverable, .mitem, .qr-card { position: relative; }
.card.hoverable::before, .mitem::before {
  content: ''; position: absolute; inset: -2px; border-radius: calc(var(--radius) + 2px); padding: 2px;
  background: var(--rainbow); background-size: 300% 100%; opacity: 0; transition: opacity .25s; pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: rainbowSlide 4s linear infinite;
}
.card.hoverable:hover::before, .mitem:hover::before { opacity: 1; }
.tbl-card.occupied { background: linear-gradient(160deg, #fff 60%, #eef4ff); }
.tbl-card.alert { background: linear-gradient(160deg, #fff 55%, #fff0f0); }

/* Customer */
.c-header .fx-floater { opacity: .35; }
.c-header h1 { text-shadow: 0 2px 10px rgba(0,0,0,.18); }
.c-cats button.active { background: var(--sunset); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(238,9,121,.3); }
.c-menu h2 { display: inline-block; background: linear-gradient(90deg, #ff6a00, #ee0979); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.mthumb { position: relative; overflow: hidden; }
.cat-items .mitem:nth-child(6n+1) .mthumb { background: linear-gradient(135deg, #ffe0d1, #ffb199); }
.cat-items .mitem:nth-child(6n+2) .mthumb { background: linear-gradient(135deg, #d9f6ff, #9be7ff); }
.cat-items .mitem:nth-child(6n+3) .mthumb { background: linear-gradient(135deg, #e8ffd9, #b8f29b); }
.cat-items .mitem:nth-child(6n+4) .mthumb { background: linear-gradient(135deg, #f3e1ff, #d6b3ff); }
.cat-items .mitem:nth-child(6n+5) .mthumb { background: linear-gradient(135deg, #fff6cc, #ffe066); }
.cat-items .mitem:nth-child(6n+6) .mthumb { background: linear-gradient(135deg, #ffe0ef, #ffadd2); }
.mitem:hover .mthumb { animation: wobble .6s ease-in-out; }
.add-btn { background: #fff; border: 2px solid transparent; background-image: linear-gradient(#fff, #fff), var(--sunset); background-origin: border-box; background-clip: padding-box, border-box; color: #ee0979; }
.add-btn:hover { background-image: var(--sunset), var(--sunset); color: #fff; }
.qty-ctl { border-color: #ee0979; animation: bounceIn .3s ease-out; }
.qty-ctl button { color: #ee0979; }
.mitem.in-cart { box-shadow: 0 0 0 2px #ee0979, 0 6px 18px rgba(238,9,121,.15); }
.help-fab { background: linear-gradient(135deg, #ff416c, #ff4b2b); animation: glowPulse 2.4s ease-in-out infinite; }
.help-fab.pending { background: var(--gold); color: #1f2430; }
.help-grid button:not(:disabled):hover { border-color: #ee0979; transform: translateY(-2px); box-shadow: 0 6px 14px rgba(238,9,121,.15); }
.help-grid button .ico { transition: transform .2s; }
.help-grid button:hover .ico { animation: wobble .5s ease-in-out; }
.tracker .step.current .dot { background: var(--lime); animation: pulse-green 1.6s infinite, fxPop .6s ease-out; }
.tracker .step.done::before, .tracker .step.current::before { background: linear-gradient(90deg, #a8e063, #16a34a); }
.status-msg { background: linear-gradient(90deg, #f0fdf4, #ecfeff); }
.celebrate-card { animation: glowPulse 1.6s ease-in-out 3, fxPop .6s ease-out; }
.sheet-head h3 { background: linear-gradient(90deg, #1f2430, #ee0979); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* Kitchen */
.kcol.pending h2 { background: linear-gradient(135deg, #ff416c, #ff4b2b); }
.kcol.preparing h2 { background: linear-gradient(135deg, #f7971e, #ffb300); }
.kcol.ready h2 { background: linear-gradient(135deg, #56ab2f, #16a34a); }
.ticket.new-ticket { animation: rise .35s ease-out, glowPulse 1.2s ease-in-out 3; }
.ticket.late { background: linear-gradient(160deg, #fff 70%, #ffecec); }
.ticket.late .ticket-time { animation: wobble 1s ease-in-out infinite; display: inline-block; }

/* Login */
.login-wrap .fx-floater { opacity: .5; }
.login-wrap .card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 5px; border-radius: var(--radius) var(--radius) 0 0; background: var(--rainbow); background-size: 200% 100%; animation: rainbowSlide 4s linear infinite; }
.role-switch button.active { background: var(--sunset); border-color: transparent; }

/* Help request rows */
.help-item { background: linear-gradient(90deg, #fffbeb, #fff1f2); border-color: #fecdd3; animation: rise .3s ease-out; }
.serve-item { background: linear-gradient(90deg, #f0fdf4, #ecfeff); animation: rise .3s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .fx-floater, .fx-canvas, .fx-fly { display: none !important; }
}
