/* Smoothie POS: shared styles. Touch-first: all tap targets are >= 48px, primary actions >= 64px. */
:root {
  color-scheme: light;
  /* Enterprise console palette: soft gray canvas, white cards, deep forest green */
  --bg: #f6f1e3;          /* warm cream (Mengo) */
  --surface: #ffffff;
  --surface-2: #fbf8ef;
  --border: #ebe5d3;
  --text: #121613;
  --text-2: #69716b;
  --text-3: #99a09a;
  --brand: #106d34;          /* primary: deep green */
  --brand-ink: #ffffff;
  --brand-soft: #e3f1e4;
  --mango: #f9be08;          /* Mengo mango yellow */
  --mango-soft: #fff3c4;
  --mango-ink: #0a4a23;
  --accent: #2f9a58;         /* success / progress green */
  --accent-soft: #e0f3e7;
  --warn: #b77400;
  --warn-soft: #fff3d6;
  --danger: #d23b3b;
  --danger-soft: #fde4e4;
  --info: #2563c9;
  --info-soft: #e3ecfb;
  --series-1: #2f9a58;
  --hero: linear-gradient(135deg, #0a4a23 0%, #106d34 55%, #2f9a58 100%);
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(16 24 18 / 0.04);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141412;
    --surface: #1e1e1b;
    --surface-2: #2a2a26;
    --border: #3a3934;
    --text: #f5f4ef;
    --text-2: #c3c2b7;
    --text-3: #8f8d84;
    --brand: #f06a4e;
    --brand-soft: #4a2219;
    --accent: #2fbf85;
    --accent-soft: #173a2b;
    --warn: #f0b429;
    --warn-soft: #3d3010;
    --danger: #f06363;
    --danger-soft: #4a1c1c;
    --info: #5b9ff0;
    --info-soft: #172c47;
    --series-1: #3987e5;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141412; --surface: #1e1e1b; --surface-2: #2a2a26; --border: #3a3934;
  --text: #f5f4ef; --text-2: #c3c2b7; --text-3: #8f8d84;
  --brand: #f06a4e; --brand-soft: #4a2219; --accent: #2fbf85; --accent-soft: #173a2b;
  --warn: #f0b429; --warn-soft: #3d3010; --danger: #f06363; --danger-soft: #4a1c1c;
  --info: #5b9ff0; --info-soft: #172c47; --series-1: #3987e5; --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
.touch-app, .touch-app * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.touch-app input, .touch-app textarea { -webkit-user-select: text; user-select: text; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 1rem; cursor: pointer; touch-action: manipulation;
  transition: transform 0.06s, background 0.15s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.outline { background: transparent; border: 1.5px solid var(--brand); color: var(--brand); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.big { min-height: 60px; font-size: 1.1rem; padding: 0 28px; border-radius: 999px; }
.btn.xl { min-height: 72px; font-size: 1.3rem; border-radius: 999px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 0.9rem; }
.icon-btn { width: 48px; padding: 0; }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input {
  min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); font-size: 1rem; width: 100%;
}
textarea.input { min-height: 72px; resize: vertical; }
.input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }

/* Toggle switch */
.switch { position: relative; display: inline-block; vertical-align: middle; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border); transition: 0.2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: 0.2s; box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.new { background: var(--info-soft); color: var(--info); }
.badge.preparing { background: var(--brand-soft); color: var(--brand); }
.badge.ready, .badge.paid { background: var(--accent-soft); color: var(--accent); }
.badge.cancelled, .badge.refunded { background: var(--danger-soft); color: var(--danger); }
.badge.kiosk { background: var(--info-soft); color: var(--info); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); min-height: 68px;
}
.topbar .brand { font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.tabs button {
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 10px; background: transparent;
  font-weight: 700; color: var(--text-2); cursor: pointer; display: flex; align-items: center; gap: 8px;
}
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.count { background: var(--brand); color: #fff; border-radius: 99px; padding: 1px 8px; font-size: 0.8rem; }

/* ---------- Connection banner ---------- */
.conn-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex: none; }
.conn-dot.down { background: var(--danger); animation: blink 1s infinite; }
#conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000; padding: 14px 20px;
  background: var(--danger); color: #fff; font-weight: 700; text-align: center; font-size: 1.05rem;
  box-shadow: 0 4px 20px rgb(0 0 0 / 0.3);
}
@keyframes blink { 50% { opacity: 0.3; } }

/* ---------- Overlay / modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade 0.15s;
}
.modal {
  background: var(--surface); border-radius: 22px; width: min(560px, 100%); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #222; color: #fff; padding: 14px 22px; border-radius: 14px; font-weight: 600; box-shadow: 0 8px 30px rgb(0 0 0 / 0.3); max-width: 90vw; animation: fade 0.2s; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--accent); }

/* ---------- PIN pad ---------- */
.pin-screen { position: fixed; inset: 0; z-index: 900; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pin-box { width: min(360px, 100%); text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 22px 0; min-height: 22px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; background: var(--text); }
.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pin-grid button { min-height: 76px; font-size: 1.7rem; font-weight: 600; border-radius: 18px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.pin-grid button:active { background: var(--surface-2); }
.pin-error { color: var(--danger); min-height: 24px; font-weight: 600; margin-top: 12px; }

/* ---------- Item builder (kiosk + POS) ---------- */
.builder { position: fixed; inset: 0; z-index: 400; background: var(--bg); display: flex; flex-direction: column; animation: fade 0.15s; }
.builder-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.builder-head h2 { font-size: 1.4rem; }
.builder-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 20px 16px 32px; }
.builder-inner { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
.section-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-title h3 { font-size: 1.25rem; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tiles.lg { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile {
  position: relative; min-height: 84px; padding: 14px; border-radius: var(--radius);
  border: 2px solid var(--border); background: var(--surface); text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; justify-content: center; touch-action: manipulation;
}
.tile:active:not(:disabled) { transform: scale(0.98); }
.tile .emoji { font-size: 2rem; line-height: 1; }
.tile .name { font-weight: 700; font-size: 1.05rem; }
.tile .sub { color: var(--text-2); font-size: 0.9rem; }
.tile.selected { border-color: var(--brand); background: var(--brand-soft); }
.tile.selected::after {
  content: attr(data-mark); position: absolute; top: 8px; right: 8px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 99px;
  background: var(--brand); color: #fff; font-size: 0.85rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.tile:disabled { opacity: 0.45; cursor: not-allowed; }
.tile .soldout { color: var(--danger); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; }
.tile.big-choice { min-height: 170px; align-items: flex-start; }
.tile.big-choice .emoji { font-size: 3rem; }
.recipe { display: flex; flex-wrap: wrap; gap: 8px; }
.recipe span { background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 8px 14px; font-weight: 600; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.stepper button { width: 56px; height: 56px; border: 0; background: transparent; font-size: 1.6rem; cursor: pointer; }
.stepper button:disabled { opacity: 0.3; }
.stepper span { min-width: 44px; text-align: center; font-size: 1.3rem; font-weight: 700; }
.builder-foot { display: flex; align-items: center; gap: 16px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.builder-foot .price-note { color: var(--text-2); font-size: 0.9rem; }
.builder-foot .price-note.error { color: var(--danger); font-weight: 600; }

/* ---------- Checkout (POS + counter) ---------- */
.checkout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.co-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 16px; border-radius: 14px; background: var(--surface-2); }
.co-total strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.co-total.ok { background: var(--accent-soft); }
.co-total.ok strong { color: var(--accent); }
.co-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.co-change { display: flex; flex-direction: column; padding: 16px 40px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); }
.co-change strong { font-size: 3rem; font-variant-numeric: tabular-nums; }
.checkout .pin-grid button { min-height: 64px; }
@media (max-width: 900px) { .checkout { grid-template-columns: 1fr; } }

/* ---------- Order lines ---------- */
.line { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.line:last-child { border-bottom: 0; }
.line-title { font-weight: 700; }
.line-detail { color: var(--text-2); font-size: 0.9rem; margin-top: 2px; }
.line-note { color: var(--warn); font-size: 0.9rem; font-weight: 600; margin-top: 2px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 1.35rem; font-weight: 800; }

/* ---------- Tables (admin) ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td:first-child { white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
table.data .r { text-align: right; font-variant-numeric: tabular-nums; }
tr.dim td { opacity: 0.5; }

/* ---------- Printing ---------- */
#print-root { display: none; }
@media print {
  @page { size: 80mm auto; margin: 3mm; }
  body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; color: #000; font: 12px/1.35 'Courier New', ui-monospace, monospace; width: 74mm; }
  #print-root .pl { white-space: pre-wrap; word-break: break-word; }
  #print-root .pl.c { text-align: center; }
  #print-root .pl.b { font-weight: bold; }
  #print-root .pl.l { font-size: 17px; }
  #print-root .pl.hr { border-top: 1px dashed #000; margin: 4px 0; }
  #print-root .page { page-break-after: always; }
}
a.btn { text-decoration: none; }

/* ---------- Item builder v2: photo side panel + size / fruit / add-on pickers ---------- */
.bd-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; padding: 16px; }
.bd-side { background: var(--surface); border-radius: 22px; padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.bd-side h2 { margin: 4px 0 0; font-size: 1.4rem; }
.bd-side p { margin: 0; }
.bd-qty { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; font-weight: 700; }
.bd-main { background: var(--surface); border-radius: 22px; padding: 18px; overflow: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 22px; min-height: 0; }
.bd-sec h3 { margin: 0 0 10px; font-size: 1.1rem; }
.bd-sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.bd-sec-head h3 { margin: 0; }
.bd-sec-head .spacer { flex: 1; }
.bd-count { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.bd-pic { overflow: hidden; background: var(--brand-soft); display: grid; place-items: center; flex: none; }
.bd-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bd-pic.hero { width: 100%; aspect-ratio: 4 / 3; border-radius: 16px; font-size: 3.4rem; }
.bd-pic.round { width: 100%; max-width: 74px; aspect-ratio: 1; border-radius: 50%; font-size: 1.8rem; }
.bd-pic.tiny { width: 44px; max-width: 44px; font-size: 1.1rem; }
.bd-sizes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.bd-size { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; min-height: 92px; border-radius: 18px; border: 0; background: var(--surface); box-shadow: inset 0 0 0 2px var(--border); cursor: pointer; font: inherit; color: inherit; }
.bd-size strong { font-size: 1.15rem; }
.bd-size span { font-weight: 800; color: var(--brand); font-size: 1.1rem; }
.bd-size small { color: var(--text-2); font-size: 0.78rem; }
.bd-size.on { background: var(--brand); box-shadow: none; color: #fff; }
.bd-size.on span, .bd-size.on small { color: #fff; }
.bd-size:disabled { opacity: 0.4; }
.bd-fruits { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.bd-fruit { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 8px; border-radius: 18px; border: 0; background: var(--surface); box-shadow: inset 0 0 0 2px var(--border); cursor: pointer; font: inherit; color: inherit; font-weight: 600; font-size: 0.9rem; text-align: center; line-height: 1.1; }
.bd-fruit.on { background: var(--brand-soft); box-shadow: inset 0 0 0 3px var(--brand); }
.bd-fruit:disabled { opacity: 0.4; }
.bd-fruit:active:not(:disabled), .bd-addon:active:not(:disabled), .bd-size:active:not(:disabled) { transform: scale(0.97); }
.bd-tick { position: absolute; top: 4px; right: 4px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 0.78rem; display: grid; place-items: center; }
.bd-fruit em, .bd-addon em, .bd-size em { position: absolute; left: 6px; right: 6px; bottom: 4px; font-style: normal; font-size: 0.7rem; font-weight: 700; color: #fff; background: rgb(0 0 0 / 0.6); border-radius: 6px; padding: 1px; }
.bd-addons { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.bd-addon { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; min-height: 64px; border-radius: 18px; border: 0; background: var(--surface); box-shadow: inset 0 0 0 2px var(--border); cursor: pointer; font: inherit; color: inherit; text-align: left; }
.bd-addon > span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bd-addon strong { font-size: 0.98rem; line-height: 1.15; }
.bd-addon small { color: var(--text-2); font-weight: 700; }
.bd-check { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2, #eef0ed); display: grid; place-items: center; font-size: 1rem; flex: none; }
.bd-addon.on { background: var(--brand-soft); box-shadow: inset 0 0 0 3px var(--brand); }
.bd-addon.on .bd-check { background: var(--brand); color: #fff; }
.bd-addon:disabled { opacity: 0.4; }
@media (max-width: 900px) {
  .bd-layout { grid-template-columns: 1fr; overflow: auto; }
  .bd-side { flex-direction: row; flex-wrap: wrap; align-items: center; overflow: visible; }
  .bd-pic.hero { width: 120px; aspect-ratio: 1; }
  .bd-side textarea { flex-basis: 100%; }
  .bd-main { overflow: visible; }
}

/* ---------- Quick-add pop-up (POS "+") ---------- */
.bd-quick-wrap { z-index: 450; }
.bd-quick { background: var(--surface); width: min(440px, calc(100vw - 24px)); border-radius: 24px; padding: 16px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgb(0 0 0 / 0.3); }
.bd-quick-head { display: flex; align-items: center; gap: 12px; }
.bd-quick-head strong { font-size: 1.2rem; }
.bd-pic.thumb { width: 64px; height: 64px; border-radius: 14px; font-size: 1.8rem; }
.bd-quick-sizes { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.bd-quick-sizes .bd-size { min-height: 70px; padding: 10px 6px; }
.bd-quick-addons { display: flex; flex-wrap: wrap; gap: 8px; }
.bd-chip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--border); font: inherit; font-weight: 600; cursor: pointer; color: inherit; }
.bd-chip small { color: var(--text-2); font-weight: 700; }
.bd-chip.on { background: var(--brand-soft); box-shadow: inset 0 0 0 2.5px var(--brand); }
.bd-quick-foot { display: flex; align-items: center; gap: 12px; }
.bd-more { align-self: center; background: none; border: 0; color: var(--brand); font-weight: 700; cursor: pointer; padding: 6px 12px; font: inherit; }
