* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: #1a1a1a;
  background: #f6f4ef;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.35;
}

main {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

body[data-state="LOGIN"] #screen-login,
body[data-state="SCANNING"] #screen-scan,
body[data-state="QR_SCANNED"] #screen-form,
body[data-state="SUBMITTING"] #screen-form,
body[data-state="ERROR"] #screen-form,
body[data-state="SUCCESS"] #screen-success {
  display: flex;
}

.login-form {
  display: flex;
  flex: 1;
  flex-direction: column;
  margin-top: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
}

.field-label {
  color: #333;
}

.field input {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 2px solid #1a1a1a;
  border-radius: 14px;
  background: #fff;
  color: #1a1a1a;
  font: inherit;
}

h1,
.hint,
.label,
.buyer {
  margin: 0;
  text-align: center;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
}

.hint,
.label {
  margin-top: 8px;
  color: #333;
}

.buyer {
  margin-top: 8px;
  font-size: 1.25rem;
  font-weight: 700;
  word-break: break-word;
}

#reader {
  position: relative;
  width: 100%;
  min-height: 240px;
  margin-top: 20px;
  overflow: hidden;
  border-radius: 16px;
  background: #171717;
}

#reader:empty::before {
  content: "КАМЕРА";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d5d5d5;
  font-weight: 700;
  letter-spacing: 0.12em;
}

#reader video {
  max-width: 100%;
}

.qty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

.qty button,
.qty input {
  height: 64px;
  border: 2px solid #1a1a1a;
  border-radius: 14px;
  background: #fff;
  color: #1a1a1a;
}

.qty button {
  width: 64px;
  padding: 0;
  font-size: 32px;
  line-height: 1;
}

.qty input {
  width: 96px;
  padding: 0 8px;
  font-size: 32px;
  font-weight: 700;
  text-align: center;
}

.message {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  color: #8f1d18;
  background: #fde8e6;
  white-space: pre-line;
}

.message[hidden] {
  display: none;
}

.actions {
  margin-top: auto;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

button {
  min-height: 44px;
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid #0f6b45;
  outline-offset: 2px;
}

.primary {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  background: #0f6b45;
  color: #fff;
  font-size: 1.125rem;
  font-weight: 700;
}

.primary:active:not(:disabled) {
  background: #0c5536;
}

.primary:disabled {
  opacity: 0.55;
}

.ghost {
  width: 100%;
  border: 0;
  background: transparent;
  color: #0f6b45;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

#retry {
  display: none;
}

body[data-state="ERROR"] #retry {
  display: block;
}

body[data-state="ERROR"] #submit-sale {
  display: none;
}

.check {
  margin: 24px 0 8px;
  text-align: center;
  color: #0f6b45;
  font-size: 72px;
  line-height: 1;
}

#screen-success h1 {
  color: #0f6b45;
}
