<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lead Viewer — Login</title>
<style>
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background:#0d1117; color:#e6edf3; display:flex; justify-content:center; align-items:center; height:100vh; }
.login { background:#161b22; border:1px solid #30363d; border-radius:12px; padding:40px; width:340px; text-align:center; }
.login h1 { font-size:24px; color:#58a6ff; margin-bottom:8px; }
.login p { font-size:13px; color:#8b949e; margin-bottom:24px; }
.login input { width:100%; padding:10px 14px; border-radius:8px; border:1px solid #30363d; background:#0d1117; color:#e6edf3; font-size:14px; margin-bottom:12px; }
.login input:focus { outline:none; border-color:#58a6ff; }
.login button { width:100%; padding:10px; border-radius:8px; border:none; background:#238636; color:#fff; font-size:14px; font-weight:600; cursor:pointer; }
.login button:hover { background:#2ea043; }
.error { color:#da3633; font-size:12px; margin-top:8px; display:none; }
</style>
</head>
<body>
<div class="login" id="loginBox">
  <h1>⚡ Lead Viewer</h1>
  <p>Greater Manchester Trade Leads</p>
  <input type="password" id="pw" placeholder="Password" autofocus onkeydown="if(event.key==='Enter')checkAuth()">
  <button onclick="checkAuth()">Access</button>
  <div class="error" id="err">Wrong password</div>
</div>
<script>
const HASH = '520a3bcf1c7e9d6e17f009978b84316cf99b3b5846bbad91451bd018926a92b3'; // sha256 of 'password'
async function sha256(str) {
  const buf = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(str));
  return Array.from(new Uint8Array(buf)).map(b=>b.toString(16).padStart(2,'0')).join('');
}
async function checkAuth() {
  const pw = document.getElementById('pw').value;
  const hash = await sha256(pw);
  if (hash === HASH || localStorage.getItem('leads_auth') === 'ok') {
    localStorage.setItem('leads_auth', 'ok');
    window.location.href = 'viewer.html';
  } else {
    document.getElementById('err').style.display = 'block';
  }
}
if (localStorage.getItem('leads_auth') === 'ok') window.location.href = 'viewer.html';
</script>
</body>
</html>