:root {
  color-scheme: light;
  --bg: #f5f2ea;
  --panel: #fbf8f1;
  --line: #1d1d1d;
  --soft: #d8d1c4;
  --accent: #1f5c52;
  --accent-2: #9f482d;
  --text: #111;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.15 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.locked {
  overflow: hidden;
}

body.locked #app {
  display: none;
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  min-height: 34px;
  padding: 0 10px;
  min-width: 0;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  min-height: 34px;
  border-radius: 0;
}

button.active,
.tab.active,
.mode.active {
  background: var(--accent);
  color: #fff;
}

button:disabled {
  opacity: .45;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  min-height: 34px;
  padding: 0 10px;
}

#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.top {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  display: grid;
  gap: 6px;
}

.topline,
.addline,
.row,
.payModes {
  display: grid;
  grid-auto-flow: column;
  gap: 6px;
  align-items: center;
}

.topline {
  grid-template-columns: 1fr auto auto;
}

.total {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
}

.meta {
  display: grid;
  justify-items: end;
  gap: 2px;
  font-size: 12px;
  color: #444;
}

.meta span {
  max-width: 16ch;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.actions {
  display: grid;
  grid-auto-flow: column;
  gap: 6px;
}

.addline,
.row {
  grid-template-columns: 1fr auto;
}

.scanControls {
  grid-template-columns: 1fr auto auto;
}

.main {
  min-height: 0;
  position: relative;
}

.pane {
  position: absolute;
  inset: 0;
  display: none;
  padding: 8px;
  gap: 8px;
  align-content: start;
  min-height: 0;
}

.pane.active {
  display: grid;
}

.camera,
.cart,
.editor,
.paybox,
.cashbox {
  border: 1px solid var(--line);
  background: var(--panel);
}

.camera {
  position: relative;
  height: min(42dvh, 340px);
  overflow: hidden;
}

.camera video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cameraState {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 3px 6px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 11px;
}

.cart {
  min-height: 0;
  overflow: hidden;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 4px;
}

.cartRow {
  border: 1px solid var(--soft);
  background: #fff;
  padding: 6px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
}

.cartRow.selected {
  border-color: var(--accent);
  background: #eef5f2;
}

.cartName {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cartMeta,
.cartValue,
.payText,
.hit {
  font-size: 12px;
  color: #444;
}

.editor,
.paybox {
  padding: 6px;
  gap: 6px;
  display: grid;
}

.editor .row {
  grid-template-columns: 1fr 1fr auto;
}

.editor .row:nth-child(2) {
  grid-template-columns: auto 1fr auto auto;
}

.value {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
}

.hits {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  overflow: hidden;
}

.hit {
  border: 1px solid var(--soft);
  background: #fff;
  padding: 5px 8px;
  line-height: 1.1;
}

.payModes {
  grid-template-columns: repeat(3, 1fr);
}

.paymentPanel {
  display: none;
  gap: 8px;
}

.paymentPanel.active {
  display: grid;
}

.payHead {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}

.payTotal {
  border: 1px solid var(--line);
  background: #fff;
  min-height: 34px;
  display: grid;
  align-items: center;
  padding: 0 10px;
  font-size: 22px;
  font-weight: 700;
}

.paybox {
  min-height: 0;
  align-content: start;
  justify-items: center;
}

.paybox a {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 12px;
  text-align: center;
  word-break: break-all;
}

.paybox img {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  background: #fff;
  image-rendering: pixelated;
}

.cashbox {
  padding: 6px;
  display: grid;
  gap: 6px;
}

.cashLine {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 6px;
  align-items: center;
}

.cashLabel {
  font-size: 12px;
  color: #444;
}

.cashAmount {
  border: 1px solid var(--line);
  background: #fff;
  min-height: 34px;
  display: grid;
  align-items: center;
  padding: 0 10px;
  font-weight: 700;
}

.cashPad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.cashPad button {
  min-height: 42px;
}

.nav {
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}

.tab {
  min-height: 42px;
  border-left: 0;
  border-bottom: 0;
}

.tab:first-child {
  border-left: 1px solid var(--line);
}

.tab:last-child {
  border-right: 1px solid var(--line);
}

button,
input,
select,
.camera,
.cart,
.editor,
.paybox,
.cashbox,
.hit,
.cartRow,
.value {
  box-shadow: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: var(--bg);
  z-index: 50;
  padding: 0;
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen.active {
  display: grid;
}

.authShell {
  width: min(100vw, 440px);
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  gap: 18px;
  align-content: center;
  justify-items: stretch;
  padding: 28px;
  text-align: center;
}

.authLogo {
  width: min(48vw, 120px);
  height: auto;
  justify-self: center;
  margin-bottom: 8px;
}

.authForm {
  display: grid;
  gap: 10px;
}

.hint {
  min-height: 16px;
  font-size: 12px;
  color: #944;
}

.successCard {
  text-align: center;
  width: min(100vw, 420px);
  padding: 24px;
  display: grid;
  gap: 16px;
}

.successText {
  font-size: 22px;
  font-weight: 700;
}

.successCard input {
  text-align: center;
}

.successCard .row {
  grid-template-columns: repeat(2, 1fr);
}

.customerShell {
  width: min(100vw, 640px);
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  padding: 36px 20px 24px;
}

.customerLogo {
  width: min(42vw, 170px);
  height: auto;
  border: 0;
  background: transparent;
}

.customerShell #customerQr {
  width: min(86vw, 420px);
  height: min(86vw, 420px);
  border: 0;
  background: transparent;
}

.customerSteps {
  display: grid;
  gap: 10px;
  font-size: 19px;
  line-height: 1.35;
  max-width: 34ch;
  width: 100%;
}

.customerStep {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.stepNum {
  width: 24px;
  text-align: center;
  font-weight: 700;
  line-height: 1.2;
}

.customerStep div:last-child {
  padding-top: 1px;
}

.closeCorner {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: #111;
  opacity: 1;
}

.otherText {
  border: 1px solid var(--line);
  background: #fff;
  min-height: 72px;
  display: grid;
  place-items: center;
  font-size: 16px;
}

@media (max-width: 380px) {
  .total {
    font-size: 21px;
  }

  .camera {
    height: 38dvh;
  }

  .cashLine {
    grid-template-columns: auto 1fr;
  }

  .authShell {
    padding: 22px 16px;
  }

  .customerSteps {
    font-size: 17px;
  }
}
