/* cm-scan — v0.1, самодостаточные стили, без внешних шрифтов/иконок. */
:root {
  --ink: #04101f;
  --accent: #4800ff;
  --bg: #ffffff;
  --muted: #6b7280;
  --danger: #b3261e;
  --ok: #1c7a3f;
  --surface: #f3f2f7;
}

.lang-en, .lang-ru, .lang-kz { display:none; }
html[data-lang="en"] .lang-en,
html[data-lang="ru"] .lang-ru,
html[data-lang="kz"] .lang-kz { display:inline; }

.language-toggle {
  position:fixed;
  z-index:20;
  top:max(12px, env(safe-area-inset-top));
  right:12px;
  padding:8px 14px;
  border:0;
  border-radius:8px;
  color:#fff;
  background:#111827;
  box-shadow:0 0 10px #00D4FF, 0 0 16px #D81BFF;
  font-size:16px;
  cursor:pointer;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  flex: 1 1 auto;
  display: none;
  flex-direction: column;
  min-height: 0;
}
.screen.active { display: flex; }

/* ---------- стартовый экран ---------- */
#screen-start {
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  text-align: center;
}

.brand-title {
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
}

.scan-btn {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  box-shadow: 0 0 0 1px rgba(4, 16, 31, 0.08), 0 12px 28px rgba(4, 16, 31, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.scan-btn:active { transform: scale(0.96); }
.scan-btn img {
  width: 62%;
  height: 62%;
  object-fit: contain;
  pointer-events: none;
}

.scan-btn-label {
  font-size: 17px;
  font-weight: 600;
  margin-top: 2px;
}

.secondary-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 4px;
  text-decoration: underline;
}

.file-fallback {
  margin-top: 4px;
}
.file-fallback input[type="file"] { display: none; }

/* ---------- экран камеры ---------- */
#screen-camera {
  position: relative;
  background: #000;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

#capture-canvas { display: none; }

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.crosshair {
  width: min(72vw, 72vh);
  height: min(72vw, 72vh);
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.32);
  position: relative;
}
.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.55);
}
.crosshair::before { left: 50%; top: -10px; bottom: -10px; width: 1px; transform: translateX(-50%); }
.crosshair::after { top: 50%; left: -10px; right: -10px; height: 1px; transform: translateY(-50%); }

.camera-status {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 15px;
  padding: 0 16px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.camera-controls {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  pointer-events: auto;
}

.round-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pill-btn {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  cursor: pointer;
}

/* ---------- экран "нет камеры" / результат ---------- */
#screen-error,
#screen-result {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 28px 22px;
  overflow-y: auto;
}

.status-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}
.status-icon.ok { background: rgba(28, 122, 63, 0.12); color: var(--ok); }
.status-icon.warn { background: rgba(179, 38, 30, 0.1); color: var(--danger); }
.status-icon.info { background: var(--surface); color: var(--ink); }

h1.result-title { font-size: 20px; margin: 4px 0 0; }
p.result-text { font-size: 15px; color: var(--muted); margin: 0; max-width: 380px; line-height: 1.5; }

.result-fields {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-fields .row { display: flex; justify-content: space-between; gap: 12px; }
.result-fields .k { color: var(--muted); }
.result-fields .v { font-weight: 600; word-break: break-all; overflow-wrap: anywhere; text-align: right; }

/* На узком экране пара «ключ — значение» в одну строку не помещается:
   идентификатор и адрес записи длинные и вылезают за край. Складываем в
   столбик и выравниваем по левому краю — читается заметно лучше. */
@media (max-width: 480px) {
  .result-fields .row { flex-direction: column; gap: 2px; }
  .result-fields .v { text-align: left; font-size: 13px; }
}

.primary-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 26px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.ghost-btn {
  display: inline-block;
  background: none;
  color: var(--ink);
  border: 1px solid rgba(4, 16, 31, 0.2);
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- футер-дисклеймер ---------- */
.footer-note {
  flex: 0 0 auto;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg);
}
#app.camera-mode #global-footer { display: none; }
#screen-camera .footer-note {
  position: absolute;
  bottom: 86px;
  left: 0;
  right: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  padding: 0 16px;
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e14;
    --ink: #f2f3f5;
    --surface: #1a1e27;
    --muted: #9aa1ad;
  }
}
