/* KK Bobabite POS — clean, organized, one feature per tab.
   iPad landscape: menu + cart side by side. Phones: stacked, big tap targets. */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #faf7f2; color: #1f2937; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: #6b7280; }
.error { color: #b91c1c; min-height: 1.2em; margin: 6px 0; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; padding: 10px; border: 1px solid #d1d5db; border-radius: 10px; background: #fff; min-height: 48px; }
label { display: block; margin: 10px 0; }
label.inline, .inline-form label { display: inline-block; }

.btn {
  border: 1px solid #d1d5db; background: #fff; color: #1f2937;
  border-radius: 12px; padding: 10px 18px; min-height: 48px; font-weight: 600;
}
.btn.primary { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: #b91c1c; }
.btn.big { width: 100%; font-size: 1.1rem; padding: 14px; }
.btn.small { min-height: 40px; padding: 6px 12px; }

/* banners */
.offline-banner { background: #f59e0b; color: #111827; padding: 10px 14px; font-weight: 600; text-align: center; }
.queue-banner { background: #1d4ed8; color: #fff; padding: 8px 14px; text-align: center; font-weight: 600; }

/* auth */
.auth-screen { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: #fff; border-radius: 20px; padding: 28px; max-width: 430px; width: 100%; box-shadow: 0 8px 30px rgba(0,0,0,.08); text-align: center; }
.auth-logo { height: 84px; max-width: 90%; object-fit: contain; }
.auth-card h1 { margin: 8px 0 0; color: #b91c1c; letter-spacing: .04em; }
.auth-sub { margin: 2px 0 18px; color: #6b7280; }
.auth-card label { text-align: left; }
.auth-card input { width: 100%; }
.login-users { display: grid; gap: 10px; margin: 14px 0; }
.login-user-btn {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border: 2px solid #e5e7eb; border-radius: 14px; background: #fff;
  font-size: 1.05rem; font-weight: 600; min-height: 56px;
}
.login-user-btn .role { font-size: .8rem; color: #6b7280; font-weight: 500; }
.pin-for { font-weight: 700; font-size: 1.05rem; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 10px 0; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #9ca3af; }
.pin-dots span.filled { background: #b91c1c; border-color: #b91c1c; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 260px; margin: 12px auto; }
.pin-pad button { min-height: 56px; font-size: 1.3rem; border-radius: 14px; border: 1px solid #e5e7eb; background: #f9fafb; font-weight: 600; }
.pin-pad button.small { font-size: .9rem; }

/* header + nav */
.app-header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #fff; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 20; }
.header-logo { height: 44px; object-fit: contain; }
.header-title { display: flex; flex-direction: column; }
.header-title strong { color: #b91c1c; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: .9rem; }
.sync-chip { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; padding: 6px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.main-nav { display: flex; gap: 6px; padding: 10px 16px 0; overflow-x: auto; }
.nav-btn { flex: 1; min-height: 48px; border: none; border-radius: 12px 12px 0 0; background: #e7e5e4; font-weight: 700; padding: 10px 14px; white-space: nowrap; }
.nav-btn.active { background: #fff; color: #b91c1c; box-shadow: 0 -2px 8px rgba(0,0,0,.05); }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.view { background: #fff; border-radius: 0 14px 14px 14px; padding: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }

/* sell */
.sell-layout { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.category-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.category-tabs button {
  flex: 0 0 auto; min-height: 48px; padding: 10px 16px; border-radius: 999px;
  border: 2px solid #e5e7eb; background: #fff; font-weight: 700;
}
.category-tabs button.active { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.item-btn {
  position: relative; border: 2px solid #e5e7eb; background: #fff; border-radius: 14px;
  padding: 14px 10px; min-height: 96px; display: flex; flex-direction: column; gap: 6px;
  align-items: flex-start; text-align: left; font-weight: 600;
}
.item-btn .price { color: #b91c1c; font-weight: 800; }
.item-btn .price-not-set { color: #9ca3af; font-weight: 600; font-size: .9rem; }
.item-btn.sold-out { opacity: .45; }
.badge-soldout { position: absolute; top: 8px; right: 8px; background: #111827; color: #fff; font-size: .68rem; padding: 3px 8px; border-radius: 999px; letter-spacing: .05em; }

.cart-panel { background: #fffbeb; border: 1px solid #fde68a; border-radius: 14px; padding: 16px; position: sticky; top: 76px; }
.cart-panel h2 { margin-top: 0; }
.cart-items { display: grid; gap: 8px; }
.cart-line { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 8px 10px; }
.cart-line .cl-top { display: flex; justify-content: space-between; gap: 8px; }
.cart-line .cl-name { font-weight: 700; }
.cart-line .cl-opts { color: #6b7280; font-size: .85rem; }
.cart-line .cl-controls { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.qty-stepper { display: inline-flex; align-items: center; gap: 10px; }
.qty-stepper button { width: 48px; height: 48px; border-radius: 12px; border: 1px solid #d1d5db; background: #fff; font-size: 1.3rem; font-weight: 700; }
.qty-stepper .qty-stepper button { width: 40px; height: 40px; }
.cl-controls .qty-stepper button { width: 40px; height: 40px; min-height: 40px; }
.cl-remove { margin-left: auto; color: #b91c1c; background: none; border: none; font-weight: 700; min-height: 40px; }
.field { margin: 14px 0; }
.field-label { display: block; font-weight: 700; margin-bottom: 6px; }
.segmented { display: flex; gap: 6px; }
.segmented button { flex: 1; min-height: 48px; border-radius: 10px; border: 2px solid #e5e7eb; background: #fff; font-weight: 700; padding: 8px 4px; }
.segmented button.active { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.totals { border-top: 2px dashed #e5e7eb; padding-top: 10px; display: grid; gap: 8px; }
.totals .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.totals .row input { width: 130px; text-align: right; }
.totals .row.total { font-size: 1.2rem; }
.totals .row.total strong { color: #b91c1c; }
.cart-bar {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 30;
  background: #b91c1c; color: #fff; border: none; border-radius: 14px;
  min-height: 56px; padding: 12px 18px; font-weight: 800; font-size: 1.05rem;
  display: none; justify-content: space-between; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

/* today / closing */
.closing-card { background: linear-gradient(135deg, #fef2f2, #fffbeb); border: 2px solid #fecaca; border-radius: 16px; padding: 18px; margin-bottom: 22px; }
.closing-card h2 { margin-top: 0; }
.closing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.closing-main { background: #fff; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.closing-main span { color: #6b7280; font-weight: 600; }
.closing-main strong { font-size: 1.5rem; }
.closing-main.profit strong { color: #15803d; }
.closing-splits { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 14px; }
.closing-splits h3 { margin: 0 0 8px; font-size: .95rem; color: #6b7280; }
.split-row { display: flex; justify-content: space-between; background: #fff; border-radius: 8px; padding: 7px 10px; margin-bottom: 5px; }
.closing-note { margin-bottom: 0; }
.mini-summary { background: #f9fafb; border-radius: 10px; padding: 12px; margin: 10px 0; }

/* orders */
.orders-list { display: grid; gap: 10px; }
.order-card { border: 1px solid #e5e7eb; border-radius: 12px; padding: 12px 14px; background: #fff; }
.order-card .oc-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.order-card .oc-no { font-weight: 800; }
.order-card .oc-total { margin-left: auto; font-weight: 800; color: #b91c1c; }
.order-card .oc-items { color: #374151; margin-top: 6px; }
.order-card .oc-meta { color: #6b7280; font-size: .88rem; margin-top: 4px; }
.channel-badge { font-size: .75rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: #e5e7eb; }
.channel-badge.grab { background: #dcfce7; color: #166534; }
.channel-badge.foodpanda { background: #fce7f3; color: #9d174d; }
.delete-btn { color: #dc2626; background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; min-height: 44px; padding: 6px 14px; font-weight: 700; }

/* history */
.days-list { display: grid; gap: 8px; }
.day-row { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; width: 100%; text-align: left; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px; min-height: 56px; font-weight: 600; }
.day-row .profit { color: #15803d; font-weight: 800; }

/* stock */
.stock-group h3 { margin: 18px 0 8px; color: #b91c1c; }
.stock-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 6px; background: #fff; }
.stock-row .sr-name { font-weight: 600; }
.stock-row .sr-price { color: #6b7280; }
.stock-row .toggle-wrap { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.toggle { position: relative; width: 64px; height: 36px; flex: 0 0 auto; }
.toggle input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.toggle .track { position: absolute; inset: 0; background: #d1d5db; border-radius: 999px; transition: .15s; pointer-events: none; }
.toggle .track::after { content: ""; position: absolute; width: 28px; height: 28px; border-radius: 50%; background: #fff; top: 4px; left: 4px; transition: .15s; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.toggle input:checked + .track { background: #16a34a; }
.toggle input:checked + .track::after { left: 32px; }

/* money */
.money-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 14px 0; }
.money-card { background: #f9fafb; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.money-card strong { font-size: 1.4rem; }
.money-card.profit { background: #f0fdf4; }
.money-card.profit strong { color: #15803d; }
.expense-form { display: flex; flex-wrap: wrap; gap: 8px; }
.expense-form input, .expense-form select { flex: 1 1 160px; }
.expenses-list { display: grid; gap: 8px; }
.expense-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px 12px; background: #fff; }
.expense-row .amount { font-weight: 800; }
.expense-row .delete-btn { margin-left: auto; }

/* settings */
.settings-card { border: 1px solid #e5e7eb; border-radius: 14px; padding: 16px; margin-bottom: 16px; background: #fff; }
.settings-card h3 { margin-top: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.inline-form input { flex: 1 1 150px; }
.user-row, .price-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed #e5e7eb; }
.user-row .u-name { font-weight: 700; }
.user-row .spacer, .price-row .spacer { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.price-row input { width: 130px; }
.role-tag { font-size: .75rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #e5e7eb; }
.role-tag.owner { background: #fef3c7; color: #92400e; }
.off-tag { color: #9ca3af; font-weight: 700; }
.activity-list { display: grid; gap: 6px; max-height: 420px; overflow-y: auto; }
.activity-row { font-size: .92rem; padding: 8px 10px; background: #f9fafb; border-radius: 8px; }
.activity-row .a-when { color: #6b7280; }

/* failed queue */
.failed-queue { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-weight: 600; }

/* footer — the ONLY place the address appears (plus receipts) */
.app-footer { padding: 18px 16px 30px; text-align: center; color: #6b7280; font-size: .9rem; }
.app-footer a { color: #b91c1c; }

/* modals */
.modal { position: fixed; inset: 0; background: rgba(17,24,39,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-card { background: #fff; border-radius: 18px; padding: 22px; width: 100%; max-width: 440px; max-height: 90dvh; overflow-y: auto; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.qty-row { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.topping-list { display: grid; gap: 8px; }
.topping-option { display: flex; align-items: center; gap: 10px; border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px 12px; min-height: 48px; font-weight: 600; }
.topping-option input { width: 22px; height: 22px; min-height: 0; }
.topping-option .t-price { margin-left: auto; color: #b91c1c; font-weight: 800; }

/* receipt */
.receipt { text-align: center; font-family: ui-monospace, Menlo, monospace; }
.receipt img { height: 64px; object-fit: contain; }
.receipt h3 { margin: 6px 0; }
.receipt .r-items { text-align: left; margin: 10px 0; }
.receipt .r-row { display: flex; justify-content: space-between; gap: 10px; }
.receipt .r-opts { color: #6b7280; font-size: .85em; text-align: left; }
.receipt hr { border: none; border-top: 1px dashed #9ca3af; }
.receipt .r-total { font-size: 1.15rem; font-weight: 800; }
#receipt-sheet { display: none; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px; z-index: 60;
  background: #111827; color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600;
  max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

/* phones (Android / iPhone) */
@media (max-width: 820px) {
  main { padding: 10px; }
  .view { padding: 12px; }
  .sell-layout { grid-template-columns: 1fr; }
  .cart-panel { position: static; }
  .cart-bar { display: flex; }
  .cart-bar.hidden { display: none !important; }
  .item-grid { grid-template-columns: repeat(2, 1fr); }
  .header-title span { display: none; }
  .user-chip { font-size: .8rem; }
}
/* receipt printing: print ONLY the receipt sheet */
@media print {
  body * { visibility: hidden; }
  #receipt-sheet, #receipt-sheet * { visibility: visible; }
  #receipt-sheet { display: block; position: absolute; inset: 0 auto auto 0; width: 100%; }
}
