:root {
  --blue: #0a6cb0;
  --blue-dark: #075488;
  --sand: #f6f1e7;
  --green: #1f9d55;
  --red: #d23b3b;
  --ink: #1c2733;
  --muted: #6b7785;
  --line: #dfe5ec;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--sand); color: var(--ink); font-size: 17px;
}
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--blue); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 20px; }
#tabs button {
  background: rgba(255,255,255,.15); color: #fff; border: 0; padding: 10px 16px;
  margin-left: 6px; border-radius: 10px; font-size: 16px; font-weight: 600; cursor: pointer;
}
#tabs button.active { background: #fff; color: var(--blue); }
#app { padding: 16px; max-width: 1100px; margin: 0 auto; }

h2 { margin: 4px 0 14px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

input, select {
  font-size: 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  width: 100%; background: #fff;
}
button.btn {
  font-size: 18px; font-weight: 600; padding: 13px 18px; border-radius: 12px; border: 0;
  background: var(--blue); color: #fff; cursor: pointer;
}
button.btn.green { background: var(--green); }
button.btn.red { background: var(--red); }
button.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
button.btn:disabled { opacity: .45; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }

/* search results */
.result { display: flex; justify-content: space-between; align-items: center; padding: 14px;
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #fff; cursor: pointer; }
.result:active { background: #eef4fb; }
.result .name { font-weight: 700; font-size: 19px; }
.bal { font-weight: 700; }
.bal.neg { color: var(--red); }
.bal.pos { color: var(--green); }

/* item grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.item {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 10px; text-align: center;
  cursor: pointer; position: relative; user-select: none;
}
.item:active { transform: scale(.97); }
.item .emoji { font-size: 44px; line-height: 1; }
.item .iname { font-weight: 700; margin-top: 8px; }
.item .price { color: var(--muted); font-size: 15px; }
.item .qty {
  position: absolute; top: 8px; right: 8px; background: var(--green); color: #fff;
  min-width: 30px; height: 30px; border-radius: 15px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; padding: 0 6px;
}

/* cart */
.cart-line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cart-line .cname { flex: 1; font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 40px; height: 40px; font-size: 24px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.total-row { display: flex; justify-content: space-between; font-size: 22px; font-weight: 800; margin: 14px 0; }
.preview { font-size: 17px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); font-size: 15px; }
th { color: var(--muted); font-weight: 600; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 20px; background: #eef4fb; color: var(--blue); font-weight: 700; }
.tag.cash { background: #eafaf0; color: var(--green); }
.tag.void { background: #fdeaea; color: var(--red); }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90%;
}
#toast.show { opacity: 1; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 440px; }
.modal h3 { margin-top: 0; }
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.subtabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.subtabs button { padding: 9px 14px; border-radius: 20px; border: 1px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; }
.subtabs button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.big-amount { font-size: 30px; text-align: center; font-weight: 800; }
