:root {
  --bg: #1a1f28;
  --panel: #252a35;
  --line: #333a48;
  --text: #e7ebf3;
  --muted: #9ba4b4;
  --blue: #0b6dff;
  --danger-bg: #4a1f28;
  --danger: #fca5a5;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #293245, #1a1f28);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
body.camera-open { overflow: hidden; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 12px;
}

h1 { margin: 0 0 6px; font-size: 26px; }
h2 { margin: 0 0 10px; font-size: 18px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.manual-row { display: flex; gap: 8px; flex-wrap: wrap; }

button {
  border: 1px solid #3d74be;
  background: #0f2749;
  color: #dbe9ff;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
#startBtn, #manualCheckBtn, #imageCheckBtn { background: var(--blue); border-color: var(--blue); color: #fff; }
.danger-btn { background: #6d2732; border-color: #8d3847; color: #ffdbe0; }

input[type="text"], input[type="password"], input[type="file"], .auth-input {
  flex: 1;
  min-width: 260px;
  border: 1px solid #3a4252;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  background: #1d222c;
  color: var(--text);
}

.camera-wrap {
  position: fixed;
  inset: 0;
  z-index: 9999;
  margin: 0;
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
}
.camera-topbar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 64px;
  display: grid;
  grid-template-columns: 110px 1fr 110px;
  align-items: center;
  padding: 0 8px;
  background: rgba(8, 12, 20, 0.72);
  border-bottom: 1px solid rgba(255, 255, 255, 0.24);
  z-index: 2;
}
.camera-close-btn {
  justify-self: start;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 8px 10px;
}
.camera-title {
  text-align: center;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.camera-topbar-spacer { width: 100%; }

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
  border-radius: 0;
}
.frame {
  pointer-events: none;
  position: absolute;
  left: 24%;
  top: 22%;
  width: 52%;
  height: 56%;
  border: 2px solid rgba(255,255,255,.92);
  border-radius: 8px;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}
.frame.scanned {
  border-color: #2bff8f;
  box-shadow: 0 0 0 2px rgba(43, 255, 143, 0.35), 0 0 28px rgba(43, 255, 143, 0.45);
  background: rgba(43, 255, 143, 0.06);
}
.hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 30px;
  background: rgba(0,0,0,.35);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 13px;
}

.muted { color: var(--muted); }
.last-code-text {
  margin: 0;
  word-break: break-word;
}
.last-code-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-start;
}
.copy-status {
  color: #8ef2b0;
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
}
.scan-success {
  color: #8ef2b0;
  background: rgba(30, 91, 55, 0.35);
  border: 1px solid rgba(94, 216, 143, 0.5);
  border-radius: 8px;
  padding: 7px 9px;
  margin: 6px 0;
  font-weight: 600;
}

.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  white-space: pre-wrap;
}
.status {
  color: #9fb0cc;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  white-space: pre-wrap;
}
.hidden { display: none; }
.result-modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.result-modal.hidden {
  display: none;
}
.result-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 16, 0.74);
}
.result-modal-card {
  position: relative;
  width: min(780px, 100%);
  max-height: 92vh;
  background: #252a35;
  border: 1px solid #333a48;
  border-radius: 12px;
  overflow: hidden;
}
.result-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #333a48;
}
.result-modal-header h2 {
  margin: 0;
}
.result-modal-body {
  max-height: calc(92vh - 64px);
  overflow: auto;
  padding: 12px;
}
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: #1a1f28;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-overlay.hidden {
  display: none;
}
.auth-card {
  width: min(420px, 100%);
  background: #252a35;
  border: 1px solid #333a48;
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 8px;
}
.auth-card .auth-input {
  width: 100%;
  min-width: 0;
}
.auth-hint {
  margin: 0 0 4px;
}

.field {
  border: 1px solid #3a4252;
  border-radius: 8px;
  padding: 8px;
  background: #1d222c;
  margin-bottom: 6px;
}
.field .name { color: #8d96a6; font-size: 12px; }
.field .value { color: #e7ebf3; font-weight: 600; margin-top: 3px; word-break: break-word; }
