:root {
  --bg: #f4fbf5;
  --card: rgba(255, 255, 255, 0.96);
  --line: rgba(24, 115, 60, 0.14);
  --line-strong: rgba(24, 115, 60, 0.24);
  --text: #143120;
  --muted: #68806f;
  --accent: #1d944b;
  --accent-deep: #136d38;
  --accent-soft: #def4e4;
  --shadow: 0 24px 60px rgba(28, 103, 58, 0.12);
  --danger: #d14747;
  --success: #197742;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(29, 148, 75, 0.12), transparent 25%),
    linear-gradient(180deg, #fcfffc 0%, #edf7ef 48%, #e4f1e7 100%);
}

button,
input,
a {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
}

.topbar {
  width: min(1140px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 12px;
}

.workspace {
  width: min(1140px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0 40px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  line-height: 1.05;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-family: "Palatino Linotype", "Book Antiqua", serif;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.panel-grid,
.button-row,
.result-meta {
  display: grid;
  gap: 18px;
}

.panel-grid {
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
}

.card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.form-card,
.preview-card {
  padding: 24px;
}

.section-head {
  margin-bottom: 20px;
}

.field {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.field span {
  font-size: 0.95rem;
}

.field input,
.field textarea {
  width: 100%;
  padding: 15px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fcfffd;
  color: var(--text);
  outline: none;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input[readonly] {
  background: #f3faf5;
  font-weight: 700;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(29, 148, 75, 0.45);
  box-shadow: 0 0 0 5px rgba(29, 148, 75, 0.08);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.btn--small {
  min-height: 42px;
  width: auto;
  padding: 10px 16px;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn--primary {
  background: linear-gradient(135deg, #1c924b 0%, #36b664 100%);
  color: #fff;
}

.btn--secondary {
  background: #fff;
  color: var(--accent-deep);
  border: 1px solid var(--line-strong);
}

.message {
  min-height: 1.4rem;
  margin: 14px 0 0;
}

.message--error {
  color: var(--danger);
}

.message--success {
  color: var(--success);
}

.scan-block {
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fbfffc;
}

.scan-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.scan-block__head span {
  font-size: 0.95rem;
  font-weight: 700;
}

.scan-status {
  margin: 12px 0 0;
  color: var(--muted);
  word-break: break-word;
}

.preview-empty {
  display: grid;
  place-items: center;
  min-height: 420px;
  border-radius: 24px;
  border: 1px dashed rgba(24, 115, 60, 0.18);
  background: linear-gradient(180deg, #ffffff, #f5fbf6);
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.hidden {
  display: none;
}

.qr-result {
  display: grid;
  gap: 20px;
}

.qr-frame {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 28px;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffffff, #f5fbf6);
  border: 1px solid rgba(24, 115, 60, 0.1);
}

.qr-frame img {
  width: min(100%, 340px);
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #fff;
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 12px 28px rgba(25, 83, 47, 0.1);
}

.result-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-meta > div {
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--accent-soft);
  border: 1px solid rgba(24, 115, 60, 0.1);
}

.result-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.result-meta strong {
  display: block;
  margin-top: 8px;
  font-size: 1rem;
  word-break: break-word;
}

.scanner-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 24, 14, 0.68);
}

.scanner-modal.hidden {
  display: none;
}

.scanner-modal__card {
  width: min(100%, 560px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  padding: 20px;
}

.scanner-modal__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.scanner-viewport {
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(24, 115, 60, 0.12);
  background: #0c1f13;
  aspect-ratio: 3 / 4;
  min-height: 420px;
}

.scanner-reader,
.scanner-reader video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-reader {
  min-height: 420px;
}

.scanner-reader > div {
  border: 0 !important;
}

.scanner-reader__inactive {
  display: grid;
  place-items: center;
  min-height: 420px;
  color: rgba(255, 255, 255, 0.74);
}

.scanner-message {
  margin: 14px 0 0;
  color: var(--muted);
}

@media (max-width: 900px) {
  .panel-grid,
  .result-meta {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .workspace {
    width: min(100%, calc(100% - 24px));
  }

  .topbar {
    padding-top: 20px;
  }

  .form-card,
  .preview-card {
    padding: 18px;
    border-radius: 22px;
  }

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

  .scan-block__head,
  .scanner-modal__head {
    flex-direction: column;
    align-items: stretch;
  }

  .preview-empty,
  .qr-frame,
  .scanner-viewport,
  .scanner-reader,
  .scanner-reader__inactive {
    min-height: 280px;
    padding: 18px;
  }
}
