/* Sasquatch Farm POS */
:root {
  --bg: #f4f4ef;
  --surface: #ffffff;
  --surface-2: #f3f3ee;
  --border: #d9d9cf;
  --divider: #e8e8e1;
  --text: #23301f;
  --muted: #5b6a55;
  --faint: #8d9887;
  --primary: #2e4a33;
  --primary-hover: #223a27;
  --primary-soft: #e3ece2;
  --accent: #a9502f;
  --accent-hover: #8c3f22;
  --accent-soft: #f3e3d9;
  --danger: #9a2c2c;
  --danger-soft: #f6dfdf;
  --ok: #2f6b3a;
  --warn-bg: #fff4d6;
  --warn-text: #6b4e00;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(35, 48, 31, .08), 0 4px 14px rgba(35, 48, 31, .06);
  --shadow-lg: 0 14px 44px rgba(20, 30, 18, .28);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap: 46px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.4; color: var(--text); background: var(--bg); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
a { color: var(--primary); }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .875rem; } .right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; } .bold { font-weight: 650; } .num { font-variant-numeric: tabular-nums; }
.boot-msg { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); padding: 0 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); touch-action: manipulation; user-select: none; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tile:focus-visible, .tab:focus-visible { outline: 3px solid #7fa884; outline-offset: 1px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: #dcbcbc; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 36px; padding: 0 .7rem; font-size: .9rem; }
.btn.big { min-height: 62px; font-size: 1.25rem; padding: 0 1.4rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: .8rem; }

/* forms */
label.field { display: block; }
label.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=tel], select, textarea {
  width: 100%; min-height: var(--tap); padding: .5rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }
