:root {
  --bg: #0b0f14;
  --card: #151b23;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --text: #e6edf3;
  --muted: #9aa7b5;
  --border: #2a333f;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 18px calc(32px + env(safe-area-inset-bottom));
  gap: 16px;
  text-align: center;
}

.hidden { display: none !important; }

h1 {
  font-size: 1.7rem;
  margin: 0;
}

p {
  margin: 0;
  opacity: 0.86;
  color: var(--muted);
}

button {
  border: none;
  border-radius: 16px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.14s ease, background 0.14s ease;
}

button:active {
  transform: scale(0.98);
}

.primary {
  background: var(--accent);
  color: #fff;
}

.secondary {
  background: #2a333f;
  color: var(--text);
}

.small-btn {
  padding: 10px 14px;
  font-size: 0.94rem;
}

.small-btn.active {
  background: var(--accent);
  color: #fff;
}

.shutter-btn {
  min-width: 150px;
  padding: 18px 26px;
  font-size: 1.05rem;
}

.row {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.wrap { flex-wrap: wrap; }

input[type="password"] {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1.2rem;
  text-align: center;
  width: 200px;
}

.scanner-screen {
  justify-content: flex-start;
  padding-top: max(20px, env(safe-area-inset-top));
}

.scanner-stage,
.preview-wrap,
.editor-wrap {
  width: min(100%, 560px);
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--card);
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

.scanner-stage {
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: 62vh;
  background: linear-gradient(180deg, #0e141c, #111822);
}

.scanner-video,
.scanner-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scanner-video {
  object-fit: contain;
  background: #05080c;
}

.scanner-overlay {
  pointer-events: none;
}

.scanner-guide {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(11, 15, 20, 0.76);
  backdrop-filter: blur(8px);
  font-size: 0.95rem;
  color: var(--text);
}

.scanner-guide.error {
  color: #fecaca;
}

.scanner-actions {
  width: min(100%, 560px);
}

.secondary-actions button {
  flex: 1 1 220px;
}

.review-screen {
  justify-content: flex-start;
  padding-top: max(20px, env(safe-area-inset-top));
}

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.editor-wrap,
.preview-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 10px;
}

#editor-canvas,
.preview-wrap img {
  display: block;
  max-width: 100%;
  border-radius: 16px;
}

.preview-wrap img {
  max-height: 56vh;
}

.pdf-note {
  font-size: 1.02rem;
  line-height: 1.5;
  padding: 24px;
}

.thumbs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  width: min(100%, 560px);
  padding: 2px 4px 6px;
}

.thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--border);
  background: #111822;
  flex: 0 0 auto;
}

.thumb.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-label {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(11, 15, 20, 0.78);
  color: #fff;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#company-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.company-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.big { font-size: 4rem; }
.error { color: var(--danger); }

@media (max-width: 480px) {
  .screen {
    padding-left: 14px;
    padding-right: 14px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .scanner-stage,
  .preview-wrap,
  .editor-wrap,
  .scanner-actions,
  .thumbs {
    width: 100%;
  }
}
