:root {
  --brand: #0b6e4f;
  --brand-dark: #075a40;
  --brand-light: #e6f4ef;
  --accent: #f4a300;
  --danger: #d64545;
  --warning: #e08e0b;
  --info: #2b6cb0;
  --success: #1f9d55;
  --bg: #f2f4f6;
  --card: #ffffff;
  --text: #1c2530;
  --muted: #6b7683;
  --border: #e2e6ea;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
  --radius: 12px;
  --header-h: 56px;
  --nav-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 700; }
h1 { font-size: 1.3rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }

/* Boot */
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 1rem; color: var(--muted); }
.boot-logo { width: 72px; height: 72px; border-radius: 20px; background: var(--brand); color: #fff; font-size: 2.4rem; font-weight: 800; display: grid; place-items: center; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login { min-height: 100vh; display: flex; flex-direction: column; padding: calc(var(--safe-top) + 24px) 20px 24px; background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 45%, #052e21 100%); color: #fff; }
.login-brand { text-align: center; margin: 6vh 0 3vh; }
.login-brand .logo { width: 80px; height: 80px; border-radius: 22px; background: rgba(255,255,255,.14); display: grid; place-items: center; font-size: 2.6rem; font-weight: 800; margin: 0 auto 1rem; }
.login-brand h1 { font-size: 1.5rem; }
.login-brand p { color: rgba(255,255,255,.8); margin: 0; }
.login-card { background: #fff; color: var(--text); border-radius: 18px; padding: 20px; box-shadow: 0 12px 40px rgba(0,0,0,.25); margin-top: auto; }
.login-card .field { margin-bottom: 14px; }
.login-card label { font-size: .82rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: 6px; }
.login-card input { width: 100%; padding: 13px 14px; border: 1.5px solid var(--border); border-radius: 10px; }
.login-card input:focus { outline: none; border-color: var(--brand); }
.login-error { background: #fdecec; color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: .85rem; margin-bottom: 12px; display: none; }
.login-error.show { display: block; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-pad button { padding: 16px; font-size: 1.4rem; font-weight: 700; border: 1px solid var(--border); background: #fafbfc; border-radius: 12px; }
.pin-dots { display: flex; gap: 10px; justify-content: center; margin: 8px 0 16px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); }
.pin-dots span.filled { background: var(--brand); border-color: var(--brand); }

/* App shell */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header { position: sticky; top: 0; z-index: 30; height: calc(var(--header-h) + var(--safe-top)); padding-top: var(--safe-top); background: var(--brand); color: #fff; display: flex; align-items: center; gap: 10px; padding-left: 12px; padding-right: 12px; box-shadow: var(--shadow); }
.app-header .title { font-weight: 700; font-size: 1.02rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header .sub { font-size: .72rem; opacity: .85; font-weight: 400; }
.icon-btn { background: rgba(255,255,255,.15); border: none; color: #fff; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; position: relative; }
.icon-btn:active { background: rgba(255,255,255,.3); }
.badge-dot { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: #3a2500; font-size: .62rem; font-weight: 800; display: grid; place-items: center; }
.app-content { flex: 1; padding: 12px 12px calc(var(--nav-h) + var(--safe-bottom) + 16px); }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; height: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom); background: #fff; border-top: 1px solid var(--border); display: flex; box-shadow: 0 -2px 10px rgba(0,0,0,.04); }
.bottom-nav button { flex: 1; border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .68rem; font-weight: 600; padding: 6px 2px; }
.bottom-nav button .ic { font-size: 1.25rem; line-height: 1; }
.bottom-nav button.active { color: var(--brand); }

/* Online status */
.net-pill { font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 20px; background: rgba(255,255,255,.18); }
.net-pill.offline { background: var(--danger); }
.net-pill.online { background: rgba(255,255,255,.18); }

/* Generic */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.tiny { font-size: .72rem; }
.mt { margin-top: 10px; } .mb { margin-bottom: 10px; } .mt2 { margin-top: 16px; }
.center { text-align: center; }
.right { text-align: right; }
.strong { font-weight: 700; }
.hidden { display: none !important; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 16px 2px 8px; }
.section-title h2 { margin: 0; font-size: 1rem; }

/* Buttons */
.btn { border: none; border-radius: 10px; padding: 11px 16px; font-weight: 600; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.lg { padding: 15px; font-size: 1.02rem; }
.btn.sm { padding: 7px 12px; font-size: .82rem; }
.btn.ghost { background: var(--brand-light); color: var(--brand-dark); }
.btn.outline { background: #fff; border: 1.5px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.warn { background: var(--accent); color: #3a2500; }
.btn.grey { background: #eef1f4; color: var(--text); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-group { display: flex; gap: 8px; }

/* Inputs */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.input, select.input, textarea.input { width: 100%; padding: 11px 12px; border: 1.5px solid var(--border); border-radius: 10px; background: #fff; }
.input:focus { outline: none; border-color: var(--brand); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7683' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.searchbar { display: flex; gap: 8px; align-items: center; }
.searchbar input { flex: 1; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat .label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
.stat .value { font-size: 1.35rem; font-weight: 800; margin-top: 4px; }
.stat.brand { background: var(--brand); color: #fff; }
.stat.brand .label { color: rgba(255,255,255,.8); }

/* Tables / lists */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item:active { background: #f7f9fa; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-sub { font-size: .78rem; color: var(--muted); }
.thumb { width: 42px; height: 42px; border-radius: 10px; background: var(--brand-light); display: grid; place-items: center; font-weight: 700; color: var(--brand-dark); flex-shrink: 0; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: .7rem; font-weight: 700; }
.badge.green { background: #e3f5ea; color: #1f7a45; }
.badge.red { background: #fdecec; color: var(--danger); }
.badge.amber { background: #fdf3e2; color: #a56600; }
.badge.blue { background: #e7f0fb; color: var(--info); }
.badge.grey { background: #eef1f4; color: var(--muted); }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; padding: 7px 14px; border-radius: 20px; background: #fff; border: 1.5px solid var(--border); font-size: .82rem; font-weight: 600; color: var(--muted); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* POS */
.pos-search { position: sticky; top: calc(var(--header-h) + var(--safe-top)); z-index: 20; background: var(--bg); padding: 8px 0; }
.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px) { .product-grid { grid-template-columns: repeat(4, 1fr); } }
.product-tile { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.product-tile:active { transform: scale(.98); }
.product-tile .pt-img { height: 84px; background: var(--brand-light); display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; color: var(--brand-dark); overflow: hidden; }
.product-tile .pt-img img { width: 100%; height: 100%; object-fit: cover; }
.product-tile .pt-body { padding: 8px 10px; flex: 1; display: flex; flex-direction: column; }
.product-tile .pt-name { font-size: .84rem; font-weight: 600; line-height: 1.25; min-height: 2.1em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-tile .pt-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; }
.product-tile .pt-price { font-weight: 800; color: var(--brand-dark); }
.product-tile .pt-stock { font-size: .7rem; color: var(--muted); }
.product-tile .pt-stock.low { color: var(--danger); font-weight: 700; }
.product-tile.out { opacity: .55; }

/* Cart bar */
.cart-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-bottom)); z-index: 25; background: var(--brand-dark); color: #fff; padding: 10px 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 -3px 12px rgba(0,0,0,.15); }
.cart-bar .cb-count { background: var(--accent); color: #3a2500; border-radius: 20px; padding: 2px 10px; font-weight: 800; font-size: .8rem; }
.cart-bar .cb-total { flex: 1; font-weight: 800; font-size: 1.05rem; }
.cart-bar button { background: #fff; color: var(--brand-dark); border: none; border-radius: 10px; padding: 10px 16px; font-weight: 700; }

/* Drawer (cart) */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: none; }
.drawer-backdrop.show { display: block; }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(440px, 100%); background: var(--bg); z-index: 41; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; }
.drawer.show { transform: translateX(0); }
.drawer-head { padding: 14px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: space-between; }
.drawer-body { flex: 1; overflow-y: auto; padding: 12px; }
.drawer-foot { padding: 12px; background: #fff; border-top: 1px solid var(--border); }

.cart-line { display: flex; gap: 10px; align-items: center; background: #fff; border-radius: 10px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); }
.cart-line .cl-main { flex: 1; min-width: 0; }
.cart-line .cl-name { font-weight: 600; font-size: .88rem; }
.qty-ctrl { display: flex; align-items: center; gap: 6px; }
.qty-ctrl button { width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--border); background: #fff; font-weight: 800; font-size: 1.05rem; }
.qty-ctrl input { width: 46px; text-align: center; padding: 6px 4px; border: 1.5px solid var(--border); border-radius: 8px; }
.totals { font-size: .92rem; }
.totals .t-row { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .t-row.grand { font-size: 1.15rem; font-weight: 800; border-top: 2px dashed var(--border); margin-top: 6px; padding-top: 8px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal { background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; max-height: 92vh; display: flex; flex-direction: column; }
@media (min-width: 640px) { .modal { border-radius: 18px; } }
.modal-head { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { padding: 14px 16px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--border); display: flex; gap: 10px; }
.modal-foot .btn { flex: 1; }
.close-x { border: none; background: #f0f2f4; width: 32px; height: 32px; border-radius: 50%; font-size: 1.1rem; color: var(--muted); }

/* Payment */
.pay-method { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pay-method button { padding: 14px; border-radius: 12px; border: 2px solid var(--border); background: #fff; font-weight: 700; }
.pay-method button.active { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { padding: 14px; font-size: 1.2rem; font-weight: 700; border: 1px solid var(--border); background: #fafbfc; border-radius: 10px; }
.change-box { background: var(--brand-light); border-radius: 12px; padding: 12px; text-align: center; }
.change-box .big { font-size: 1.6rem; font-weight: 800; color: var(--brand-dark); }

/* Toasts */
.toasts { position: fixed; top: calc(var(--safe-top) + 10px); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(420px, 92vw); }
.toast { padding: 12px 16px; border-radius: 12px; color: #fff; font-weight: 600; font-size: .88rem; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: toastIn .2s ease; }
.toast.success { background: var(--success); } .toast.error { background: var(--danger); }
.toast.info { background: var(--info); } .toast.warn { background: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ic { font-size: 2.4rem; margin-bottom: 8px; }

/* Menu grid */
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 560px) { .menu-grid { grid-template-columns: repeat(4, 1fr); } }
.menu-tile { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; text-align: center; }
.menu-tile .ic { font-size: 1.6rem; }
.menu-tile:active { background: #f7f9fa; }

/* Receipt */
.receipt { font-family: "Courier New", monospace; font-size: .82rem; background: #fff; color: #000; padding: 16px; max-width: 320px; margin: 0 auto; }
.receipt .r-center { text-align: center; }
.receipt .r-line { display: flex; justify-content: space-between; }
.receipt hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }
.receipt table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.receipt td { padding: 1px 0; vertical-align: top; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.tabs button { padding: 8px 14px; border-radius: 20px; border: 1.5px solid var(--border); background: #fff; font-weight: 600; white-space: nowrap; color: var(--muted); }
.tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding: 8px 0; }
.bar-chart .bar { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; }
.bar-chart .bar span { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: .6rem; color: var(--muted); }
.progress { height: 8px; background: #eef1f4; border-radius: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); }
