/* ==========================================================================
   K-POS — Smart POS and Ordering System
   Shared styles + per-app themes. Palette taken from the K-POS logo:
   deep blue #055DF3 → sky #01AEFD → cyan #00E5FF.
   ========================================================================== */
.reward-box { border: 1px solid var(--line, #dde6f2); border-radius: 12px; padding: .75rem; background: linear-gradient(135deg, rgba(5,93,243,.06), rgba(0,229,255,.08)); }
.pin-chip { display: inline-flex; align-items: center; gap: .3rem; background: rgba(0,229,255,.14); border: 1px solid rgba(0,229,255,.55); color: #fff; border-radius: 999px; padding: .2rem .7rem; font-size: .9rem; white-space: nowrap; }
.pin-chip b { font-size: 1.05rem; letter-spacing: .12em; color: #7ff3ff; }
:root {
  --brand: #055df3;
  --brand-dark: #0447c2;
  --brand-soft: #e8f2ff;
  --brand-sky: #01aefd;
  --brand-cyan: #00e5ff;
  --brand-gradient: linear-gradient(135deg, #055df3 0%, #01aefd 60%, #00e5ff 100%);
  --navy: #071a3a;
  --navy-2: #0c2350;
  --ink: #0f1b2d;
  --muted: #64748b;
  --surface: #ffffff;
  --canvas: #f3f7fc;
  --line: #dde6f2;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --info: #1d4ed8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.06);
  --touch: 48px;
  font-synthesis: none;
}
html, body { height: 100%; }
body { background: var(--canvas); color: var(--ink); -webkit-tap-highlight-color: transparent; }
.btn { border-radius: 10px; font-weight: 600; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-outline-brand { border-color: var(--brand); color: var(--brand); }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }
.btn-touch { min-height: var(--touch); padding-inline: 1rem; }
.text-brand { color: var(--brand) !important; }
.bg-brand-soft { background: var(--brand-soft) !important; }
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-control, .form-select { border-radius: 10px; }
.mono { font-variant-numeric: tabular-nums; }
.small-caps { text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 700; color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .55; }
.min-w-0 { min-width: 0; }
.cursor-pointer { cursor: pointer; }

/* Status chips -------------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; line-height: 1.4; white-space: nowrap; }
.st-held       { background: #eef2f7; color: #475569; }
.st-submitted  { background: #fef3c7; color: #92400e; }
.st-confirmed  { background: #dbeafe; color: #1e40af; }
.st-preparing  { background: #ffedd5; color: #9a3412; }
.st-ready      { background: #dcfce7; color: #166534; }
.st-served     { background: #e0e7ff; color: #3730a3; }
.st-completed  { background: #f1f5f9; color: #334155; }
.st-cancelled, .st-voided { background: #fee2e2; color: #991b1b; }
.st-paid       { background: #dcfce7; color: #166534; }
.st-unpaid     { background: #fef2f2; color: #b91c1c; }
.st-pending    { background: #fef3c7; color: #92400e; }
.st-open       { background: #dbeafe; color: #1e40af; }
.st-void, .st-failed { background: #f1f5f9; color: #64748b; }
.st-acknowledged { background: #dbeafe; color: #1e40af; }
.st-in_progress  { background: #ffedd5; color: #9a3412; }

/* Table status colours (floor plan) */
.ts-available        { --ts: #16a34a; --ts-bg: #f0fdf4; }
.ts-occupied         { --ts: #2563eb; --ts-bg: #eff6ff; }
.ts-ordering         { --ts: #d97706; --ts-bg: #fffbeb; }
.ts-preparing        { --ts: #ea580c; --ts-bg: #fff7ed; }
.ts-served           { --ts: #7c3aed; --ts-bg: #f5f3ff; }
.ts-awaiting_payment { --ts: #dc2626; --ts-bg: #fef2f2; }
.ts-cleaning         { --ts: #0891b2; --ts-bg: #ecfeff; }
.ts-reserved         { --ts: #64748b; --ts-bg: #f8fafc; }
.ts-out_of_service   { --ts: #9ca3af; --ts-bg: #f3f4f6; }

/* Connection banner & toasts ---------------------------------------------- */
#conn-banner { position: fixed; inset: 0 0 auto 0; z-index: 2000; text-align: center; font-weight: 600; padding: .35rem; font-size: .85rem; transform: translateY(-100%); transition: transform .2s; }
#conn-banner.show { transform: none; }
#conn-banner.offline { background: #7f1d1d; color: #fff; }
#conn-banner.degraded { background: #92400e; color: #fff; }
#toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 2100; display: flex; flex-direction: column; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast-msg { background: #111827; color: #fff; border-radius: 12px; padding: .7rem 1rem; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 500; animation: toast-in .2s ease-out; }
.toast-msg.ok { background: #14532d; }
.toast-msg.err { background: #7f1d1d; }
.toast-msg.warn { background: #78350f; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* Staff top bar ------------------------------------------------------------- */
.staff-bar { background: var(--navy); color: #eaf2ff; height: 56px; display: flex; align-items: center; gap: .75rem; padding: 0 1rem; position: sticky; top: 0; z-index: 1030; }
.staff-bar .brand { font-weight: 800; letter-spacing: .01em; white-space: nowrap; }
.staff-bar .brand img { width: 26px; height: 26px; object-fit: contain; }
.staff-bar .brand .kpos { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.staff-bar .app-title { color: var(--brand-cyan); font-weight: 600; }
.staff-bar .btn-bar { color: #eaf2ff; border: 1px solid rgba(255,255,255,.18); background: transparent; }
.staff-bar .btn-bar:hover { background: rgba(255,255,255,.08); color: #fff; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; display: inline-block; box-shadow: 0 0 0 3px rgba(34,197,94,.25); }
.live-dot.off { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.25); }

/* Item picker / menu grid ---------------------------------------------------- */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.item-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem; text-align: left; min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; transition: transform .06s, border-color .1s; width: 100%; }
.item-tile:hover { border-color: var(--brand); }
.item-tile:active { transform: scale(.98); }
.item-tile .name { font-weight: 700; line-height: 1.2; }
.item-tile .price { color: var(--brand); font-weight: 700; }
.item-tile.disabled { opacity: .45; pointer-events: none; }
.cat-list .btn { text-align: left; }
.opt-group { border: 1px solid var(--line); border-radius: 12px; padding: .75rem; margin-bottom: .75rem; }
.opt-group .opt { display: flex; align-items: center; justify-content: space-between; padding: .55rem .25rem; border-bottom: 1px dashed var(--line); cursor: pointer; }
.opt-group .opt:last-child { border-bottom: 0; }
.opt-group .opt input { width: 1.25rem; height: 1.25rem; }
.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: #fff; }
.qty-stepper button { border: 0; background: transparent; width: 40px; height: 40px; font-size: 1.15rem; }
.qty-stepper span { min-width: 2rem; text-align: center; font-weight: 700; }

/* ============================ POS ======================================== */
.app-pos { overflow: hidden; }
.pos-shell { display: grid; grid-template-columns: 84px 1fr; height: calc(100vh - 56px); }
.pos-nav { background: var(--navy-2); display: flex; flex-direction: column; gap: .25rem; padding: .5rem .35rem; }
.pos-nav button { background: transparent; border: 0; color: #b9cbe8; border-radius: 12px; padding: .6rem .2rem; font-size: .72rem; font-weight: 600; position: relative; }
.pos-nav button i { display: block; font-size: 1.35rem; margin-bottom: .1rem; }
.pos-nav button.active { background: var(--brand-gradient); color: #fff; }
.pos-nav .badge { position: absolute; top: 4px; right: 6px; }
.pos-main { overflow: hidden; }
.pos-view { height: 100%; overflow: auto; padding: 1rem; display: none; }
.pos-view.active { display: block; }
.pos-order { grid-template-columns: 180px 1fr 360px; gap: 1rem; height: 100%; padding: 1rem; overflow: hidden; }
.pos-order.active { display: grid; }
.pos-order > div { min-height: 0; overflow: auto; }
.ticket { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden !important; }
.ticket-lines { flex: 1; overflow: auto; }
.ticket-line { padding: .6rem .9rem; border-bottom: 1px solid var(--line); }
.ticket-line .mods { color: var(--muted); font-size: .82rem; }
.ticket-foot { border-top: 1px solid var(--line); padding: .9rem; background: #f8fbff; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.kpi .v { font-size: 1.45rem; font-weight: 800; }
.kpi .l { color: var(--muted); font-size: .8rem; font-weight: 600; }
.order-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .8rem; cursor: pointer; }
.order-card.incoming { border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.checkout { display: grid; grid-template-columns: 340px 1fr; gap: 1rem; }
.bill-row { padding: .75rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; margin-bottom: .5rem; }
.bill-row.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(5,93,243,.15); }
.pay-methods .btn { min-height: 56px; }
.cash-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.totals-table td { padding: .2rem 0; }
.totals-table .grand td { font-size: 1.3rem; font-weight: 800; border-top: 2px solid var(--ink); padding-top: .4rem; }

/* Floor plan ---------------------------------------------------------------- */
.floor { position: relative; background: repeating-linear-gradient(0deg, transparent 0 39px, #e6edf7 39px 40px), repeating-linear-gradient(90deg, transparent 0 39px, #e6edf7 39px 40px), #f9fbfe; border: 1px solid var(--line); border-radius: var(--radius); min-height: 520px; }
.floor-table { position: absolute; transform: translate(-50%, -50%); width: 104px; min-height: 84px; border: 3px solid var(--ts); background: var(--ts-bg); border-radius: 14px; padding: .4rem; text-align: center; cursor: pointer; user-select: none; }
.floor-table.round { border-radius: 50%; width: 96px; min-height: 96px; display: flex; flex-direction: column; justify-content: center; }
.floor-table.rect { width: 140px; }
.floor-table .lbl { font-weight: 800; font-size: 1.15rem; }
.floor-table .st { font-size: .66rem; font-weight: 700; text-transform: uppercase; color: var(--ts); }
.floor-table .flag { position: absolute; top: -10px; right: -10px; }
.floor-legend span { display: inline-flex; align-items: center; gap: .3rem; margin-right: .8rem; font-size: .8rem; }
.floor-legend span::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--ts); }
.floor.editing .floor-table { cursor: grab; }

/* ============================ Waiter ===================================== */
.app-waiter { padding-bottom: 76px; }
.waiter-tabs { position: fixed; bottom: 0; left: 0; right: 0; height: 68px; background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); z-index: 1020; padding-bottom: env(safe-area-inset-bottom); }
.waiter-tabs button { border: 0; background: transparent; color: var(--muted); font-size: .75rem; font-weight: 700; position: relative; }
.waiter-tabs button i { display: block; font-size: 1.4rem; }
.waiter-tabs button.active { color: var(--brand); }
.waiter-tabs .badge { position: absolute; top: 6px; left: calc(50% + 6px); }
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .65rem; }
.table-card { border: 3px solid var(--ts); background: var(--ts-bg); border-radius: 16px; padding: .7rem .4rem; text-align: center; position: relative; }
.table-card .lbl { font-size: 1.5rem; font-weight: 800; }
.table-card .st { font-size: .66rem; text-transform: uppercase; font-weight: 800; color: var(--ts); }
.table-card .flags { position: absolute; top: -8px; right: -6px; display: flex; gap: 2px; }
.call-card { border-left: 6px solid #f59e0b; }
.call-card.overdue { border-left-color: #dc2626; animation: pulse-border 1.2s infinite; }
@keyframes pulse-border { 50% { box-shadow: 0 0 0 4px rgba(220,38,38,.2); } }
.cart-fab { position: fixed; left: 1rem; right: 1rem; bottom: 80px; z-index: 1019; }

/* ============================ Kitchen ==================================== */
.app-kitchen { background: #070d1a; color: #e5e7eb; }
.app-kitchen .staff-bar { background: #030b1a; }
.kds-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem 1rem; background: #0b1426; border-bottom: 1px solid #1d2b45; position: sticky; top: 56px; z-index: 1020; }
.kds-bar .btn { border-radius: 999px; }
.kds-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: .9rem; padding: 1rem; align-items: start; }
.kds-ticket { background: #111b2e; border: 1px solid #22314d; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.kds-ticket .hd { padding: .6rem .8rem; display: flex; justify-content: space-between; align-items: center; background: #1a2742; border-top: 6px solid var(--station, #64748b); }
.kds-ticket.warn .hd { background: #4a3a10; }
.kds-ticket.late .hd { background: #5b1414; animation: late-flash 1.6s infinite; }
@keyframes late-flash { 50% { background: #7f1d1d; } }
.kds-ticket .hd .num { font-weight: 800; font-size: 1.05rem; }
.kds-ticket .hd .tbl { font-size: 1.5rem; font-weight: 900; }
.kds-ticket .timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.1rem; }
.kds-ticket ul { list-style: none; margin: 0; padding: .4rem .8rem; }
.kds-ticket li { padding: .45rem 0; border-bottom: 1px dashed #30363d; cursor: pointer; }
.kds-ticket li:last-child { border: 0; }
.kds-ticket li .q { font-weight: 900; font-size: 1.2rem; color: #fbbf24; margin-right: .35rem; }
.kds-ticket li .n { font-weight: 700; font-size: 1.08rem; }
.kds-ticket li .m { color: #93c5fd; font-size: .9rem; padding-left: 1.7rem; }
.kds-ticket li .note { color: #fca5a5; font-weight: 700; font-size: .9rem; padding-left: 1.7rem; }
.kds-ticket li.ready .n { color: #4ade80; }
.kds-ticket li.voided { text-decoration: line-through; opacity: .45; }
.kds-ticket .ft { padding: .6rem .8rem; display: flex; gap: .5rem; border-top: 1px solid #30363d; }
.kds-ticket .ft .btn { flex: 1; min-height: 52px; font-size: 1rem; }
.kds-ticket.status-ready { border-color: #22c55e; }
.kds-empty { color: #6b7280; text-align: center; padding: 5rem 1rem; font-size: 1.2rem; }

/* ============================ Admin ====================================== */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 56px); }
.admin-side { background: #fff; border-right: 1px solid var(--line); padding: 1rem .6rem; position: sticky; top: 56px; height: calc(100vh - 56px); overflow: auto; }
.admin-side .nav-link { color: var(--ink); border-radius: 10px; font-weight: 600; padding: .55rem .8rem; display: flex; gap: .6rem; align-items: center; }
.admin-side .nav-link.active { background: var(--brand-soft); color: var(--brand); }
.admin-side .grp { margin: 1rem .8rem .3rem; }
.admin-main { padding: 1.5rem; min-width: 0; }
.admin-main h2 { font-weight: 800; font-size: 1.45rem; }
.table-admin { background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.table-admin table { margin: 0; }
.table-admin th { background: #f5f8fc; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.qr-box { width: 120px; height: 120px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.qr-box svg { width: 100%; height: 100%; }
.perm-matrix th, .perm-matrix td { text-align: center; vertical-align: middle; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; }

/* ============================ Customer =================================== */
.app-order { background: #f6faff; padding-bottom: 96px; }
.cust-head { background: var(--brand);  background-image: linear-gradient(135deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 55%, #00e5ff) 100%); color: #fff; padding: 1rem 1rem 1.6rem; border-radius: 0 0 24px 24px; }
.cust-head .logo { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.2); display: grid; place-items: center; font-weight: 900; overflow: hidden; }
.cust-head .logo img { width: 100%; height: 100%; object-fit: cover; }
.table-pill { background: #fff; color: var(--brand); border-radius: 999px; padding: .25rem .8rem; font-weight: 800; }
.cat-chips { position: sticky; top: 0; z-index: 1010; background: #f6faff; padding: .6rem 1rem; display: flex; gap: .5rem; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.cat-chips::-webkit-scrollbar { display: none; }
.cat-chips .btn { white-space: nowrap; border-radius: 999px; }
.featured { display: flex; gap: .75rem; overflow-x: auto; padding: .25rem 1rem 1rem; scroll-snap-type: x mandatory; }
.featured .f-card { min-width: 220px; scroll-snap-align: start; }
.menu-item { display: flex; gap: .8rem; padding: .9rem 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.thumb { width: 88px; height: 88px; border-radius: 14px; flex-shrink: 0; object-fit: cover; background: linear-gradient(135deg, #dbeafe, #a5f3fc); display: grid; place-items: center; font-size: 1.6rem; font-weight: 900; color: var(--brand-dark); }
.menu-item.soldout { opacity: .5; }
.diet { font-size: .68rem; font-weight: 700; border-radius: 6px; padding: .05rem .35rem; background: #ecfdf5; color: #047857; margin-right: .2rem; }
.cust-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); background: linear-gradient(transparent, #f6faff 30%); z-index: 1020; display: flex; gap: .6rem; }
.cust-bar .btn { min-height: 54px; border-radius: 16px; font-size: 1.02rem; }
.call-fab { position: fixed; right: 1rem; bottom: 88px; z-index: 1021; width: 60px; height: 60px; border-radius: 50%; font-size: 1.6rem; box-shadow: 0 8px 20px rgba(0,0,0,.2); }
.steps { display: flex; justify-content: space-between; position: relative; margin: .8rem 0 .2rem; }
.steps::before { content: ""; position: absolute; top: 11px; left: 6%; right: 6%; height: 3px; background: var(--line); }
.steps .s { position: relative; text-align: center; flex: 1; font-size: .68rem; font-weight: 700; color: var(--muted); }
.steps .s .dot { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 3px solid var(--line); margin: 0 auto .2rem; display: grid; place-items: center; font-size: .7rem; }
.steps .s.done .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.steps .s.done { color: var(--ink); }
.offcanvas-bottom.tall { height: 88vh; border-radius: 20px 20px 0 0; }

/* Print --------------------------------------------------------------------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* Responsive ---------------------------------------------------------------- */
@media (max-width: 1199px) {
  .pos-order { grid-template-columns: 140px 1fr 320px; }
}
@media (max-width: 991px) {
  .pos-shell { grid-template-columns: 1fr; grid-template-rows: 1fr 64px; }
  .pos-nav { order: 2; flex-direction: row; justify-content: space-around; padding: .25rem; }
  .pos-nav button { flex: 1; padding: .3rem 0; }
  .pos-order { grid-template-columns: 1fr; grid-template-rows: auto 1fr 45%; }
  .pos-order .cat-list { display: flex; gap: .4rem; overflow-x: auto; }
  .pos-order .cat-list .btn { white-space: nowrap; width: auto !important; }
  .checkout { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { position: static; height: auto; display: flex; overflow-x: auto; padding: .5rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-side .grp { display: none; }
  .admin-side .nav-link { white-space: nowrap; }
  .admin-main { padding: 1rem; }
}
@media (max-width: 575px) {
  .staff-bar .app-title, .staff-bar .hide-xs { display: none !important; }
  .item-grid { grid-template-columns: repeat(2, 1fr); }
}
