<?php require_once __DIR__.'/includes/db.php'; if(session_status()===PHP_SESSION_NONE) session_start();
$msg=''; if($_SERVER['REQUEST_METHOD']==='POST'){ $u=trim($_POST['username']??''); $p=trim($_POST['password']??'');
 $st=$mysqli->prepare("SELECT id,username,pass_hash,name FROM users WHERE username=? LIMIT 1"); $st->bind_param('s',$u); $st->execute(); $rs=$st->get_result();
 if($row=$rs->fetch_assoc()){ if(password_verify($p,$row['pass_hash'])){ $_SESSION['uid']=$row['id']; $_SESSION['name']=$row['name']; header('Location: index.php'); exit; } else $msg='Password salah.'; } else $msg='User tidak ditemukan.'; } ?>
<!doctype html><html lang="id"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Login Admin</title><link rel="stylesheet" href="assets/css/admin.css"></head>
<body><div class="container" style="max-width:460px"><div class="card" style="padding:18px;border-radius:16px;margin-top:60px">
<div class="header" style="border:0;padding:0 0 14px 0"><div class="brand"><svg width="36" height="36" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#ef4444"/><rect x="6" y="11" width="12" height="6" fill="#fff"/><polygon points="12,6 15,11 9,11" fill="#fff"/></svg>
<div><strong>Login Admin Desa Mambu</strong><div class="badge">Merah–Putih · Persawahan</div></div></div></div>
<?php if($msg): ?><div class="alert"><?php echo esc($msg); ?></div><?php endif; ?>
<form method="post" style="display:grid;gap:10px"><label>Username</label><input class="input" name="username" required><label>Password</label><input class="input" type="password" name="password" required><button class="btn primary" type="submit">Masuk</button></form>
<div class="note" style="margin-top:10px">Default admin: <b>admin</b> / <b>admin123</b></div></div></div></body></html>
