:root {
  --bg: #f5efe5;
  --bg-accent: #eadcc2;
  --panel: rgba(255, 251, 245, 0.96);
  --ink: #1f1d1a;
  --muted: #6d6559;
  --line: rgba(61, 45, 24, 0.14);
  --brand: #0b6e4f;
  --brand-strong: #074f39;
  --brand-soft: #dff2eb;
  --warn: #c44b20;
  --ok: #1c7c54;
  --radius: 24px;
  --shadow: 0 18px 50px rgba(74, 53, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(230, 173, 98, 0.25), transparent 28%),
    radial-gradient(circle at left bottom, rgba(11, 110, 79, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
}

.app-shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.panel-hero {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr;
  gap: 18px;
  align-items: end;
}

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

h1,
h2 {
  margin: 0 0 12px;
}

.subtitle {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.hero-status {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.helper-copy,
.section-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.panel {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-weight: 600;
}

input,
select,
textarea,
button,
pre {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fffdfa;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(11, 110, 79, 0.18);
  border-color: rgba(11, 110, 79, 0.35);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  color: white;
  background: var(--brand);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

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

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

button.secondary {
  background: #7c5e2b;
}

.ghost {
  background: transparent;
  color: var(--brand-strong);
  border: 1px solid rgba(11, 110, 79, 0.22);
}

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

.capture-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.action-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(11, 110, 79, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 238, 228, 0.85));
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(38, 31, 20, 0.08);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.action-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(11, 110, 79, 0.28);
}

.tile-kicker {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-strong);
}

.camera-panel {
  margin-bottom: 16px;
  border-radius: 20px;
  padding: 14px;
  background: rgba(28, 24, 19, 0.96);
  color: white;
}

.camera-frame {
  overflow: hidden;
  border-radius: 16px;
  background: black;
}

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

.camera-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.preview-box {
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: 22px;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 242, 234, 0.88)),
    repeating-linear-gradient(
      45deg,
      rgba(11, 110, 79, 0.03) 0,
      rgba(11, 110, 79, 0.03) 10px,
      transparent 10px,
      transparent 20px
    );
}

.preview-box img {
  max-width: 100%;
  max-height: 72vh;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 14px 28px rgba(15, 11, 7, 0.16);
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
  color: var(--muted);
}

.preview-placeholder p {
  margin: 0;
  font-weight: 700;
}

.preview-placeholder span {
  max-width: 320px;
  font-size: 0.95rem;
}

.primary-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.status {
  width: fit-content;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
}

.status.idle,
.status.reading,
.status.verifying {
  background: #f4ead7;
  color: #825d17;
}

.status.confirmed {
  background: #ddf6e9;
  color: var(--ok);
}

.status.not_found,
.status.error {
  background: #fbe3da;
  color: var(--warn);
}

.form-grid,
.dual-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.stack-panel {
  min-width: 0;
}

#resultBox {
  margin: 0;
  min-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: #191612;
  color: #f8f3eb;
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100% - 16px, 1080px);
    padding-top: 10px;
  }

  .panel-hero,
  .capture-actions,
  .primary-actions,
  .form-grid,
  .dual-panel {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px 16px;
  }

  h1 {
    font-size: 2rem;
    line-height: 1.05;
  }

  .camera-actions {
    flex-direction: column;
  }

  .primary-actions button,
  .camera-actions button {
    width: 100%;
  }

  .preview-box {
    min-height: 220px;
  }
}
