* {
  box-sizing: border-box
}

:root {
  --bg: #F5F7F8;
  --surface: #fff;
  --surface-2: #f8fafb;
  --text: #252525;
  --muted: #666;
  --border: #E3E7EA;
  --ink: #2A2C30;
  --sheen: linear-gradient(145deg, #5B5F66 0%, #383A3F 42%, #26282C 62%, #45484E 100%);
  --edge: inset 0 1px 0 rgba(255, 255, 255, .16), inset 0 -1px 0 rgba(0, 0, 0, .35);
  --danger: #E5484D;
  --ok: #24734d;
  --warn: #b26a00
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Poppins", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5
}

button,
input,
select {
  font: inherit
}

button {
  cursor: pointer
}

button:disabled {
  opacity: .6;
  cursor: not-allowed
}

.hidden {
  display: none !important
}

.top {
  min-height: 64px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px clamp(14px, 4vw, 40px);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px)
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--sheen);
  box-shadow: var(--edge);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 19px
}

.brand strong {
  display: block;
  font-size: 15px
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
  justify-content: flex-end
}

.page {
  width: min(1000px, calc(100% - 24px));
  margin: 22px auto 60px
}

.state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 34px;
  text-align: center;
  max-width: 460px;
  margin: 50px auto
}

.state h1 {
  margin: 0 0 8px;
  font-size: 24px
}

.state p {
  color: var(--muted);
  margin: 0 0 14px
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #e3e7e9;
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 14px
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

.stack {
  display: grid;
  gap: 10px;
  text-align: left
}

.fc {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  min-height: 42px
}

.fc:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(42, 44, 48, .14)
}

.primary,
.ghost-button {
  border-radius: 9px;
  padding: 10px 16px;
  font-weight: 700;
  border: 1px solid transparent;
  min-height: 42px;
  white-space: nowrap
}

.primary {
  background: var(--sheen);
  color: #fff;
  box-shadow: var(--edge), 0 6px 16px rgba(0, 0, 0, .2)
}

.primary:hover {
  filter: brightness(1.12)
}

.ghost-button {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center
}

.ghost-button.sm,
.sm {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 12px
}

.danger {
  background: #fff;
  border: 1px solid #e8caca;
  color: #8e3030;
  border-radius: 9px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 12px
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 2px
}

.tabs button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 9px;
  padding: 9px 16px;
  font-weight: 700;
  color: var(--muted)
}

.tabs button.on {
  background: var(--sheen);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--edge)
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 12px 36px rgba(22, 28, 32, .06)
}

.card h2 {
  font-size: 17px;
  margin: 0 0 4px
}

.help {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 12px
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px
}

.head small {
  color: var(--muted)
}

.big {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em
}

.row {
  display: flex;
  gap: 10px;
  margin: 10px 0;
  flex-wrap: wrap;
  align-items: center
}

.row>.fc {
  flex: 1 1 150px;
  width: auto
}

.row.pay>.fc:nth-child(1) {
  flex: 0 1 150px
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px
}

.check input {
  accent-color: var(--ink)
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 8px
}

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2)
}

.item.click {
  cursor: pointer
}

.item.click:hover {
  background: #fff;
  border-color: #c7ced2
}

.item small {
  display: block;
  color: var(--muted);
  font-size: 12px
}

.item .amt {
  font-weight: 800;
  white-space: nowrap
}

.item .acts {
  display: flex;
  gap: 6px;
  align-items: center
}

.item label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  cursor: pointer
}

.item input[type=checkbox] {
  accent-color: var(--ink);
  width: 17px;
  height: 17px
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 16px;
  font-size: 13px
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600
}

.chip.add {
  border-style: dashed;
  color: var(--muted)
}

.tag {
  display: inline-block;
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--ink);
  margin-right: 6px
}

.tag.void {
  background: var(--danger)
}

.tag.ok {
  background: var(--ok)
}

.err {
  color: var(--danger);
  font-size: 13px;
  margin: 8px 0 0
}

.amounts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 8px
}

.amounts label {
  font-size: 12px;
  font-weight: 700;
  display: block;
  margin-bottom: 4px
}

.void-row {
  opacity: .55;
  text-decoration: line-through
}

dialog {
  border: 0;
  border-radius: 14px;
  padding: 22px;
  max-width: min(460px, 94vw);
  width: 100%;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35)
}

dialog::backdrop {
  background: rgba(20, 22, 26, .5)
}

dialog h3 {
  margin: 0 0 6px
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 50;
  max-width: 92vw
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0)
}

.toast.error {
  background: #8e3030
}

.receipt {
  font-size: 13px
}

.receipt h3 {
  text-align: center;
  margin: 0
}

.receipt .c {
  text-align: center;
  color: var(--muted);
  margin: 0 0 10px
}

.receipt table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0
}

.receipt td {
  padding: 5px 0;
  border-bottom: 1px dashed var(--border)
}

.receipt td:last-child {
  text-align: right;
  white-space: nowrap
}

.receipt .tot td {
  font-weight: 800;
  border-bottom: 0;
  font-size: 15px
}

.receipt .meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px
}

.receipt .meta span:nth-child(odd) {
  color: var(--muted)
}

@media print {

  .no-print,
  .top,
  .tabs {
    display: none !important
  }

  body {
    background: #fff
  }

  .page {
    margin: 0;
    width: 100%
  }

  .card {
    box-shadow: none;
    border: 0
  }

  body.print-receipt .page {
    display: none
  }

  body.print-receipt dialog {
    position: static;
    box-shadow: none;
    max-width: none;
    padding: 0
  }
}

@media(max-width:640px) {
  .row>.fc {
    flex: 1 1 100%
  }

  .row.pay>.fc:nth-child(1) {
    flex: 1 1 100%
  }

  .actions {
    justify-content: stretch
  }

  .actions button {
    flex: 1
  }
}

@media (prefers-reduced-motion:reduce) {
  * {
    transition: none !important;
    animation: none !important
  }
}

.opt {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px
}

.selbox {
  display: flex;
  align-items: center;
  padding-right: 2px
}

.selbox input {
  accent-color: var(--ink);
  width: 18px;
  height: 18px
}

.item.picked {
  border-color: var(--ink);
  background: #fff
}

.tag.grp {
  background: #6A6E75
}

.bulk {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 20px));
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  z-index: 20
}

.bulk>div {
  flex: 1;
  min-width: 0
}

.bulk small {
  display: block;
  opacity: .75;
  font-size: 12px
}

.bulk .fc {
  width: auto;
  min-height: 40px
}

.bulk .ghost-button {
  min-height: 40px
}

.bulk .primary {
  background: #fff;
  color: var(--ink);
  box-shadow: none
}

#receiptDialog {
  max-height: 88vh;
  overflow: auto
}

@media print {
  .bulk {
    display: none !important
  }

  .receipt {
    page-break-after: always
  }

  .receipt:last-child {
    page-break-after: auto
  }

  #receiptDialog {
    max-height: none;
    overflow: visible
  }
}

@media(max-width:640px) {
  .bulk {
    flex-wrap: wrap
  }

  .bulk>div {
    flex: 1 1 100%
  }

  .bulk .fc,
  .bulk button {
    flex: 1
  }
}

.dirty {
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
  align-self: center;
  margin-right: auto
}

.chk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px 12px;
  margin: 6px 0 4px
}

.chk-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer
}

.chk-grid input {
  accent-color: var(--ink)
}

#clsDialog {
  max-width: min(520px, 94vw)
}