.check { display: flex; gap: .5rem; align-items: center; min-height: 36px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; }
.err { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); padding: .6rem .8rem; font-weight: 600; }
.note { background: var(--warn-bg); color: var(--warn-text); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.info { background: var(--primary-soft); color: var(--primary); border-radius: var(--radius-sm); padding: .6rem .8rem; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--primary); color: #fff; display: flex; align-items: center; gap: .8rem; padding: .35rem .8rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; white-space: nowrap; }
.brand img { height: 38px; width: auto; background: #fff; border-radius: 6px; padding: 2px 4px; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .04em; padding: .12rem .45rem; border-radius: 99px; background: #f2c744; color: #3b2d00; text-transform: uppercase; }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.green { background: var(--primary-soft); color: var(--primary); }
.tabs { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; color: #dbe6da; padding: 0 .85rem; min-height: 44px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab:hover { background: rgba(255,255,255,.1); }
.tab.active { background: #fff; color: var(--primary); }
.topbar .who { display: flex; gap: .4rem; align-items: center; }
.topbar .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; min-height: 40px; }
.topbar .btn:hover { background: rgba(255,255,255,.22); }
.page { padding: 1rem; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: .9rem; }
.card { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.card + .card { margin-top: 1rem; }
.card h2 { margin-bottom: .7rem; }

/* sign in */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth { width: 100%; max-width: 420px; }
.auth .logo { display: block; height: 96px; margin: 0 auto .6rem; }
.auth h1 { text-align: center; margin-bottom: .2rem; }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: .45rem .6rem; border-bottom: 2px solid var(--divider); white-space: nowrap; }
table.t td { padding: .55rem .6rem; border-bottom: 1px solid var(--divider); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
table.t th.right, table.t td.right { text-align: right; }
table.t tfoot td { font-weight: 700; border-top: 2px solid var(--divider); border-bottom: 0; }
.neg { color: var(--danger); font-weight: 600; }
.pos { color: var(--ok); font-weight: 600; }

/* checkout */
.register { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 1rem; align-items: start; }
.register > * { min-width: 0; }
.scanbar { display: flex; gap: .5rem; position: sticky; top: 58px; z-index: 5; background: var(--bg); padding-bottom: .6rem; }
.scanbar input { min-height: 56px; font-size: 1.15rem; padding-left: 1rem; border-width: 2px; border-color: var(--primary); }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .5rem; scrollbar-width: thin; }
.chip { flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 0 .9rem; min-height: 38px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.tile { display: flex; flex-direction: column; text-align: left; border: 1px solid var(--divider); background: var(--surface); border-radius: var(--radius); padding: 0; cursor: pointer; overflow: hidden; min-height: 132px; box-shadow: var(--shadow); touch-action: manipulation; }
.tile:hover { border-color: var(--primary); }
.tile .pic { height: 78px; background: var(--surface-2) center/cover no-repeat; display: grid; place-items: center; color: var(--faint); font-weight: 700; font-size: 1.4rem; }
.tile .pic img { width: 100%; height: 78px; object-fit: cover; display: block; }
.tile .tn { padding: .4rem .55rem 0; font-weight: 600; font-size: .9rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .tp { padding: .15rem .55rem .5rem; color: var(--muted); font-size: .85rem; margin-top: auto; display: flex; justify-content: space-between; gap: .3rem; }
.tile.out .tp .q { color: var(--danger); }
.cart { position: sticky; top: 66px; display: flex; flex-direction: column; max-height: calc(100vh - 82px); padding: 0; overflow: hidden; }
.cart-head { padding: .7rem .9rem; border-bottom: 1px solid var(--divider); display: flex; justify-content: space-between; align-items: center; }
.cart-lines { overflow-y: auto; flex: 1 1 auto; min-height: 90px; }
.cart-empty { padding: 2rem 1rem; text-align: center; color: var(--faint); }
.cl { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; padding: .6rem .9rem; border-bottom: 1px solid var(--divider); cursor: pointer; }
.cl:hover { background: var(--surface-2); }
.cl .n { font-weight: 600; line-height: 1.25; }
.cl .s { color: var(--muted); font-size: .85rem; }
.cl .amt { font-weight: 650; text-align: right; }
.qtybox { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.qtybox button { width: 40px; height: 38px; border: 0; background: var(--surface-2); font-size: 1.2rem; font-weight: 700; cursor: pointer; }
.qtybox span { min-width: 42px; text-align: center; font-weight: 650; }
.cart-foot { border-top: 2px solid var(--divider); padding: .7rem .9rem .9rem; background: var(--surface); }
.sum { display: flex; justify-content: space-between; padding: .12rem 0; }
.sum.total { font-size: 1.5rem; font-weight: 750; padding-top: .35rem; margin-top: .3rem; border-top: 1px solid var(--divider); }
.cart-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin: .6rem 0; }
.cart-tools .btn { padding: 0 .3rem; font-size: .85rem; min-height: 42px; }
.paybar { display: none; }

/* keypad + pay */
.due { text-align: center; padding: .4rem 0 .8rem; }
.due .lbl { color: var(--muted); font-weight: 600; }
.due .amt { font-size: 2.8rem; font-weight: 800; line-height: 1.05; }
.paygrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: .7rem 0; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.keypad button { min-height: 58px; font-size: 1.4rem; font-weight: 650; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; cursor: pointer; touch-action: manipulation; }
.keypad button:active { background: var(--surface-2); }
.entry { font-size: 2rem; font-weight: 750; text-align: right; padding: .3rem .7rem; border: 2px solid var(--primary); border-radius: var(--radius-sm); background: #fff; min-height: 58px; }
.change { text-align: center; padding: 1rem 0; }
.change .amt { font-size: 3.4rem; font-weight: 800; color: var(--primary); line-height: 1; }

/* modal */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20, 28, 18, .55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; }
.modal.wide { max-width: 1120px; }
.modal.narrow { max-width: 440px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .8rem 1rem; border-bottom: 1px solid var(--divider); }
.modal-body { padding: 1rem; }
.modal-foot { padding: .8rem 1rem; border-top: 1px solid var(--divider); display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.x { border: 0; background: transparent; font-size: 1.6rem; line-height: 1; width: 42px; height: 42px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.x:hover { background: var(--surface-2); }

/* toast */
#toast-root { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; width: calc(100% - 2rem); max-width: 520px; }
.toast { background: #1f2a1c; color: #fff; padding: .75rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 600; text-align: center; }
.toast.bad { background: var(--danger); }
.toast.good { background: var(--ok); }

table.vt td { padding: .4rem .3rem; }
table.vt input[type=text], table.vt input[type=number] { min-width: 112px; padding: .4rem .5rem; }
table.vt td.money input { min-width: 80px; width: 80px; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; }
.stat { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: .8rem .9rem; }
.stat .k { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat .v { font-size: 1.5rem; font-weight: 750; }
.subtabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; }
.subtabs .chip { min-height: 42px; }
.list-pick { max-height: 300px; overflow-y: auto; border: 1px solid var(--divider); border-radius: var(--radius-sm); }
.list-pick button { display: flex; justify-content: space-between; gap: .6rem; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--divider); background: #fff; padding: .6rem .7rem; cursor: pointer; min-height: 46px; align-items: center; }
.list-pick button:hover { background: var(--surface-2); }
.thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--surface-2); flex: 0 0 auto; }
#cam { width: 100%; min-height: 240px; background: #000; border-radius: var(--radius-sm); overflow: hidden; }

/* receipt (on screen) */
.receipt { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; line-height: 1.35; color: #000; background: #fff; width: 300px; margin: 0 auto; padding: 10px 8px; border: 1px dashed var(--border); }
.receipt .c { text-align: center; } .receipt .b { font-weight: 700; }
.receipt .ln { display: flex; justify-content: space-between; gap: 8px; }
.receipt .ln span:first-child { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.receipt hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
.receipt .big { font-size: 16px; font-weight: 700; }

/* labels (on screen preview) */
.label-sheet { display: flex; flex-wrap: wrap; gap: 8px; }
.label { background: #fff; color: #000; border: 1px dashed var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; padding: 0.04in 0.06in; text-align: center; }
.label .ln1 { font: 700 8pt/1.1 Arial, Helvetica, sans-serif; max-height: 2.2em; overflow: hidden; width: 100%; }
.label .ln2 { font: 7pt/1.1 Arial, Helvetica, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.label .pr { font: 700 11pt/1.1 Arial, Helvetica, sans-serif; }
.label svg { max-width: 100%; height: auto; display: block; }

#print-root { display: none; }

@media (max-width: 980px) {
  .topbar { flex-wrap: wrap; row-gap: .3rem; }
  .topbar .brand { flex: 1 1 auto; }
  .topbar .tabs { order: 3; flex: 1 1 100%; }
  .topbar .who .btn { white-space: nowrap; }
  .register { grid-template-columns: minmax(0, 1fr); }
  .scanbar { position: static; }
  .cart { position: static; max-height: none; }
  .cart-lines { max-height: 46vh; }
  .brand span.name { display: none; }
  .page { padding: .7rem; padding-bottom: 92px; }
  .paybar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--surface); border-top: 1px solid var(--border); padding: .6rem .8rem calc(.6rem + env(safe-area-inset-bottom)); gap: .6rem; align-items: center; box-shadow: 0 -4px 14px rgba(0,0,0,.08); }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .overlay { padding: 0; align-items: stretch; }
  .modal, .modal.wide, .modal.narrow { max-width: none; border-radius: 0; min-height: 100%; }
  .due .amt { font-size: 2.3rem; }
}

@media print {
  @page { margin: 0; }
  body { background: #fff; }
  #app, #modal-root, #toast-root { display: none !important; }
  #print-root { display: block; }
  .receipt { border: 0; width: 72mm; margin: 0; padding: 2mm 2mm 8mm; font-size: 12px; }
  .label-sheet { display: block; }
  .label { border: 0; page-break-after: always; break-after: page; margin: 0; }
  .label:last-child { page-break-after: auto; break-after: auto; }
}
