:root {
  --bg: #f3f4f1;
  --panel: #ffffff;
  --ink: #17201e;
  --muted: #5d6b67;
  --line: #dde2de;
  --brand: #14433f;
  --brand-2: #0e7a6b;
  --accent: #d9480f;
  --ok: #1f7a3d;
  --warn: #a15c00;
  --bad: #b3261e;
  --soft: #e8f1ee;
  --radius: 8px;
  --gap: 12px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; line-height: 1.35; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.hide { display: none !important; }
.bad { color: var(--bad); }
.good { color: var(--ok); }
.warnc { color: var(--warn); }
.nowrap { white-space: nowrap; }

/* shell */
.top { display: flex; align-items: center; gap: 4px; background: var(--brand); color: #fff; padding: 0 12px; height: 48px; position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; letter-spacing: .3px; margin-right: 14px; white-space: nowrap; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #d4e6e1; text-decoration: none; padding: 12px 11px 11px; line-height: 22px; white-space: nowrap; border-bottom: 3px solid transparent; }
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: #ffb066; font-weight: 600; }
.navmore { position: relative; flex: none; }
.navmore[hidden] { display: none; }
.navmore > button { background: none; border: 0; border-bottom: 3px solid transparent; color: #d4e6e1; font: inherit; padding: 12px 11px 11px; line-height: 22px; white-space: nowrap; cursor: pointer; }
.navmore > button:hover { color: #fff; }
.navmore.dot > button::after { content: ''; display: inline-block; width: 8px; height: 8px; margin-left: 5px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.navmenu { position: absolute; right: 0; top: 100%; display: flex; flex-direction: column; min-width: 190px; background: var(--brand); border-radius: 0 0 8px 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); padding: 4px 0; z-index: 40; }
.navmenu[hidden] { display: none; }
.navmenu a { color: #d4e6e1; text-decoration: none; padding: 10px 16px; white-space: nowrap; }
.navmenu a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.navmenu .badge { margin-left: 5px; padding: 0 6px; border-radius: 9px; background: var(--accent); color: #fff; font-size: .75rem; }
.navmenu .badge:empty { display: none; }
.who { display: flex; gap: 8px; align-items: center; white-space: nowrap; font-size: .85rem; color: #d4e6e1; }
.who button { background: none; border: 1px solid #5d8a83; color: #fff; border-radius: 6px; padding: 4px 8px; cursor: pointer; }
.page { padding: var(--gap); max-width: 1500px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--gap); }
.head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); margin-bottom: var(--gap); flex-wrap: wrap; }

/* controls */
input, select, textarea { background: #fff; border: 1px solid #b9c3be; border-radius: 6px; padding: 8px 10px; min-height: 38px; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: var(--brand-2); }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: .85rem; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { font-size: 1rem; color: var(--ink); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--gap); }
.btn { border: 1px solid #b9c3be; background: #fff; border-radius: 6px; padding: 8px 13px; min-height: 38px; cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { background: #0a6a5d; }
.btn.danger { color: var(--bad); border-color: #e0b4b0; }
.btn.small { padding: 4px 9px; min-height: 30px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
a.btn { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; }
.seg { display: inline-flex; border: 1px solid #b9c3be; border-radius: 6px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: #fff; padding: 8px 13px; min-height: 38px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand-2); color: #fff; }

/* tables */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid #edf0ed; vertical-align: middle; }
th.num { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--soft); }
tr.off td { color: var(--muted); text-decoration: line-through; }
.tag { display: inline-block; font-size: .75rem; padding: 1px 7px; border-radius: 10px; background: var(--soft); color: var(--brand); }
.tag.warn { background: #fdf0d9; color: var(--warn); }
.tag.bad { background: #fbe6e4; color: var(--bad); }
.tag.owner { background: #fdf0d9; color: var(--warn); }

.nav .badge { margin-left: 5px; padding: 0 6px; border-radius: 9px; background: var(--accent); color: #fff; font-size: .75rem; }
.nav .badge:empty { display: none; }

/* item photos */
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.photo { position: relative; margin: 0; width: 96px; height: 96px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo figcaption { position: absolute; left: 4px; right: 4px; bottom: 4px; display: flex; justify-content: space-between; align-items: flex-end; gap: 4px; }
.photo figcaption .x { background: var(--panel); border-radius: 50%; }
.photo.add { display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer; color: var(--brand); border-style: dashed; font-size: .85rem; }

/* editing a saved bill */
.editbar { display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap; background: #fdf0d9; color: var(--warn); border: 1px solid #f1d3a1; border-radius: var(--radius); padding: 8px 12px; }
.editbar b { color: var(--ink); }

/* rights on the Users screen */
.rights { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 16px; }
.rights h3 { grid-column: 1 / -1; margin-top: 8px; font-size: .9rem; color: var(--muted); }
.rights label { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
.rights input { width: auto; min-height: 0; }

/* pos */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--gap); height: calc(100vh - 48px); padding: var(--gap); }
.pos-main { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.scanbox { position: relative; }
.scanbox input { font-size: 1.25rem; min-height: 52px; border: 2px solid var(--brand-2); padding-left: 14px; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #9fb0aa; border-radius: 0 0 8px 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); z-index: 15; max-height: 52vh; overflow-y: auto; }
.sug { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #edf0ed; align-items: center; }
.sug.on, .sug:hover { background: var(--soft); }
.sug .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.partybar { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; flex-wrap: wrap; }
.partybar .pname { font-weight: 600; }
.cart { flex: 1; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-y: auto; }
.cart table { min-width: 560px; }
.cart th { position: sticky; top: 0; background: #f7f8f6; z-index: 1; }
.cart td input { min-height: 34px; padding: 4px 6px; text-align: right; width: 84px; }
.cart .nm { font-weight: 600; }
.cart tr.flash td { background: #dff3e7; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.x { background: none; border: 0; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 2px 8px; line-height: 1; }
.x:hover { color: var(--bad); }
.chip { border: 1px solid #e5c389; background: #fdf0d9; color: #7a4600; font-size: .75rem; border-radius: 10px; padding: 0 7px; cursor: pointer; }
.pos-side { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }
.totalbox { background: var(--brand); color: #fff; border-radius: var(--radius); padding: 12px 14px; }
.totalbox .lbl { font-size: .85rem; color: #b9d4cd; }
.totalbox .amt { font-size: 2.3rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sumrow { display: flex; justify-content: space-between; padding: 2px 0; font-variant-numeric: tabular-nums; }
.paybtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.paybtn { border: 1px solid #b9c3be; background: #fff; border-radius: var(--radius); padding: 11px 8px; cursor: pointer; font-weight: 600; font-size: 1rem; }
.paybtn:hover { background: var(--soft); }
.paybtn.main { grid-column: 1 / -1; background: var(--brand-2); border-color: var(--brand-2); color: #fff; font-size: 1.15rem; padding: 14px 8px; }
.paybtn.main:hover { background: #0a6a5d; }
.key { font-size: .72rem; opacity: .75; font-weight: 500; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 5px; }
.mobilebar { display: none; }

.scanrow { display: flex; gap: 8px; align-items: stretch; }
.scanrow .scanbox { flex: 1; min-width: 0; }
.camera { display: none; }
.touch .camera { display: block; background: var(--brand-2); border-color: var(--brand-2); color: #fff; font-weight: 600; padding: 8px 16px; }
.partybar { position: relative; }
.partybar .suggest { top: calc(100% + 2px); }
.partybar .sug { grid-template-columns: minmax(0, 1fr) auto auto; }

/* variant table */
.vfilters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.vfilters #vq { flex: 1 1 220px; width: auto; }
.vfilters select { width: auto; max-width: 170px; }
.vtable { max-height: 54vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.vtable th { position: sticky; top: 0; background: #f7f8f6; z-index: 1; }
.vtable td { padding: 4px 8px; cursor: pointer; }
.vtable td.vq { width: 76px; }
.vtable .vq input { width: 62px; min-height: 32px; padding: 3px 6px; text-align: right; }
.vtable tr.on td { background: var(--soft); }
.vtable tr.picked td { background: #dff3e7; }
.vtable tr.nostock td { color: var(--muted); }
.vtable .vjoin { display: none; }

/* camera */
#camui { position: fixed; inset: 0; z-index: 70; background: #000; color: #fff; }
#camui video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-aim { position: absolute; left: 8%; right: 8%; top: 36%; height: 22%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
.cam-good .cam-aim { border-color: #5fe08a; }
.cam-bad .cam-aim { border-color: #ff7a6e; }
.cam-top { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: rgba(0, 0, 0, .55); }
.cam-top .btn, .cam-bottom .btn { color: var(--ink); }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); background: rgba(0, 0, 0, .7); display: flex; flex-direction: column; gap: 8px; }
#cammsg { font-size: 1.05rem; font-weight: 600; min-height: 1.4em; }
.cam-good #cammsg { color: #8ff0ae; }
.cam-bad #cammsg { color: #ffb0a8; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--gap); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat .l { font-size: .8rem; color: var(--muted); }
.stat .v { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--gap); align-items: start; }

/* modal */
.backdrop { position: fixed; inset: 0; background: rgba(15, 25, 22, .5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; z-index: 50; overflow-y: auto; }
.dialog { background: #fff; border-radius: 10px; width: 100%; max-width: 520px; padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 16px 48px rgba(0, 0, 0, .3); }
.dialog.wide { max-width: 900px; }
.dialog .head { margin: 0; }
.dlgfoot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.bigtotal { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.payin { display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: center; }
.change { background: #dff3e7; color: #155d2e; border-radius: 6px; padding: 8px 12px; font-size: 1.2rem; font-weight: 600; display: flex; justify-content: space-between; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--brand); }
.logincard { background: #fff; border-radius: 12px; padding: 22px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; }
.logincard h1 { text-align: center; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pinpad button { min-height: 52px; font-size: 1.25rem; border: 1px solid #b9c3be; background: #fff; border-radius: 8px; cursor: pointer; }
.pinpad button:hover { background: var(--soft); }

/* toast */
#toasts { position: fixed; right: 14px; bottom: 14px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: min(92vw, 400px); }
.toast { background: #17201e; color: #fff; border-radius: 8px; padding: 10px 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.toast.bad { background: var(--bad); }
.toast.good { background: var(--ok); }

/* label preview */
.labelprev { width: 100mm; max-width: 100%; height: 25mm; border: 1px dashed #9fb0aa; background: #fff; overflow: hidden; }

@media (max-width: 860px) {
  .pos { display: flex; flex-direction: column; height: auto; min-height: calc(100vh - 48px); padding: 8px 8px 84px; }
  .cart { min-height: 40vh; overflow: visible; }
  .cart table { min-width: 0; }
  .cart th.c-amt, .cart td.c-amt { display: none; }
  .cart td input { width: 62px; }
  .pos-side .paybtns, .pos-side .totalbox { display: none; }
  .mobilebar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--brand); color: #fff; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); align-items: center; justify-content: space-between; gap: 10px; z-index: 30; }
  .mobilebar .amt { font-size: 1.5rem; font-weight: 700; }
  .mobilebar button { background: #ffb066; color: #33210f; border: 0; border-radius: 8px; padding: 12px 22px; font-weight: 700; font-size: 1rem; }
  .brand { display: none; }
  .who span { display: none; }
  .key { display: none; }
  .vtable .vc, .vtable .c-bar { display: none; }
  .vtable .vjoin { display: table-cell; }
  .vfilters select { flex: 1 1 40%; max-width: none; }
  .vtable { max-height: 48vh; }
  input, select { font-size: 16px; }
  .scanbox input { font-size: 1.1rem; }
}
