:root {
  color-scheme: light;
  --blue: #0b3d91;
  --red: #e71921;
  --ink: #162033;
  --muted: #687386;
  --line: #dfe5ef;
  --panel: #ffffff;
  --soft: #f4f7fb;
  --shadow: 0 18px 50px rgba(22, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #ffffff 0%, #f3f6fb 100%);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.brand {
  padding: 12px 10px 18px;
  text-align: center;
}

.brand img {
  display: block;
  width: min(100%, 360px);
  height: auto;
  margin: 0 auto;
}

.scan-panel,
.results-panel {
  background: var(--panel);
  border: 1px solid rgba(11, 61, 145, 0.12);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scan-panel {
  padding: 18px;
}

.results-panel {
  margin-top: 14px;
  padding: 16px;
}

.title-row,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
}

.title-row p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.status-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf3ff;
  color: var(--blue);
  font-weight: 700;
  font-size: 0.78rem;
}

.scan-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.camera-button,
.upload-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.camera-button {
  background: var(--blue);
  box-shadow: 0 12px 26px rgba(11, 61, 145, 0.22);
}

.upload-button {
  background: #168365;
  box-shadow: 0 12px 26px rgba(22, 131, 101, 0.2);
}

.camera-button input,
.upload-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.preview-wrap {
  margin-top: 16px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--soft);
}

.preview-wrap img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.progress {
  margin-top: 16px;
}

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf5;
}

.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--red));
  transition: width 180ms ease;
}

.progress p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.section-head button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  min-height: 36px;
  padding: 0 12px;
  font-weight: 700;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.export-actions button,
#saveButton {
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  min-height: 40px;
  padding: 0 12px;
  font-weight: 800;
}

.export-actions button:first-child {
  background: var(--blue);
}

.fields {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.fields input {
  width: 100%;
  min-height: 45px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--soft);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
}

.fields input.danger-field {
  border-color: var(--red);
  background: #fff3f4;
  color: #8c1016;
  box-shadow: 0 0 0 3px rgba(231, 25, 33, 0.12);
}

.final-card {
  margin-top: 14px;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  padding: 13px;
}

.final-card.danger-card {
  background: #b91c1c;
}

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

.final-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.final-head button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: #0f766e;
  padding: 0 12px;
  font-weight: 800;
}

.final-card pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.65;
}

.final-card pre.danger-text {
  color: #fff7f7;
}

.review-warning {
  margin-top: 14px;
  border: 1px solid rgba(231, 25, 33, 0.28);
  border-radius: 8px;
  background: #fff3f4;
  color: #8c1016;
  padding: 11px 12px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.mrz-box {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.mrz-box label,
.review-check {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.mrz-box textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-size: 0.92rem;
  text-transform: uppercase;
}

.mrz-box button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.review-check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  line-height: 1.3;
  text-transform: none;
}

.review-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.raw-text {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.raw-text summary {
  color: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

.raw-text pre {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  color: #39455a;
  background: var(--soft);
  border-radius: 8px;
  padding: 12px;
}

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

.saved-list p {
  color: var(--muted);
  font-size: 0.9rem;
}

.saved-record {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--soft);
}

.saved-record strong {
  display: block;
  font-size: 0.95rem;
}

.saved-record span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 28px;
  }
}
