:root {
  --green: #2f7a3d;
  --green-dark: #245e2f;
  --leaf: #e8f3eb;
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #1d231e;
  --muted: #6b7368;
  --border: #d9ddd5;
  --danger: #b3261e;
  --warn: #c98a16;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font: inherit; }
input, select { font: inherit; color: inherit; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem;
  background: var(--green); color: #fff; box-shadow: var(--shadow);
}
.brand { font-size: 1.1rem; font-weight: 700; min-width: 220px; }
.tabs { display: flex; gap: .25rem; flex: 1; justify-content: center; }
.tab {
  background: transparent; color: rgba(255,255,255,.85); border: 0; padding: .55rem 1.1rem;
  border-radius: 999px; font-weight: 600; font-size: 1rem;
}
.tab.active { background: rgba(255,255,255,.18); color: #fff; }
.employee { display: flex; align-items: center; gap: .5rem; min-width: 220px; justify-content: flex-end; }
.employee label { font-size: .85rem; opacity: .9; }
.employee input, .employee select { width: 170px; padding: .5rem .65rem; border-radius: 8px; border: 0; background: rgba(255,255,255,.92); font-size: 1rem; color: var(--text); }

.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; }

/* CHECKOUT */
.view-checkout { padding: 1rem; gap: 1rem; }
.left-pane { flex: 1.4; display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.right-pane {
  flex: 1; min-width: 360px; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 1rem; gap: .8rem; box-shadow: var(--shadow);
}

.search-row { display: flex; gap: .5rem; }
.search-row input {
  flex: 1; padding: .9rem 1rem; font-size: 1.1rem; border-radius: 12px; border: 1px solid var(--border);
  background: #fff;
}
.results {
  flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: .25rem; overflow-y: auto; box-shadow: var(--shadow); min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.result {
  display: grid; grid-template-columns: 1fr auto; gap: .75rem; align-items: center;
  padding: .75rem .9rem; border-bottom: 1px solid var(--border);
}
.result:last-child { border-bottom: 0; }
.result-main { min-width: 0; }
.result-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.result-title { font-weight: 600; }
.result-meta { color: var(--muted); font-size: .85rem; margin-top: .1rem; }
.result-price { font-weight: 700; min-width: 80px; text-align: right; }
.result-actions { display: flex; gap: .4rem; }
.result-add {
  background: var(--green); color: #fff; border: 0; padding: .55rem 1rem; border-radius: 10px; font-weight: 600;
  min-width: 64px;
}
.result-add:active { background: var(--green-dark); }
.btn-link {
  background: transparent; color: var(--green-dark); border: 1px solid var(--border);
  padding: .5rem .8rem; border-radius: 10px; font-weight: 600; font-size: .9rem;
}
.chips { margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .25rem; }
.chip {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px; background: var(--leaf);
  color: var(--green-dark); font-size: .75rem; line-height: 1.4;
}
.empty-state { padding: 1.5rem; text-align: center; color: var(--muted); }

.manual-row { display: flex; justify-content: flex-start; }

/* CART */
.right-pane h2 { margin: 0; font-size: 1.1rem; }
.cart-list { flex: 1; overflow-y: auto; min-height: 60px; }
.cart-item {
  display: grid; grid-template-columns: 1fr auto; gap: .4rem .75rem;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: 0; }
.cart-item-title { font-weight: 600; }
.cart-item-meta { color: var(--muted); font-size: .85rem; }
.cart-item-line { display: flex; gap: .5rem; align-items: center; grid-column: 1 / -1; }
.qty-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: #fff;
  font-size: 1.2rem; font-weight: 700;
}
.qty-display { min-width: 28px; text-align: center; font-weight: 600; }
.remove-btn { background: transparent; border: 0; color: var(--danger); font-size: .9rem; margin-left: auto; }
.cart-item-total { font-weight: 700; }

.totals { border-top: 2px solid var(--border); padding-top: .6rem; display: flex; flex-direction: column; gap: .3rem; }
.totals-row { display: flex; justify-content: space-between; font-size: 1rem; }
.totals-row.grand { font-size: 1.3rem; font-weight: 700; margin-top: .25rem; }

.payment label { font-size: .85rem; color: var(--muted); display: block; margin-bottom: .35rem; }
.pay-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.pay-btn {
  padding: .7rem .5rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; font-weight: 600;
}
.pay-btn.selected { background: var(--leaf); border-color: var(--green); color: var(--green-dark); }

.customer { display: flex; flex-direction: column; gap: .4rem; }
.customer input { padding: .65rem .8rem; border-radius: 10px; border: 1px solid var(--border); }

.actions { display: flex; gap: .5rem; }
.actions button { flex: 1; padding: 1rem; font-size: 1.05rem; }
.btn-primary {
  background: var(--green); color: #fff; border: 0; border-radius: 12px; font-weight: 700;
  padding: .75rem 1rem;
}
.btn-primary:disabled { background: #b3c4b6; }
.btn-primary:active:not(:disabled) { background: var(--green-dark); }
.btn-secondary {
  background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 12px; font-weight: 600;
  padding: .75rem 1rem;
}

/* REPORTS */
.view-reports { padding: 1rem; flex-direction: column; gap: 1rem; }
.reports-controls { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; background: var(--card);
  border: 1px solid var(--border); border-radius: 14px; padding: 1rem; box-shadow: var(--shadow); }
.reports-controls label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
.reports-controls input, .reports-controls select { padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.reports-summary { display: flex; flex-wrap: wrap; gap: .75rem; }
.summary-card { flex: 1 1 160px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: .75rem 1rem; box-shadow: var(--shadow); }
.summary-card .label { color: var(--muted); font-size: .8rem; }
.summary-card .value { font-size: 1.4rem; font-weight: 700; margin-top: .15rem; }
.reports-table-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.reports-table { width: 100%; border-collapse: collapse; }
.reports-table th, .reports-table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.reports-table th { background: #fafbf9; font-size: .85rem; color: var(--muted); }
.reports-table tr:last-child td { border-bottom: 0; }
.row-reprint { background: transparent; border: 1px solid var(--border); padding: .35rem .7rem; border-radius: 8px; font-size: .85rem; }

/* SETTINGS */
.view-settings { padding: 1rem; flex-direction: column; gap: 1rem; overflow-y: auto; }
.settings-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1rem 1.25rem;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .55rem; max-width: 720px; }
.settings-card h3 { margin: 0; }
.settings-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
.settings-card input { padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.settings-card .status { font-size: .9rem; color: var(--muted); }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal[hidden] { display: none; }
.modal-card { background: var(--card); border-radius: 14px; padding: 1.25rem; width: min(420px, 92vw); display: flex; flex-direction: column; gap: .7rem; box-shadow: 0 12px 30px rgba(0,0,0,.25); }
.modal-card h3 { margin: 0; }
.modal-card label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
.modal-card input[type="text"], .modal-card input[type="number"] { padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; font-size: 1rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .25rem; }

/* RECEIPT OVERLAY */
.receipt-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 200; }
.receipt-overlay[hidden] { display: none; }
.receipt-card { background: #fff; border-radius: 14px; width: min(560px, 92vw); max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 12px 30px rgba(0,0,0,.25); overflow: hidden; }
.receipt-content { padding: 1.25rem 1.5rem; overflow-y: auto; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .95rem; }
.receipt-actions { display: flex; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--border); }
.receipt-actions button { flex: 1; padding: .8rem; }

.receipt-content h2 { font-family: -apple-system, BlinkMacSystemFont, sans-serif; margin: 0 0 .25rem; text-align: center; }
.receipt-content .store-info { text-align: center; font-size: .85rem; color: var(--muted); margin-bottom: .75rem; font-family: -apple-system, sans-serif; }
.receipt-content .meta { font-size: .85rem; margin-bottom: .75rem; }
.receipt-content table { width: 100%; border-collapse: collapse; }
.receipt-content table td { padding: .15rem 0; vertical-align: top; }
.receipt-content .item-name { padding-right: .5rem; }
.receipt-content .item-qty { text-align: center; width: 40px; }
.receipt-content .item-price { text-align: right; width: 80px; }
.receipt-content hr { border: 0; border-top: 1px dashed #aaa; margin: .5rem 0; }
.receipt-content .total-line { display: flex; justify-content: space-between; }
.receipt-content .total-line.grand { font-weight: 700; font-size: 1.1rem; }
.receipt-content .thanks { text-align: center; margin-top: 1rem; font-family: -apple-system, sans-serif; font-size: .9rem; color: var(--muted); }

/* PRINT */
@media print {
  body * { visibility: hidden; }
  .receipt-overlay, .receipt-overlay * { visibility: visible; }
  .receipt-overlay { position: absolute; inset: 0; background: #fff; }
  .receipt-card { box-shadow: none; max-height: none; }
  .receipt-actions { display: none; }
  .receipt-content { padding: 0; }
}

/* LOCK BUTTON IN TOPBAR */
.lock-now-btn {
  background: rgba(255,255,255,.16); color: #fff; border: 0; padding: .45rem .8rem;
  border-radius: 999px; font-weight: 600; font-size: .85rem; margin-left: .25rem;
}
.lock-now-btn:active { background: rgba(255,255,255,.28); }

/* SECURITY SETTINGS */
.settings-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.catalog-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* PRODUCT DETAIL OVERLAY */
.detail-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 250; }
.detail-overlay[hidden] { display: none; }
.detail-card {
  background: var(--card); border-radius: 16px; width: min(720px, 94vw); max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 14px 40px rgba(0,0,0,.3); overflow: hidden; position: relative;
}
.detail-close {
  position: absolute; top: .5rem; right: .5rem; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.06); font-size: 1rem; line-height: 1; cursor: pointer; z-index: 1;
}
.detail-body { padding: 1.25rem 1.5rem; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.detail-body h2 { margin: 0 0 .25rem; }
.detail-sub { color: var(--muted); margin-bottom: .75rem; }
.detail-desc { background: var(--leaf); border-radius: 10px; padding: .75rem .9rem; white-space: pre-line; line-height: 1.45; margin-bottom: 1rem; }
.detail-h3 { margin: 1rem 0 .5rem; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.variant-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .5rem; }
.variant-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: .75rem; align-items: center;
  padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 12px; background: #fff;
}
.variant-row.hi { border-color: var(--green); box-shadow: 0 0 0 2px rgba(47,122,61,.18); }
.variant-label { font-weight: 600; }
.variant-meta { color: var(--muted); font-size: .8rem; }
.variant-price { font-weight: 700; min-width: 70px; text-align: right; }
.detail-grid {
  display: grid; grid-template-columns: 160px 1fr; column-gap: 1rem; row-gap: .4rem;
  margin: 0; padding: 0;
}
.detail-grid dt { color: var(--muted); font-size: .85rem; }
.detail-grid dd { margin: 0; }

/* LOCK OVERLAY */
.lock-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(160deg, #245e2f, #1b4123 60%, #102d18);
  display: flex; align-items: center; justify-content: center;
}
.lock-overlay[hidden] { display: none; }
.lock-card {
  background: rgba(255,255,255,.06); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.12); border-radius: 22px;
  padding: 2rem 1.75rem; color: #fff; width: min(380px, 94vw);
  text-align: center; box-shadow: 0 30px 60px rgba(0,0,0,.35);
}
.lock-brand { font-weight: 700; opacity: .9; margin-bottom: .5rem; }
.lock-card h2 { margin: .25rem 0; font-size: 1.4rem; }
.lock-hint { color: rgba(255,255,255,.7); font-size: .85rem; margin-bottom: 1rem; min-height: 1.2em; }
.lock-error { color: #ffb4ad; font-size: .9rem; min-height: 1.2em; margin-bottom: .5rem; }
.pin-dots { display: flex; gap: .65rem; justify-content: center; margin: 1rem 0 .75rem; }
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.55);
  background: transparent; transition: background .15s, transform .15s;
}
.pin-dot.filled { background: #fff; border-color: #fff; transform: scale(1.08); }
.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-top: .75rem;
}
.keypad-btn {
  height: 64px; border-radius: 16px; border: 0; background: rgba(255,255,255,.12); color: #fff;
  font-size: 1.5rem; font-weight: 500; cursor: pointer; transition: background .1s;
  -webkit-user-select: none; user-select: none;
}
.keypad-btn:active { background: rgba(255,255,255,.28); }
.keypad-aux { background: rgba(255,255,255,.06); font-size: 1.05rem; font-weight: 600; }
.lock-card.shake { animation: shake .32s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

/* Lock overlay never prints */
@media print { .lock-overlay { display: none !important; } }

/* ADMIN VIEW */
.view-admin { padding: 1rem; flex-direction: column; gap: 1rem; overflow-y: auto; }
.admin-tabs { display: flex; gap: .25rem; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: .35rem; box-shadow: var(--shadow); width: max-content; }
.admin-tab { background: transparent; border: 0; padding: .55rem 1.1rem; border-radius: 10px; font-weight: 600; color: var(--muted); }
.admin-tab.active { background: var(--leaf); color: var(--green-dark); }
.admin-panel { display: flex; flex-direction: column; gap: 1rem; }
.admin-panel[hidden] { display: none; }
.admin-table-wrap { max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.admin-table th, .admin-table td { padding: .5rem .65rem; vertical-align: middle; }
.admin-table .mono { font-family: ui-monospace, monospace; font-size: .8rem; color: var(--muted); }
.admin-table input[type="number"] { width: 90px; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 8px; }
.admin-save-btn, .admin-revert-btn, .admin-delete-btn { padding: .3rem .55rem; font-size: .8rem; margin-left: .2rem; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); border-radius: 10px; padding: .5rem .8rem; font-weight: 600; font-size: .85rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .8rem; }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid textarea { padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; font: inherit; resize: vertical; }
.cp-row, .emp-row { display: flex; justify-content: space-between; align-items: center; padding: .55rem .25rem; border-bottom: 1px solid var(--border); }
.cp-row:last-child, .emp-row:last-child { border-bottom: 0; }

/* CONCIERGE */
.concierge-card { width: min(720px, 94vw); }
.concierge-bar { display: flex; gap: .5rem; margin: .5rem 0; }
.concierge-bar textarea {
  flex: 1; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; resize: vertical; min-height: 56px;
}
.concierge-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.concierge-suggestion {
  border: 1px solid var(--border); background: var(--leaf); color: var(--green-dark);
  padding: .4rem .75rem; border-radius: 999px; font-size: .85rem; font-weight: 600;
}
.concierge-suggestion:active { background: #d6e7da; }
.concierge-results { display: flex; flex-direction: column; gap: .4rem; }
.concierge-item {
  display: grid; grid-template-columns: 1fr auto; gap: .5rem;
  padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 10px; background: #fff;
  align-items: center;
}

/* CHECKOUT polish */
.search-row { flex-wrap: wrap; }
#conciergeOpenBtn { padding: .9rem 1rem; font-size: 1rem; }

/* iPAD PORTRAIT FALLBACK */
@media (max-width: 880px) {
  .view-checkout { flex-direction: column; }
  .right-pane { min-width: 0; }
  .brand { min-width: 0; font-size: 1rem; }
  .employee { min-width: 0; }
  .employee input, .employee select { width: 120px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid dt { margin-top: .35rem; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-tabs { width: 100%; overflow-x: auto; }
}
