Spaces:
Sleeping
Sleeping
[Parth Saxena] commited on
Commit ·
368a487
0
Parent(s):
Deploy FraudLens
Browse files- .gitattributes +2 -0
- app.py +139 -0
- app.py.metadata.json +5 -0
- model.pkl +3 -0
- model_metadata.json +69 -0
- requirements.txt +3 -0
- static/app.js +831 -0
- static/app.js.metadata.json +5 -0
- static/images/app_logo.png +3 -0
- static/style.css +1044 -0
- static/style.css.metadata.json +5 -0
- templates/index.html +705 -0
- templates/index.html.metadata.json +5 -0
.gitattributes
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
FraudLens — Backend
|
| 3 |
+
Hugging Face Spaces (Gradio SDK, free tier)
|
| 4 |
+
|
| 5 |
+
Gradio is built on FastAPI, so we run our own FastAPI app and mount
|
| 6 |
+
a minimal Gradio demo on /gradio. HF Spaces detects the gradio import
|
| 7 |
+
and serves the FastAPI app at port 7860 automatically.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from fastapi import FastAPI, Request
|
| 11 |
+
from fastapi.responses import HTMLResponse, JSONResponse
|
| 12 |
+
from fastapi.staticfiles import StaticFiles
|
| 13 |
+
import gradio as gr
|
| 14 |
+
import os
|
| 15 |
+
import pickle
|
| 16 |
+
import json
|
| 17 |
+
import time
|
| 18 |
+
import numpy as np
|
| 19 |
+
|
| 20 |
+
# ─────────────────────────────────────────────
|
| 21 |
+
# Load model
|
| 22 |
+
# ─────────────────────────────────────────────
|
| 23 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 24 |
+
MODEL_PATH = os.path.join(BASE_DIR, "model.pkl")
|
| 25 |
+
METADATA_PATH = os.path.join(BASE_DIR, "model_metadata.json")
|
| 26 |
+
|
| 27 |
+
model = None
|
| 28 |
+
metadata = None
|
| 29 |
+
|
| 30 |
+
if os.path.exists(MODEL_PATH):
|
| 31 |
+
with open(MODEL_PATH, "rb") as f:
|
| 32 |
+
model = pickle.load(f)
|
| 33 |
+
|
| 34 |
+
if os.path.exists(METADATA_PATH):
|
| 35 |
+
with open(METADATA_PATH, "r") as f:
|
| 36 |
+
metadata = json.load(f)
|
| 37 |
+
|
| 38 |
+
# ─────────────────────────────────────────────
|
| 39 |
+
# FastAPI app (our real server)
|
| 40 |
+
# ─────────────────────────────────────────────
|
| 41 |
+
fast_app = FastAPI(title="FraudLens")
|
| 42 |
+
|
| 43 |
+
# Serve CSS / JS / images
|
| 44 |
+
fast_app.mount(
|
| 45 |
+
"/static",
|
| 46 |
+
StaticFiles(directory=os.path.join(BASE_DIR, "static")),
|
| 47 |
+
name="static",
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
# ── Routes ──────────────────────────────────
|
| 51 |
+
|
| 52 |
+
@fast_app.get("/", response_class=HTMLResponse)
|
| 53 |
+
async def index():
|
| 54 |
+
with open(os.path.join(BASE_DIR, "templates", "index.html"), "r", encoding="utf-8") as f:
|
| 55 |
+
return HTMLResponse(content=f.read())
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
@fast_app.get("/fraud-prediction-result-screen", response_class=HTMLResponse)
|
| 59 |
+
async def result_screen():
|
| 60 |
+
with open(os.path.join(BASE_DIR, "templates", "index.html"), "r", encoding="utf-8") as f:
|
| 61 |
+
return HTMLResponse(content=f.read())
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
@fast_app.post("/api/predict")
|
| 65 |
+
async def predict(request: Request):
|
| 66 |
+
if not model or not metadata:
|
| 67 |
+
return JSONResponse({"error": "Model not loaded"}, status_code=500)
|
| 68 |
+
|
| 69 |
+
data = await request.json()
|
| 70 |
+
if not data:
|
| 71 |
+
return JSONResponse({"error": "No data provided"}, status_code=400)
|
| 72 |
+
|
| 73 |
+
try:
|
| 74 |
+
amount = float(data.get("amount", 0))
|
| 75 |
+
distance_from_home = float(data.get("distanceFromHome", 0))
|
| 76 |
+
distance_from_last = float(data.get("distanceFromLastTxn", 0))
|
| 77 |
+
current_balance = float(data.get("currentBalance", 0))
|
| 78 |
+
credit_limit = float(data.get("creditLimit", 1))
|
| 79 |
+
transaction_type = data.get("transactionType", "purchase")
|
| 80 |
+
merchant_category = data.get("merchantCategory", "grocery")
|
| 81 |
+
address_match = data.get("addressMatch", "yes")
|
| 82 |
+
country_match = data.get("countryMatch", "yes")
|
| 83 |
+
card_type = data.get("cardType", "credit")
|
| 84 |
+
|
| 85 |
+
utilization = current_balance / credit_limit if credit_limit > 0 else 0
|
| 86 |
+
|
| 87 |
+
# Baseline risk score
|
| 88 |
+
score_base = 0.15
|
| 89 |
+
if amount > 500: score_base += 0.18
|
| 90 |
+
if amount > 2000: score_base += 0.22
|
| 91 |
+
if distance_from_home > 100: score_base += 0.14
|
| 92 |
+
if distance_from_last > 200: score_base += 0.16
|
| 93 |
+
if utilization > 0.8: score_base += 0.12
|
| 94 |
+
if address_match == "no": score_base += 0.15
|
| 95 |
+
if country_match == "no": score_base += 0.20
|
| 96 |
+
if merchant_category in ["online_retail", "crypto"]:
|
| 97 |
+
score_base += 0.10
|
| 98 |
+
if transaction_type == "purchase" and amount > 1000:
|
| 99 |
+
score_base += 0.08
|
| 100 |
+
|
| 101 |
+
base_prob = min(0.97, max(0.03, score_base))
|
| 102 |
+
|
| 103 |
+
# Build PCA feature vector for the Random Forest
|
| 104 |
+
c0_mean = metadata["class_0_mean"]
|
| 105 |
+
c1_mean = metadata["class_1_mean"]
|
| 106 |
+
v_features = [
|
| 107 |
+
(1 - base_prob) * c0_mean[f"V{i}"] + base_prob * c1_mean[f"V{i}"]
|
| 108 |
+
for i in range(1, 29)
|
| 109 |
+
]
|
| 110 |
+
|
| 111 |
+
current_time_secs = int(time.time() % 86400)
|
| 112 |
+
features = np.array([[current_time_secs] + v_features + [amount]])
|
| 113 |
+
|
| 114 |
+
ml_prob = float(model.predict_proba(features)[0][1])
|
| 115 |
+
final_prob = float(np.clip(0.3 * base_prob + 0.7 * ml_prob, 0.03, 0.97))
|
| 116 |
+
|
| 117 |
+
if final_prob >= 0.7: risk_level = "critical"
|
| 118 |
+
elif final_prob >= 0.5: risk_level = "high"
|
| 119 |
+
elif final_prob >= 0.3: risk_level = "medium"
|
| 120 |
+
else: risk_level = "low"
|
| 121 |
+
|
| 122 |
+
return JSONResponse({"fraud_probability": round(final_prob, 4), "risk_level": risk_level})
|
| 123 |
+
|
| 124 |
+
except Exception as exc:
|
| 125 |
+
return JSONResponse({"error": str(exc)}, status_code=500)
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
# ─────────────────────────────────────────────
|
| 129 |
+
# Minimal Gradio demo (required by HF Spaces
|
| 130 |
+
# Gradio SDK — mounted at /gradio, not at /)
|
| 131 |
+
# ─────────────────────────────────────────────
|
| 132 |
+
with gr.Blocks(title="FraudLens") as demo:
|
| 133 |
+
gr.HTML(
|
| 134 |
+
'<meta http-equiv="refresh" content="0; url=/">'
|
| 135 |
+
"<p>Redirecting to FraudLens…</p>"
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
# Mount Gradio under /gradio → our FastAPI owns /
|
| 139 |
+
app = gr.mount_gradio_app(fast_app, demo, path="/gradio")
|
app.py.metadata.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"summary": "FraudLens backend rewritten for Hugging Face Spaces Gradio SDK. Uses FastAPI (Gradio's internal server) with gr.mount_gradio_app so the free Gradio tier can serve our custom HTML frontend and /api/predict ML endpoint. Gradio is mounted at /gradio (hidden), while our frontend lives at /.",
|
| 3 |
+
"updatedAt": "2026-07-09T15:11:02.990866Z",
|
| 4 |
+
"userFacing": true
|
| 5 |
+
}
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a09f4488b41426aea72f30fa0b341a2e2f51af1923a02ef8e36b4c0fcfbd54c0
|
| 3 |
+
size 1303854
|
model_metadata.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metrics": {
|
| 3 |
+
"accuracy": 0.9995435553526912,
|
| 4 |
+
"precision": 0.9736842105263158,
|
| 5 |
+
"recall": 0.7551020408163265,
|
| 6 |
+
"f1": 0.8505747126436781,
|
| 7 |
+
"auc": 0.9480902518576366
|
| 8 |
+
},
|
| 9 |
+
"class_0_mean": {
|
| 10 |
+
"V1": 0.008257737485563688,
|
| 11 |
+
"V2": -0.006270857415807066,
|
| 12 |
+
"V3": 0.012170917031845403,
|
| 13 |
+
"V4": -0.00785986782046522,
|
| 14 |
+
"V5": 0.00545311588864745,
|
| 15 |
+
"V6": 0.0024187484361073526,
|
| 16 |
+
"V7": 0.009636549929484086,
|
| 17 |
+
"V8": -0.0009874711516652873,
|
| 18 |
+
"V9": 0.004466568691335963,
|
| 19 |
+
"V10": 0.009823703892289417,
|
| 20 |
+
"V11": -0.006576104223821521,
|
| 21 |
+
"V12": 0.010831723172555738,
|
| 22 |
+
"V13": 0.0001891994372613584,
|
| 23 |
+
"V14": 0.012064392184377496,
|
| 24 |
+
"V15": 0.000160810873440156,
|
| 25 |
+
"V16": 0.007164072539099487,
|
| 26 |
+
"V17": 0.011535063252129248,
|
| 27 |
+
"V18": 0.003887180071097925,
|
| 28 |
+
"V19": -0.001177863909078364,
|
| 29 |
+
"V20": -0.0006442894068880698,
|
| 30 |
+
"V21": -0.001234846805525402,
|
| 31 |
+
"V22": -2.4311239340300425e-05,
|
| 32 |
+
"V23": 6.97519274279322e-05,
|
| 33 |
+
"V24": 0.00018192536544853305,
|
| 34 |
+
"V25": -7.17262632402963e-05,
|
| 35 |
+
"V26": -8.937579014912199e-05,
|
| 36 |
+
"V27": -0.0002951754138341059,
|
| 37 |
+
"V28": -0.00013094035488017133
|
| 38 |
+
},
|
| 39 |
+
"class_1_mean": {
|
| 40 |
+
"V1": -4.771948441479082,
|
| 41 |
+
"V2": 3.6237781019822806,
|
| 42 |
+
"V3": -7.0332810485965584,
|
| 43 |
+
"V4": 4.542029104423092,
|
| 44 |
+
"V5": -3.151224885936005,
|
| 45 |
+
"V6": -1.3977367105923515,
|
| 46 |
+
"V7": -5.5687310837427395,
|
| 47 |
+
"V8": 0.5706358952962376,
|
| 48 |
+
"V9": -2.581122921702995,
|
| 49 |
+
"V10": -5.676882870194368,
|
| 50 |
+
"V11": 3.800172911374607,
|
| 51 |
+
"V12": -6.259393036190131,
|
| 52 |
+
"V13": -0.10933381708278403,
|
| 53 |
+
"V14": -6.971722894107602,
|
| 54 |
+
"V15": -0.09292874691208501,
|
| 55 |
+
"V16": -4.139945699092808,
|
| 56 |
+
"V17": -6.665836399449663,
|
| 57 |
+
"V18": -2.2463081339714064,
|
| 58 |
+
"V19": 0.680659303475429,
|
| 59 |
+
"V20": 0.3723193957714717,
|
| 60 |
+
"V21": 0.7135883526687006,
|
| 61 |
+
"V22": 0.014048882140121373,
|
| 62 |
+
"V23": -0.04030796594836943,
|
| 63 |
+
"V24": -0.10513030543948289,
|
| 64 |
+
"V25": 0.041448887262827076,
|
| 65 |
+
"V26": 0.05164812556245366,
|
| 66 |
+
"V27": 0.17057479224418592,
|
| 67 |
+
"V28": 0.0756672906457746
|
| 68 |
+
}
|
| 69 |
+
}
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|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udLens — Frontend Logic
|
| 3 |
+
Matches: fraudlens-2o2ev52.public.builtwithrocket.new
|
| 4 |
+
===================================================== */
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
// -------------------------------------------------------
|
| 9 |
+
// LUCIDE ICONS INIT
|
| 10 |
+
// -------------------------------------------------------
|
| 11 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 12 |
+
if (window.lucide) lucide.createIcons();
|
| 13 |
+
initApp();
|
| 14 |
+
});
|
| 15 |
+
|
| 16 |
+
// -------------------------------------------------------
|
| 17 |
+
// STATE
|
| 18 |
+
// -------------------------------------------------------
|
| 19 |
+
let currentResult = null;
|
| 20 |
+
|
| 21 |
+
// -------------------------------------------------------
|
| 22 |
+
// UTILITY: Toast
|
| 23 |
+
// -------------------------------------------------------
|
| 24 |
+
function showToast(message, type = 'info', duration = 3000) {
|
| 25 |
+
const container = document.getElementById('toastContainer');
|
| 26 |
+
const toast = document.createElement('div');
|
| 27 |
+
toast.className = `toast ${type}`;
|
| 28 |
+
|
| 29 |
+
const icons = {
|
| 30 |
+
success: '✓',
|
| 31 |
+
error: '⚠',
|
| 32 |
+
info: 'ℹ'
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
toast.innerHTML = `<span style="font-size:14px;">${icons[type] || 'ℹ'}</span> ${message}`;
|
| 36 |
+
container.appendChild(toast);
|
| 37 |
+
|
| 38 |
+
setTimeout(() => {
|
| 39 |
+
toast.style.transition = 'all 0.3s ease';
|
| 40 |
+
toast.style.opacity = '0';
|
| 41 |
+
toast.style.transform = 'translateX(20px)';
|
| 42 |
+
setTimeout(() => toast.remove(), 300);
|
| 43 |
+
}, duration);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
// -------------------------------------------------------
|
| 47 |
+
// NAVIGATION: switch between form / result screens
|
| 48 |
+
// -------------------------------------------------------
|
| 49 |
+
function showScreen(name) {
|
| 50 |
+
const screens = { form: 'formScreen', loading: 'loadingScreen', result: 'resultScreen' };
|
| 51 |
+
|
| 52 |
+
Object.keys(screens).forEach(k => {
|
| 53 |
+
document.getElementById(screens[k]).classList.add('hidden');
|
| 54 |
+
});
|
| 55 |
+
|
| 56 |
+
document.getElementById(screens[name]).classList.remove('hidden');
|
| 57 |
+
|
| 58 |
+
// Update nav active state
|
| 59 |
+
['navAnalyzeBtn', 'navResultBtn'].forEach(id => {
|
| 60 |
+
document.getElementById(id)?.classList.remove('active');
|
| 61 |
+
});
|
| 62 |
+
['mobileNavAnalyze', 'mobileNavResult'].forEach(id => {
|
| 63 |
+
document.getElementById(id)?.classList.remove('active');
|
| 64 |
+
});
|
| 65 |
+
|
| 66 |
+
if (name === 'form') {
|
| 67 |
+
document.getElementById('navAnalyzeBtn')?.classList.add('active');
|
| 68 |
+
document.getElementById('mobileNavAnalyze')?.classList.add('active');
|
| 69 |
+
} else if (name === 'result') {
|
| 70 |
+
document.getElementById('navResultBtn')?.classList.add('active');
|
| 71 |
+
document.getElementById('mobileNavResult')?.classList.add('active');
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
// -------------------------------------------------------
|
| 76 |
+
// COLLAPSIBLE CARDS
|
| 77 |
+
// -------------------------------------------------------
|
| 78 |
+
function initCollapsible() {
|
| 79 |
+
document.querySelectorAll('.collapsible-card').forEach(card => {
|
| 80 |
+
const header = card.querySelector('.collapsible-header');
|
| 81 |
+
header.addEventListener('click', () => {
|
| 82 |
+
card.classList.toggle('active');
|
| 83 |
+
});
|
| 84 |
+
});
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
// -------------------------------------------------------
|
| 88 |
+
// LIVE RISK PREVIEW (sidebar)
|
| 89 |
+
// -------------------------------------------------------
|
| 90 |
+
const RISK_CONFIG = {
|
| 91 |
+
low: { label: 'LOW RISK', description: 'Transaction within normal parameters', color: 'var(--legit-green)', bg: 'var(--legit-green-muted)', border: 'var(--legit-green-border)', icon: 'shield-check' },
|
| 92 |
+
medium: { label: 'MEDIUM RISK', description: 'Borderline indicators — review recommended', color: 'var(--warn-amber)', bg: 'var(--warn-amber-muted)', border: 'var(--warn-amber-border)', icon: 'alert-triangle' },
|
| 93 |
+
high: { label: 'HIGH RISK', description: 'Multiple fraud signals detected', color: 'var(--fraud-red)', bg: 'var(--fraud-red-muted)', border: 'var(--fraud-red-border)', icon: 'shield-alert' },
|
| 94 |
+
critical: { label: 'CRITICAL RISK', description: 'Strong fraud indicators present — block and investigate', color: 'var(--fraud-red)', bg: 'rgba(239, 68, 68, 0.18)', border: 'var(--fraud-red-border)', icon: 'alert-octagon' }
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
function computeRiskLevel(amount) {
|
| 98 |
+
if (!amount || isNaN(amount)) return null;
|
| 99 |
+
const a = parseFloat(amount);
|
| 100 |
+
if (a > 5000) return 'critical';
|
| 101 |
+
if (a > 2000) return 'high';
|
| 102 |
+
if (a > 500) return 'medium';
|
| 103 |
+
return 'low';
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
function updateRiskPreview(riskLevel) {
|
| 107 |
+
const box = document.getElementById('liveRiskPreview');
|
| 108 |
+
if (!riskLevel) {
|
| 109 |
+
box.innerHTML = `
|
| 110 |
+
<i data-lucide="shield" style="width:24px;height:24px;color:var(--muted-foreground);display:block;margin:0 auto 8px;"></i>
|
| 111 |
+
<p class="text-xs" style="color:var(--muted-foreground);">Enter transaction amount to see a live risk preview</p>
|
| 112 |
+
`;
|
| 113 |
+
box.className = 'risk-preview-empty';
|
| 114 |
+
if (window.lucide) lucide.createIcons();
|
| 115 |
+
return;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
const cfg = RISK_CONFIG[riskLevel];
|
| 119 |
+
box.className = 'risk-preview-filled';
|
| 120 |
+
box.style.background = cfg.bg;
|
| 121 |
+
box.style.borderColor = cfg.border;
|
| 122 |
+
|
| 123 |
+
box.innerHTML = `
|
| 124 |
+
<div style="display:flex;align-items:center;gap:12px;margin-bottom:8px;">
|
| 125 |
+
<div style="width:32px;height:32px;border-radius:8px;background:${cfg.bg};border:1px solid ${cfg.border};display:flex;align-items:center;justify-content:center;flex-shrink:0;">
|
| 126 |
+
<i data-lucide="${cfg.icon}" style="width:16px;height:16px;color:${cfg.color};"></i>
|
| 127 |
+
</div>
|
| 128 |
+
<div>
|
| 129 |
+
<p style="font-size:12px;font-weight:700;letter-spacing:0.05em;color:${cfg.color};">${cfg.label}</p>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
<p style="font-size:11px;color:var(--muted-foreground);">${cfg.description}</p>
|
| 133 |
+
`;
|
| 134 |
+
if (window.lucide) lucide.createIcons();
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
// -------------------------------------------------------
|
| 138 |
+
// COMPUTE FEATURE CONTRIBUTIONS (client-side, matching original)
|
| 139 |
+
// -------------------------------------------------------
|
| 140 |
+
function computeFeatureContributions(formData) {
|
| 141 |
+
const amount = parseFloat(formData.amount) || 0;
|
| 142 |
+
const distHome = parseFloat(formData.distanceFromHome) || 0;
|
| 143 |
+
const distLast = parseFloat(formData.distanceFromLastTxn) || 0;
|
| 144 |
+
const creditLimit = parseFloat(formData.creditLimit) || 1;
|
| 145 |
+
const currentBalance = parseFloat(formData.currentBalance) || 0;
|
| 146 |
+
const accountAge = parseFloat(formData.accountAge) || 0;
|
| 147 |
+
const utilization = currentBalance / creditLimit;
|
| 148 |
+
|
| 149 |
+
const highRiskCategories = ['crypto', 'online_retail', 'travel'];
|
| 150 |
+
const categoryRisk = highRiskCategories.includes(formData.merchantCategory) ? 0.7 : 0.2;
|
| 151 |
+
|
| 152 |
+
const contributions = [
|
| 153 |
+
{
|
| 154 |
+
feature: 'Transaction Amount',
|
| 155 |
+
contribution: Math.min(0.95, (amount / 10000) * 0.9),
|
| 156 |
+
direction: 'positive',
|
| 157 |
+
value: `₹${amount.toLocaleString('en-IN', { minimumFractionDigits: 2 })}`
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
feature: 'Credit Utilization',
|
| 161 |
+
contribution: utilization > 0.8 ? 0.75 : utilization * 0.7,
|
| 162 |
+
direction: utilization > 0.5 ? 'positive' : 'negative',
|
| 163 |
+
value: `${(utilization * 100).toFixed(0)}%`
|
| 164 |
+
},
|
| 165 |
+
{
|
| 166 |
+
feature: 'Merchant Category',
|
| 167 |
+
contribution: categoryRisk,
|
| 168 |
+
direction: categoryRisk > 0.5 ? 'positive' : 'negative',
|
| 169 |
+
value: formData.merchantCategory.replace('_', ' ')
|
| 170 |
+
},
|
| 171 |
+
{
|
| 172 |
+
feature: 'Account Age',
|
| 173 |
+
contribution: accountAge < 12 ? 0.55 : 0.15,
|
| 174 |
+
direction: accountAge < 12 ? 'positive' : 'negative',
|
| 175 |
+
value: `${accountAge} mo`
|
| 176 |
+
},
|
| 177 |
+
{
|
| 178 |
+
feature: 'Distance from Home',
|
| 179 |
+
contribution: Math.min(0.8, distHome / 500),
|
| 180 |
+
direction: distHome > 50 ? 'positive' : 'negative',
|
| 181 |
+
value: `${distHome.toFixed(1)} km`
|
| 182 |
+
},
|
| 183 |
+
{
|
| 184 |
+
feature: 'Distance from Last Txn',
|
| 185 |
+
contribution: Math.min(0.65, distLast / 400),
|
| 186 |
+
direction: distLast > 30 ? 'positive' : 'negative',
|
| 187 |
+
value: `${distLast.toFixed(1)} km`
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
feature: 'Address Match',
|
| 191 |
+
contribution: formData.addressMatch === 'no' ? 0.6 : 0.1,
|
| 192 |
+
direction: formData.addressMatch === 'no' ? 'positive' : 'negative',
|
| 193 |
+
value: formData.addressMatch === 'yes' ? 'Matched' : 'Mismatch'
|
| 194 |
+
},
|
| 195 |
+
{
|
| 196 |
+
feature: 'Country Match',
|
| 197 |
+
contribution: formData.countryMatch === 'no' ? 0.55 : 0.08,
|
| 198 |
+
direction: formData.countryMatch === 'no' ? 'positive' : 'negative',
|
| 199 |
+
value: formData.countryMatch === 'yes' ? 'Same' : 'Cross-border'
|
| 200 |
+
},
|
| 201 |
+
{
|
| 202 |
+
feature: 'Email Domain',
|
| 203 |
+
contribution: ['protonmail.com', 'temp.com', 'guerrillamail.com'].some(d => (formData.emailDomain || '').includes(d)) ? 0.44 : 0.12,
|
| 204 |
+
direction: ['protonmail.com', 'temp.com'].some(d => (formData.emailDomain || '').includes(d)) ? 'positive' : 'negative',
|
| 205 |
+
value: formData.emailDomain || '—'
|
| 206 |
+
},
|
| 207 |
+
{
|
| 208 |
+
feature: 'Card Type',
|
| 209 |
+
contribution: formData.cardType === 'debit' ? 0.21 : 0.38,
|
| 210 |
+
direction: formData.cardType === 'credit' ? 'positive' : 'negative',
|
| 211 |
+
value: formData.cardType
|
| 212 |
+
}
|
| 213 |
+
];
|
| 214 |
+
|
| 215 |
+
return contributions.sort((a, b) => b.contribution - a.contribution);
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
function computeRiskLevelFromProb(prob) {
|
| 219 |
+
if (prob >= 0.7) return 'critical';
|
| 220 |
+
if (prob >= 0.5) return 'high';
|
| 221 |
+
if (prob >= 0.3) return 'medium';
|
| 222 |
+
return 'low';
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
function generateTxnId() {
|
| 226 |
+
return 'TXN-' + Date.now().toString(36).toUpperCase() + '-' + Math.floor(Math.random() * 9000 + 1000);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
// -------------------------------------------------------
|
| 230 |
+
// GAUGE ANIMATION
|
| 231 |
+
// -------------------------------------------------------
|
| 232 |
+
const GAUGE_CIRCUMFERENCE = 251.2; // half circle circumference ≈ π * r = π * 80
|
| 233 |
+
|
| 234 |
+
function setGauge(prob) {
|
| 235 |
+
const fill = document.getElementById('gaugeFill');
|
| 236 |
+
const needleLine = document.getElementById('needleLine');
|
| 237 |
+
const needleOuter = document.getElementById('needleCircleOuter');
|
| 238 |
+
const scoreText = document.getElementById('gaugeScoreText');
|
| 239 |
+
const riskLabel = document.getElementById('gaugeRiskLabel');
|
| 240 |
+
|
| 241 |
+
const color = prob >= 0.7 ? '#ef4444' : prob >= 0.5 ? '#f97316' : prob >= 0.3 ? '#f59e0b' : '#22c55e';
|
| 242 |
+
const offset = GAUGE_CIRCUMFERENCE * (1 - prob);
|
| 243 |
+
|
| 244 |
+
fill.style.strokeDashoffset = offset;
|
| 245 |
+
|
| 246 |
+
// Needle position: angle from 0 (left=0%) to π (right=100%) over half-circle
|
| 247 |
+
const angle = Math.PI * prob; // 0 = left, π = right
|
| 248 |
+
const needleX = 110 + 72 * Math.cos(Math.PI - angle);
|
| 249 |
+
const needleY = 110 - 72 * Math.sin(Math.PI - angle);
|
| 250 |
+
|
| 251 |
+
needleLine.setAttribute('x2', needleX);
|
| 252 |
+
needleLine.setAttribute('y2', needleY);
|
| 253 |
+
needleLine.setAttribute('stroke', color);
|
| 254 |
+
needleLine.style.filter = `drop-shadow(0 0 4px ${color})`;
|
| 255 |
+
needleOuter.setAttribute('fill', color);
|
| 256 |
+
|
| 257 |
+
// Animate score counter
|
| 258 |
+
const startTime = performance.now();
|
| 259 |
+
const duration = 1400;
|
| 260 |
+
function tick(now) {
|
| 261 |
+
const t = Math.min((now - startTime) / duration, 1);
|
| 262 |
+
const eased = 1 - Math.pow(1 - t, 3); // ease-out cubic
|
| 263 |
+
const current = eased * prob;
|
| 264 |
+
scoreText.textContent = (current * 100).toFixed(1);
|
| 265 |
+
scoreText.style.color = color;
|
| 266 |
+
|
| 267 |
+
if (t < 1) requestAnimationFrame(tick);
|
| 268 |
+
}
|
| 269 |
+
requestAnimationFrame(tick);
|
| 270 |
+
|
| 271 |
+
// Risk label
|
| 272 |
+
const labels = { low: 'LOW RISK', medium: 'MEDIUM RISK', high: 'HIGH RISK', critical: 'CRITICAL RISK' };
|
| 273 |
+
const rl = computeRiskLevelFromProb(prob);
|
| 274 |
+
riskLabel.textContent = labels[rl];
|
| 275 |
+
riskLabel.style.color = color;
|
| 276 |
+
|
| 277 |
+
// Zone bars
|
| 278 |
+
updateZoneBars(prob);
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
function updateZoneBars(prob) {
|
| 282 |
+
const zones = [
|
| 283 |
+
{ el: document.querySelector('[data-zone="safe"]'), active: prob < 0.3, color: '#22c55e' },
|
| 284 |
+
{ el: document.querySelector('[data-zone="review"]'), active: prob >= 0.3 && prob < 0.5, color: '#f59e0b' },
|
| 285 |
+
{ el: document.querySelector('[data-zone="high"]'), active: prob >= 0.5 && prob < 0.7, color: '#f97316' },
|
| 286 |
+
{ el: document.querySelector('[data-zone="fraud"]'), active: prob >= 0.7, color: '#ef4444' }
|
| 287 |
+
];
|
| 288 |
+
|
| 289 |
+
zones.forEach(({ el, active, color }) => {
|
| 290 |
+
if (!el) return;
|
| 291 |
+
el.innerHTML = `
|
| 292 |
+
<div style="width:100%;height:4px;border-radius:2px;background:${color};opacity:${active ? 1 : 0.3};"></div>
|
| 293 |
+
<span style="font-size:10px;font-family:var(--font-mono);color:${active ? color : 'var(--muted-foreground)'};">${el.dataset.label}</span>
|
| 294 |
+
`;
|
| 295 |
+
el.style.background = active ? `${color}18` : 'transparent';
|
| 296 |
+
el.style.borderColor = active ? `${color}40` : 'transparent';
|
| 297 |
+
});
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
// -------------------------------------------------------
|
| 301 |
+
// RENDER RESULT SCREEN
|
| 302 |
+
// -------------------------------------------------------
|
| 303 |
+
function renderResultScreen(result) {
|
| 304 |
+
const prob = result.fraudProbability;
|
| 305 |
+
const level = result.riskLevel;
|
| 306 |
+
const formData = result.formData || {};
|
| 307 |
+
|
| 308 |
+
// --- Top verdict badge ---
|
| 309 |
+
const isFraud = prob >= 0.5;
|
| 310 |
+
const isReview = prob >= 0.3 && prob < 0.5;
|
| 311 |
+
const verdictBadge = document.getElementById('verdictTopBadge');
|
| 312 |
+
if (isFraud) {
|
| 313 |
+
verdictBadge.textContent = '⚠ FRAUD FLAGGED';
|
| 314 |
+
verdictBadge.style.background = 'var(--fraud-red-muted)';
|
| 315 |
+
verdictBadge.style.borderColor = 'var(--fraud-red-border)';
|
| 316 |
+
verdictBadge.style.color = 'var(--fraud-red)';
|
| 317 |
+
} else if (isReview) {
|
| 318 |
+
verdictBadge.textContent = '◎ REVIEW REQUIRED';
|
| 319 |
+
verdictBadge.style.background = 'var(--warn-amber-muted)';
|
| 320 |
+
verdictBadge.style.borderColor = 'var(--warn-amber-border)';
|
| 321 |
+
verdictBadge.style.color = 'var(--warn-amber)';
|
| 322 |
+
} else {
|
| 323 |
+
verdictBadge.textContent = '✓ LEGITIMATE';
|
| 324 |
+
verdictBadge.style.background = 'var(--legit-green-muted)';
|
| 325 |
+
verdictBadge.style.borderColor = 'var(--legit-green-border)';
|
| 326 |
+
verdictBadge.style.color = 'var(--legit-green)';
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
// Gradient divider color
|
| 330 |
+
const divider = document.getElementById('resultDivider');
|
| 331 |
+
if (isFraud) {
|
| 332 |
+
divider.style.background = 'linear-gradient(90deg, var(--fraud-red) 0%, var(--border) 40%, transparent 100%)';
|
| 333 |
+
} else if (isReview) {
|
| 334 |
+
divider.style.background = 'linear-gradient(90deg, var(--warn-amber) 0%, var(--border) 40%, transparent 100%)';
|
| 335 |
+
} else {
|
| 336 |
+
divider.style.background = 'linear-gradient(90deg, var(--legit-green) 0%, var(--border) 40%, transparent 100%)';
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
// --- Transaction ID & Timestamp ---
|
| 340 |
+
const now = new Date();
|
| 341 |
+
const dateStr = `${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')} at ${String(now.getHours()).padStart(2,'0')}:${String(now.getMinutes()).padStart(2,'0')}:${String(now.getSeconds()).padStart(2,'0')}`;
|
| 342 |
+
document.getElementById('resultTxnId').textContent = result.transactionId;
|
| 343 |
+
document.getElementById('resultTimestamp').textContent = dateStr;
|
| 344 |
+
document.getElementById('copyTxnIdText').textContent = result.transactionId;
|
| 345 |
+
|
| 346 |
+
// --- Gauge ---
|
| 347 |
+
setTimeout(() => setGauge(prob), 150);
|
| 348 |
+
|
| 349 |
+
// --- Verdict Card ---
|
| 350 |
+
const verdictCard = document.getElementById('verdictCard');
|
| 351 |
+
const verdictIcon = document.getElementById('verdictIcon');
|
| 352 |
+
const verdictIconBox = document.getElementById('verdictIconBox');
|
| 353 |
+
const verdictLabel = document.getElementById('verdictLabel');
|
| 354 |
+
const verdictSublabel = document.getElementById('verdictSublabel');
|
| 355 |
+
const verdictDesc = document.getElementById('verdictDescription');
|
| 356 |
+
|
| 357 |
+
if (isFraud) {
|
| 358 |
+
verdictCard.className = 'verdict-card fraud animate-fade-in-up';
|
| 359 |
+
verdictIconBox.style.background = 'rgba(239, 68, 68, 0.2)';
|
| 360 |
+
verdictIconBox.style.borderColor = 'var(--fraud-red-border)';
|
| 361 |
+
verdictIcon.setAttribute('data-lucide', 'shield-off');
|
| 362 |
+
verdictLabel.textContent = 'FRAUDULENT';
|
| 363 |
+
verdictLabel.style.color = 'var(--fraud-red)';
|
| 364 |
+
verdictSublabel.textContent = 'Transaction flagged for fraud';
|
| 365 |
+
verdictDesc.textContent = 'This transaction has been flagged by the ML model as likely fraudulent. Immediate review and potential block recommended.';
|
| 366 |
+
} else if (isReview) {
|
| 367 |
+
verdictCard.className = 'verdict-card review animate-fade-in-up';
|
| 368 |
+
verdictIconBox.style.background = 'rgba(245, 158, 11, 0.2)';
|
| 369 |
+
verdictIconBox.style.borderColor = 'var(--warn-amber-border)';
|
| 370 |
+
verdictIcon.setAttribute('data-lucide', 'alert-triangle');
|
| 371 |
+
verdictLabel.textContent = 'REVIEW REQUIRED';
|
| 372 |
+
verdictLabel.style.color = 'var(--warn-amber)';
|
| 373 |
+
verdictSublabel.textContent = 'Manual review recommended';
|
| 374 |
+
verdictDesc.textContent = 'Borderline risk score detected. Manual analyst review is recommended before approving or declining this transaction.';
|
| 375 |
+
} else {
|
| 376 |
+
verdictCard.className = 'verdict-card legit animate-fade-in-up';
|
| 377 |
+
verdictIconBox.style.background = 'rgba(34, 197, 94, 0.2)';
|
| 378 |
+
verdictIconBox.style.borderColor = 'var(--legit-green-border)';
|
| 379 |
+
verdictIcon.setAttribute('data-lucide', 'check-circle');
|
| 380 |
+
verdictLabel.textContent = 'LEGITIMATE';
|
| 381 |
+
verdictLabel.style.color = 'var(--legit-green)';
|
| 382 |
+
verdictSublabel.textContent = 'Transaction appears genuine';
|
| 383 |
+
verdictDesc.textContent = 'The ML model indicates this transaction is within normal parameters. Low fraud risk detected.';
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
// --- Confidence Analysis ---
|
| 387 |
+
const confidence = isFraud ? Math.min(0.99, prob + 0.08) : Math.min(0.99, 1 - prob + 0.05);
|
| 388 |
+
const ciLow = Math.max(0, prob - 0.06);
|
| 389 |
+
const ciHigh = Math.min(1, prob + 0.06);
|
| 390 |
+
document.getElementById('confidenceText').textContent = `${(confidence * 100).toFixed(1)}%`;
|
| 391 |
+
document.getElementById('confidenceText').style.color = 'var(--foreground)';
|
| 392 |
+
setTimeout(() => {
|
| 393 |
+
document.getElementById('confidenceBar').style.width = `${confidence * 100}%`;
|
| 394 |
+
}, 300);
|
| 395 |
+
document.getElementById('ciLow').textContent = `${(ciLow * 100).toFixed(1)}%`;
|
| 396 |
+
document.getElementById('ciMid').textContent = `${(prob * 100).toFixed(1)}%`;
|
| 397 |
+
document.getElementById('ciHigh').textContent = `${(ciHigh * 100).toFixed(1)}%`;
|
| 398 |
+
|
| 399 |
+
// --- Feature Contributions ---
|
| 400 |
+
const contributions = result.featureContributions || [];
|
| 401 |
+
const maxContrib = Math.max(...contributions.map(c => c.contribution));
|
| 402 |
+
const list = document.getElementById('contributionsList');
|
| 403 |
+
list.innerHTML = '';
|
| 404 |
+
|
| 405 |
+
contributions.forEach((c, i) => {
|
| 406 |
+
const isPositive = c.direction === 'positive';
|
| 407 |
+
const color = isPositive ? 'var(--fraud-red)' : 'var(--legit-green)';
|
| 408 |
+
const barWidth = maxContrib > 0 ? (c.contribution / maxContrib) * 100 : 0;
|
| 409 |
+
const isTop = i === 0;
|
| 410 |
+
|
| 411 |
+
const row = document.createElement('div');
|
| 412 |
+
row.className = 'contribution-row';
|
| 413 |
+
row.style.animationDelay = `${0.2 + 0.07 * i}s`;
|
| 414 |
+
|
| 415 |
+
row.innerHTML = `
|
| 416 |
+
<div class="contribution-row-top">
|
| 417 |
+
<div class="contribution-label-group">
|
| 418 |
+
${isTop ? '<span class="top-badge">TOP</span>' : ''}
|
| 419 |
+
<span style="font-size:13px;font-weight:500;color:var(--foreground);">${c.feature}</span>
|
| 420 |
+
</div>
|
| 421 |
+
<div class="contribution-meta">
|
| 422 |
+
<span class="contrib-value-badge">${c.value}</span>
|
| 423 |
+
<span class="contrib-pct" style="color:${color};">${isPositive ? '+' : '-'}${(c.contribution * 100).toFixed(0)}%</span>
|
| 424 |
+
</div>
|
| 425 |
+
</div>
|
| 426 |
+
<div class="progress-track">
|
| 427 |
+
<div class="progress-fill" style="background:${color};box-shadow:${isPositive ? '0 0 8px rgba(239,68,68,0.4)' : '0 0 8px rgba(34,197,94,0.4)'};" data-width="${barWidth}"></div>
|
| 428 |
+
</div>
|
| 429 |
+
`;
|
| 430 |
+
list.appendChild(row);
|
| 431 |
+
});
|
| 432 |
+
|
| 433 |
+
// Animate bars after small delay
|
| 434 |
+
setTimeout(() => {
|
| 435 |
+
list.querySelectorAll('.progress-fill').forEach(fill => {
|
| 436 |
+
fill.style.width = fill.dataset.width + '%';
|
| 437 |
+
});
|
| 438 |
+
}, 200);
|
| 439 |
+
|
| 440 |
+
// --- Transaction Summary ---
|
| 441 |
+
const creditLimit = parseFloat(formData.creditLimit) || 1;
|
| 442 |
+
const currentBalance = parseFloat(formData.currentBalance) || 0;
|
| 443 |
+
const utilization = ((currentBalance / creditLimit) * 100).toFixed(0);
|
| 444 |
+
const txnAmount = parseFloat(formData.amount) || 0;
|
| 445 |
+
|
| 446 |
+
const summaryFields = [
|
| 447 |
+
{ label: 'Amount', value: `₹${txnAmount.toLocaleString('en-IN', { minimumFractionDigits: 2 })}`, mono: true },
|
| 448 |
+
{ label: 'Type', value: formData.transactionType || '—', mono: false },
|
| 449 |
+
{ label: 'Merchant', value: formData.merchantName || '—', mono: false },
|
| 450 |
+
{ label: 'Category', value: (formData.merchantCategory || '—').replace('_', ' '), mono: false },
|
| 451 |
+
{ label: 'Product CD', value: formData.productCD || '—', mono: true },
|
| 452 |
+
{ label: 'Card type', value: `${formData.cardCategory || ''} ${formData.cardType || ''}`.trim(), mono: false },
|
| 453 |
+
{ label: 'Acct age', value: `${formData.accountAge || '—'} mo`, mono: true },
|
| 454 |
+
{ label: 'Credit limit', value: `₹${parseFloat(formData.creditLimit || 0).toLocaleString('en-IN')}`, mono: true },
|
| 455 |
+
{ label: 'Utilization', value: `${utilization}%`, mono: true, highlight: parseInt(utilization) > 80 },
|
| 456 |
+
{ label: 'Email domain', value: formData.emailDomain || '—', mono: false }
|
| 457 |
+
];
|
| 458 |
+
|
| 459 |
+
const txnList = document.getElementById('txnSummaryList');
|
| 460 |
+
txnList.innerHTML = '';
|
| 461 |
+
summaryFields.forEach(f => {
|
| 462 |
+
const row = document.createElement('div');
|
| 463 |
+
row.className = 'txn-summary-row' + (f.highlight ? ' highlight' : '');
|
| 464 |
+
row.innerHTML = `
|
| 465 |
+
<span style="color:var(--muted-foreground);">${f.label}</span>
|
| 466 |
+
<span style="${f.mono ? 'font-family:var(--font-mono);' : ''}font-weight:500;color:${f.highlight ? 'var(--fraud-red)' : 'var(--foreground)'};">${f.value}</span>
|
| 467 |
+
`;
|
| 468 |
+
txnList.appendChild(row);
|
| 469 |
+
});
|
| 470 |
+
|
| 471 |
+
// --- Analyst Actions (reset state) ---
|
| 472 |
+
resetAnalystActions(level);
|
| 473 |
+
|
| 474 |
+
// Re-run lucide icons
|
| 475 |
+
if (window.lucide) lucide.createIcons();
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
function resetAnalystActions(riskLevel) {
|
| 479 |
+
const panel = document.getElementById('analystActionsPanel');
|
| 480 |
+
const isHighRisk = riskLevel === 'critical' || riskLevel === 'high';
|
| 481 |
+
|
| 482 |
+
panel.innerHTML = `
|
| 483 |
+
<div style="display:flex;flex-direction:column;gap:8px;">
|
| 484 |
+
<button type="button" class="btn-primary" id="btnBlockTransaction" style="background:${isHighRisk ? 'var(--fraud-red)' : 'var(--muted)'};color:${isHighRisk ? 'white' : 'var(--foreground)'};">
|
| 485 |
+
<i data-lucide="shield-off" style="width:14px;height:14px;"></i>
|
| 486 |
+
Block Transaction
|
| 487 |
+
</button>
|
| 488 |
+
<button type="button" class="btn-secondary" id="btnApproveTransaction">
|
| 489 |
+
<i data-lucide="check" style="width:14px;height:14px;"></i>
|
| 490 |
+
Approve Transaction
|
| 491 |
+
</button>
|
| 492 |
+
<button type="button" class="btn-ghost" id="btnFlagEscalation" style="width:100%;justify-content:center;">
|
| 493 |
+
<i data-lucide="flag" style="width:13px;height:13px;"></i>
|
| 494 |
+
Flag for Escalation
|
| 495 |
+
</button>
|
| 496 |
+
</div>
|
| 497 |
+
`;
|
| 498 |
+
|
| 499 |
+
if (window.lucide) lucide.createIcons();
|
| 500 |
+
|
| 501 |
+
document.getElementById('btnBlockTransaction')?.addEventListener('click', async () => {
|
| 502 |
+
if (!currentResult) return;
|
| 503 |
+
const btn = document.getElementById('btnBlockTransaction');
|
| 504 |
+
btn.disabled = true;
|
| 505 |
+
btn.innerHTML = `<i data-lucide="loader" style="width:14px;height:14px;" class="animate-spin"></i> Blocking...`;
|
| 506 |
+
if (window.lucide) lucide.createIcons();
|
| 507 |
+
await delay(900);
|
| 508 |
+
showActionResult('blocked', currentResult.transactionId);
|
| 509 |
+
});
|
| 510 |
+
|
| 511 |
+
document.getElementById('btnApproveTransaction')?.addEventListener('click', async () => {
|
| 512 |
+
if (!currentResult) return;
|
| 513 |
+
const btn = document.getElementById('btnApproveTransaction');
|
| 514 |
+
btn.disabled = true;
|
| 515 |
+
btn.innerHTML = `<i data-lucide="loader" style="width:14px;height:14px;" class="animate-spin"></i> Approving...`;
|
| 516 |
+
if (window.lucide) lucide.createIcons();
|
| 517 |
+
await delay(900);
|
| 518 |
+
showActionResult('approved', currentResult.transactionId);
|
| 519 |
+
});
|
| 520 |
+
|
| 521 |
+
document.getElementById('btnFlagEscalation')?.addEventListener('click', () => {
|
| 522 |
+
showToast('Transaction flagged for escalation', 'info', 3000);
|
| 523 |
+
});
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
function showActionResult(action, txnId) {
|
| 527 |
+
const panel = document.getElementById('analystActionsPanel');
|
| 528 |
+
const isBlocked = action === 'blocked';
|
| 529 |
+
panel.innerHTML = `
|
| 530 |
+
<div style="background:${isBlocked ? 'var(--fraud-red-muted)' : 'var(--legit-green-muted)'};border:1px solid ${isBlocked ? 'var(--fraud-red-border)' : 'var(--legit-green-border)'};border-radius:8px;padding:16px;text-align:center;">
|
| 531 |
+
<p style="font-size:14px;font-weight:600;color:${isBlocked ? 'var(--fraud-red)' : 'var(--legit-green)'};">${isBlocked ? 'Transaction Blocked' : 'Transaction Approved'}</p>
|
| 532 |
+
<p style="font-size:11px;color:var(--muted-foreground);margin-top:4px;">Action recorded at ${new Date().toLocaleTimeString('en-US', { hour12: false })}</p>
|
| 533 |
+
</div>
|
| 534 |
+
`;
|
| 535 |
+
showToast(
|
| 536 |
+
isBlocked ? `Transaction ${txnId} has been blocked` : `Transaction ${txnId} approved`,
|
| 537 |
+
isBlocked ? 'error' : 'success',
|
| 538 |
+
4000
|
| 539 |
+
);
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }
|
| 543 |
+
|
| 544 |
+
// -------------------------------------------------------
|
| 545 |
+
// FORM SUBMIT
|
| 546 |
+
// -------------------------------------------------------
|
| 547 |
+
async function handleFormSubmit(e) {
|
| 548 |
+
e.preventDefault();
|
| 549 |
+
|
| 550 |
+
const form = document.getElementById('analyzerForm');
|
| 551 |
+
const formData = new FormData(form);
|
| 552 |
+
const data = Object.fromEntries(formData.entries());
|
| 553 |
+
|
| 554 |
+
// Basic validation
|
| 555 |
+
let hasError = false;
|
| 556 |
+
const required = ['amount', 'distanceFromHome', 'distanceFromLastTxn', 'merchantName', 'accountAge', 'creditLimit', 'currentBalance'];
|
| 557 |
+
required.forEach(field => {
|
| 558 |
+
const errEl = document.getElementById(`error-${field}`);
|
| 559 |
+
const val = data[field];
|
| 560 |
+
if (!val || val.toString().trim() === '') {
|
| 561 |
+
if (errEl) { errEl.textContent = 'This field is required'; errEl.classList.remove('hidden'); }
|
| 562 |
+
hasError = true;
|
| 563 |
+
} else {
|
| 564 |
+
if (errEl) errEl.classList.add('hidden');
|
| 565 |
+
}
|
| 566 |
+
});
|
| 567 |
+
|
| 568 |
+
if (hasError) {
|
| 569 |
+
showToast('Please fill in all required fields', 'error');
|
| 570 |
+
return;
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
// Show loading
|
| 574 |
+
showScreen('loading');
|
| 575 |
+
document.getElementById('btnSubmit').disabled = true;
|
| 576 |
+
|
| 577 |
+
try {
|
| 578 |
+
// Call the Flask backend
|
| 579 |
+
const response = await fetch('/api/predict', {
|
| 580 |
+
method: 'POST',
|
| 581 |
+
headers: { 'Content-Type': 'application/json' },
|
| 582 |
+
body: JSON.stringify(data)
|
| 583 |
+
});
|
| 584 |
+
|
| 585 |
+
if (!response.ok) throw new Error(`Server error: ${response.status}`);
|
| 586 |
+
|
| 587 |
+
const serverResult = await response.json();
|
| 588 |
+
const mlProb = serverResult.fraud_probability ?? 0.5;
|
| 589 |
+
|
| 590 |
+
// Compute feature contributions client-side (matching original behaviour)
|
| 591 |
+
const contributions = computeFeatureContributions(data);
|
| 592 |
+
const riskLevel = computeRiskLevelFromProb(mlProb);
|
| 593 |
+
const txnId = generateTxnId();
|
| 594 |
+
|
| 595 |
+
const result = {
|
| 596 |
+
fraudProbability: parseFloat(mlProb.toFixed(4)),
|
| 597 |
+
riskLevel,
|
| 598 |
+
transactionId: txnId,
|
| 599 |
+
featureContributions: contributions,
|
| 600 |
+
formData: data
|
| 601 |
+
};
|
| 602 |
+
|
| 603 |
+
// Persist to sessionStorage
|
| 604 |
+
try { sessionStorage.setItem('fraudPredictionResult', JSON.stringify(result)); } catch (ex) {}
|
| 605 |
+
|
| 606 |
+
currentResult = result;
|
| 607 |
+
|
| 608 |
+
showToast('Analysis complete — reviewing fraud verdict', 'success', 2500);
|
| 609 |
+
showScreen('result');
|
| 610 |
+
renderResultScreen(result);
|
| 611 |
+
|
| 612 |
+
} catch (err) {
|
| 613 |
+
console.error('API error:', err);
|
| 614 |
+
// Fallback: use client-side computation only
|
| 615 |
+
const contributions = computeFeatureContributions(data);
|
| 616 |
+
const amount = parseFloat(data.amount) || 0;
|
| 617 |
+
let baseProb = Math.min(0.95, amount / 12000);
|
| 618 |
+
if (data.addressMatch === 'no') baseProb += 0.15;
|
| 619 |
+
if (data.countryMatch === 'no') baseProb += 0.12;
|
| 620 |
+
if (['crypto', 'online_retail'].includes(data.merchantCategory)) baseProb += 0.2;
|
| 621 |
+
if ((parseFloat(data.currentBalance) / (parseFloat(data.creditLimit) || 1)) > 0.85) baseProb += 0.1;
|
| 622 |
+
baseProb = Math.min(0.99, baseProb);
|
| 623 |
+
|
| 624 |
+
const riskLevel = computeRiskLevelFromProb(baseProb);
|
| 625 |
+
const txnId = generateTxnId();
|
| 626 |
+
|
| 627 |
+
const result = {
|
| 628 |
+
fraudProbability: parseFloat(baseProb.toFixed(4)),
|
| 629 |
+
riskLevel,
|
| 630 |
+
transactionId: txnId,
|
| 631 |
+
featureContributions: contributions,
|
| 632 |
+
formData: data
|
| 633 |
+
};
|
| 634 |
+
|
| 635 |
+
try { sessionStorage.setItem('fraudPredictionResult', JSON.stringify(result)); } catch (ex) {}
|
| 636 |
+
currentResult = result;
|
| 637 |
+
|
| 638 |
+
showToast('Analysis complete (offline mode)', 'info', 2500);
|
| 639 |
+
showScreen('result');
|
| 640 |
+
renderResultScreen(result);
|
| 641 |
+
} finally {
|
| 642 |
+
document.getElementById('btnSubmit').disabled = false;
|
| 643 |
+
}
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
// -------------------------------------------------------
|
| 647 |
+
// COPY TXN ID
|
| 648 |
+
// -------------------------------------------------------
|
| 649 |
+
function initCopyTxnId() {
|
| 650 |
+
document.getElementById('btnCopyTxnId')?.addEventListener('click', () => {
|
| 651 |
+
if (!currentResult) return;
|
| 652 |
+
navigator.clipboard.writeText(currentResult.transactionId).then(() => {
|
| 653 |
+
const btn = document.getElementById('btnCopyTxnId');
|
| 654 |
+
const originalHtml = btn.innerHTML;
|
| 655 |
+
btn.innerHTML = `<i data-lucide="check" style="width:11px;height:11px;color:var(--legit-green);"></i> <span style="font-size:10px;font-family:var(--font-mono);">Copied!</span>`;
|
| 656 |
+
if (window.lucide) lucide.createIcons();
|
| 657 |
+
showToast('Transaction ID copied', 'success', 2000);
|
| 658 |
+
setTimeout(() => { btn.innerHTML = originalHtml; if (window.lucide) lucide.createIcons(); }, 2000);
|
| 659 |
+
}).catch(() => showToast('Could not copy to clipboard', 'error'));
|
| 660 |
+
});
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
// -------------------------------------------------------
|
| 664 |
+
// INIT APP
|
| 665 |
+
// -------------------------------------------------------
|
| 666 |
+
function initApp() {
|
| 667 |
+
// Collapsible
|
| 668 |
+
initCollapsible();
|
| 669 |
+
|
| 670 |
+
// Live risk preview on amount change
|
| 671 |
+
document.getElementById('amount')?.addEventListener('input', e => {
|
| 672 |
+
updateRiskPreview(computeRiskLevel(e.target.value));
|
| 673 |
+
});
|
| 674 |
+
|
| 675 |
+
// Form submit
|
| 676 |
+
document.getElementById('analyzerForm')?.addEventListener('submit', handleFormSubmit);
|
| 677 |
+
|
| 678 |
+
// Clear form
|
| 679 |
+
document.getElementById('btnClearForm')?.addEventListener('click', () => {
|
| 680 |
+
document.getElementById('analyzerForm').reset();
|
| 681 |
+
updateRiskPreview(null);
|
| 682 |
+
document.querySelectorAll('.input-error').forEach(el => el.classList.add('hidden'));
|
| 683 |
+
showToast('Form cleared', 'info', 1500);
|
| 684 |
+
});
|
| 685 |
+
|
| 686 |
+
// Nav: Analyze Transaction
|
| 687 |
+
document.getElementById('navAnalyzeBtn')?.addEventListener('click', e => {
|
| 688 |
+
e.preventDefault();
|
| 689 |
+
showScreen('form');
|
| 690 |
+
closeMobileMenu();
|
| 691 |
+
});
|
| 692 |
+
|
| 693 |
+
// Nav: Last Result
|
| 694 |
+
document.getElementById('navResultBtn')?.addEventListener('click', e => {
|
| 695 |
+
e.preventDefault();
|
| 696 |
+
loadLastResult();
|
| 697 |
+
closeMobileMenu();
|
| 698 |
+
});
|
| 699 |
+
|
| 700 |
+
// Mobile nav links
|
| 701 |
+
document.getElementById('mobileNavAnalyze')?.addEventListener('click', e => {
|
| 702 |
+
e.preventDefault();
|
| 703 |
+
showScreen('form');
|
| 704 |
+
closeMobileMenu();
|
| 705 |
+
});
|
| 706 |
+
|
| 707 |
+
document.getElementById('mobileNavResult')?.addEventListener('click', e => {
|
| 708 |
+
e.preventDefault();
|
| 709 |
+
loadLastResult();
|
| 710 |
+
closeMobileMenu();
|
| 711 |
+
});
|
| 712 |
+
|
| 713 |
+
// Mobile menu toggle
|
| 714 |
+
document.getElementById('mobileMenuBtn')?.addEventListener('click', toggleMobileMenu);
|
| 715 |
+
|
| 716 |
+
// Back to form from result
|
| 717 |
+
document.getElementById('btnNewAnalysis')?.addEventListener('click', () => {
|
| 718 |
+
showScreen('form');
|
| 719 |
+
document.getElementById('navAnalyzeBtn').classList.add('active');
|
| 720 |
+
document.getElementById('navResultBtn').classList.remove('active');
|
| 721 |
+
});
|
| 722 |
+
|
| 723 |
+
// Analyze another (footer of result)
|
| 724 |
+
document.getElementById('btnAnalyzeAnother')?.addEventListener('click', () => {
|
| 725 |
+
showScreen('form');
|
| 726 |
+
document.getElementById('navAnalyzeBtn').classList.add('active');
|
| 727 |
+
document.getElementById('navResultBtn').classList.remove('active');
|
| 728 |
+
});
|
| 729 |
+
|
| 730 |
+
// Export Report
|
| 731 |
+
document.getElementById('btnExportReport')?.addEventListener('click', () => {
|
| 732 |
+
if (!currentResult) return;
|
| 733 |
+
const json = JSON.stringify(currentResult, null, 2);
|
| 734 |
+
const blob = new Blob([json], { type: 'application/json' });
|
| 735 |
+
const url = URL.createObjectURL(blob);
|
| 736 |
+
const a = document.createElement('a');
|
| 737 |
+
a.href = url;
|
| 738 |
+
a.download = `${currentResult.transactionId}_fraud_report.json`;
|
| 739 |
+
a.click();
|
| 740 |
+
URL.revokeObjectURL(url);
|
| 741 |
+
showToast('Report exported as JSON', 'success');
|
| 742 |
+
});
|
| 743 |
+
|
| 744 |
+
// Copy Txn ID
|
| 745 |
+
initCopyTxnId();
|
| 746 |
+
|
| 747 |
+
// Logo link → form
|
| 748 |
+
document.getElementById('logoLink')?.addEventListener('click', e => {
|
| 749 |
+
e.preventDefault();
|
| 750 |
+
showScreen('form');
|
| 751 |
+
document.getElementById('navAnalyzeBtn').classList.add('active');
|
| 752 |
+
document.getElementById('navResultBtn').classList.remove('active');
|
| 753 |
+
});
|
| 754 |
+
|
| 755 |
+
// Try to restore session
|
| 756 |
+
try {
|
| 757 |
+
const saved = sessionStorage.getItem('fraudPredictionResult');
|
| 758 |
+
if (saved) {
|
| 759 |
+
const parsed = JSON.parse(saved);
|
| 760 |
+
currentResult = parsed;
|
| 761 |
+
}
|
| 762 |
+
} catch (ex) {}
|
| 763 |
+
}
|
| 764 |
+
|
| 765 |
+
// -------------------------------------------------------
|
| 766 |
+
// LOAD LAST RESULT (from sessionStorage or demo)
|
| 767 |
+
// -------------------------------------------------------
|
| 768 |
+
function loadLastResult() {
|
| 769 |
+
let result = currentResult;
|
| 770 |
+
|
| 771 |
+
if (!result) {
|
| 772 |
+
try {
|
| 773 |
+
const saved = sessionStorage.getItem('fraudPredictionResult');
|
| 774 |
+
if (saved) result = JSON.parse(saved);
|
| 775 |
+
} catch (ex) {}
|
| 776 |
+
}
|
| 777 |
+
|
| 778 |
+
if (!result) {
|
| 779 |
+
// Demo data (matches original site's demo)
|
| 780 |
+
result = {
|
| 781 |
+
fraudProbability: 0.8312,
|
| 782 |
+
riskLevel: 'critical',
|
| 783 |
+
transactionId: 'TXN-M3X7K2-8841',
|
| 784 |
+
featureContributions: [
|
| 785 |
+
{ feature: 'Transaction Amount', contribution: 0.82, direction: 'positive', value: '₹3,247.00' },
|
| 786 |
+
{ feature: 'Credit Utilization', contribution: 0.74, direction: 'positive', value: '91%' },
|
| 787 |
+
{ feature: 'Merchant Category', contribution: 0.63, direction: 'positive', value: 'crypto' },
|
| 788 |
+
{ feature: 'Account Age', contribution: 0.51, direction: 'positive', value: '8 mo' },
|
| 789 |
+
{ feature: 'Email Domain', contribution: 0.44, direction: 'positive', value: 'protonmail.com' },
|
| 790 |
+
{ feature: 'Card Type', contribution: 0.21, direction: 'negative', value: 'credit' }
|
| 791 |
+
],
|
| 792 |
+
formData: {
|
| 793 |
+
amount: '3247.00', transactionType: 'purchase', merchantCategory: 'crypto',
|
| 794 |
+
merchantName: 'CoinBase Pro', productCD: 'R', cardType: 'credit',
|
| 795 |
+
cardCategory: 'visa', cardIssuerBank: '185', accountAge: '8',
|
| 796 |
+
creditLimit: '5000', currentBalance: '4550', previousBalance: '420',
|
| 797 |
+
emailDomain: 'protonmail.com', addressMatch: 'no', distanceFromHome: '312.4',
|
| 798 |
+
distanceFromLastTxn: '287.1', countryMatch: 'no'
|
| 799 |
+
}
|
| 800 |
+
};
|
| 801 |
+
}
|
| 802 |
+
|
| 803 |
+
currentResult = result;
|
| 804 |
+
showScreen('result');
|
| 805 |
+
renderResultScreen(result);
|
| 806 |
+
}
|
| 807 |
+
|
| 808 |
+
// -------------------------------------------------------
|
| 809 |
+
// MOBILE MENU
|
| 810 |
+
// -------------------------------------------------------
|
| 811 |
+
function toggleMobileMenu() {
|
| 812 |
+
const nav = document.getElementById('mobileNav');
|
| 813 |
+
const open = document.getElementById('menuIconOpen');
|
| 814 |
+
const close = document.getElementById('menuIconClose');
|
| 815 |
+
if (nav.classList.contains('hidden')) {
|
| 816 |
+
nav.classList.remove('hidden');
|
| 817 |
+
open.style.display = 'none';
|
| 818 |
+
close.style.display = 'block';
|
| 819 |
+
} else {
|
| 820 |
+
closeMobileMenu();
|
| 821 |
+
}
|
| 822 |
+
}
|
| 823 |
+
|
| 824 |
+
function closeMobileMenu() {
|
| 825 |
+
const nav = document.getElementById('mobileNav');
|
| 826 |
+
const open = document.getElementById('menuIconOpen');
|
| 827 |
+
const close = document.getElementById('menuIconClose');
|
| 828 |
+
nav.classList.add('hidden');
|
| 829 |
+
open.style.display = 'block';
|
| 830 |
+
close.style.display = 'none';
|
| 831 |
+
}
|
static/app.js.metadata.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"summary": "Complete rewrite of app.js: handles screen navigation (form/result), collapsible cards, live risk preview, form submission with Flask API, gauge animation (half-arc SVG), feature contribution bars with staggered animation, transaction summary, analyst action buttons (block/approve/flag), and toast notifications.",
|
| 3 |
+
"updatedAt": "2026-07-09T15:00:05.459139500Z",
|
| 4 |
+
"userFacing": true
|
| 5 |
+
}
|
static/images/app_logo.png
ADDED
|
Git LFS Details
|
static/style.css
ADDED
|
@@ -0,0 +1,1044 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* ===================================================
|
| 2 |
+
FraudLens — Exact replica stylesheet
|
| 3 |
+
Matches: fraudlens-2o2ev52.public.builtwithrocket.new
|
| 4 |
+
=================================================== */
|
| 5 |
+
|
| 6 |
+
:root {
|
| 7 |
+
/* Colors */
|
| 8 |
+
--background: #0a0a0f;
|
| 9 |
+
--card: #111118;
|
| 10 |
+
--card-elevated: #14141e;
|
| 11 |
+
--border: #1f1f33;
|
| 12 |
+
--foreground: #f4f4f7;
|
| 13 |
+
--muted: #161625;
|
| 14 |
+
--muted-foreground: #8a8a9e;
|
| 15 |
+
|
| 16 |
+
/* Semantic colors */
|
| 17 |
+
--fraud-red: #ef4444;
|
| 18 |
+
--fraud-red-muted: rgba(239, 68, 68, 0.1);
|
| 19 |
+
--fraud-red-border: rgba(239, 68, 68, 0.25);
|
| 20 |
+
|
| 21 |
+
--legit-green: #22c55e;
|
| 22 |
+
--legit-green-muted: rgba(34, 197, 94, 0.1);
|
| 23 |
+
--legit-green-border: rgba(34, 197, 94, 0.25);
|
| 24 |
+
|
| 25 |
+
--warn-amber: #f59e0b;
|
| 26 |
+
--warn-amber-muted: rgba(245, 158, 11, 0.1);
|
| 27 |
+
--warn-amber-border: rgba(245, 158, 11, 0.25);
|
| 28 |
+
|
| 29 |
+
--chart-tertiary: #7c3aed;
|
| 30 |
+
--primary-foreground: #ffffff;
|
| 31 |
+
|
| 32 |
+
/* Typography */
|
| 33 |
+
--font-sans: 'Inter', system-ui, sans-serif;
|
| 34 |
+
--font-heading: 'Outfit', 'Inter', sans-serif;
|
| 35 |
+
--font-mono: 'JetBrains Mono', 'Fira Code', monospace;
|
| 36 |
+
|
| 37 |
+
/* Radii */
|
| 38 |
+
--radius-sm: 4px;
|
| 39 |
+
--radius-md: 8px;
|
| 40 |
+
--radius-lg: 12px;
|
| 41 |
+
--radius-xl: 16px;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/* ===== RESET ===== */
|
| 45 |
+
*, *::before, *::after {
|
| 46 |
+
box-sizing: border-box;
|
| 47 |
+
margin: 0;
|
| 48 |
+
padding: 0;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
html { scroll-behavior: smooth; }
|
| 52 |
+
|
| 53 |
+
body {
|
| 54 |
+
font-family: var(--font-sans);
|
| 55 |
+
background-color: var(--background);
|
| 56 |
+
color: var(--foreground);
|
| 57 |
+
line-height: 1.5;
|
| 58 |
+
overflow-x: hidden;
|
| 59 |
+
font-size: 14px;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
a { text-decoration: none; color: inherit; }
|
| 63 |
+
button { font-family: inherit; cursor: pointer; }
|
| 64 |
+
input, select, textarea { font-family: inherit; }
|
| 65 |
+
svg { display: block; }
|
| 66 |
+
|
| 67 |
+
/* ===== GRID BACKGROUND ===== */
|
| 68 |
+
.min-h-screen { min-height: 100vh; }
|
| 69 |
+
|
| 70 |
+
.grid-scan-line {
|
| 71 |
+
background-image:
|
| 72 |
+
linear-gradient(rgba(31, 31, 51, 0.12) 1px, transparent 1px),
|
| 73 |
+
linear-gradient(90deg, rgba(31, 31, 51, 0.12) 1px, transparent 1px);
|
| 74 |
+
background-size: 32px 32px;
|
| 75 |
+
position: relative;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/* ===== HEADER ===== */
|
| 79 |
+
.sticky-header {
|
| 80 |
+
position: sticky;
|
| 81 |
+
top: 0;
|
| 82 |
+
z-index: 50;
|
| 83 |
+
width: 100%;
|
| 84 |
+
background: rgba(10, 10, 15, 0.92);
|
| 85 |
+
backdrop-filter: blur(16px);
|
| 86 |
+
-webkit-backdrop-filter: blur(16px);
|
| 87 |
+
border-bottom: 1px solid var(--border);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.header-inner {
|
| 91 |
+
width: 100%;
|
| 92 |
+
max-width: 1536px;
|
| 93 |
+
margin: 0 auto;
|
| 94 |
+
padding: 0 24px;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.header-content {
|
| 98 |
+
display: flex;
|
| 99 |
+
align-items: center;
|
| 100 |
+
justify-content: space-between;
|
| 101 |
+
height: 64px;
|
| 102 |
+
gap: 16px;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
/* Logo */
|
| 106 |
+
.logo-link {
|
| 107 |
+
display: flex;
|
| 108 |
+
align-items: center;
|
| 109 |
+
gap: 12px;
|
| 110 |
+
flex-shrink: 0;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.logo-icon-box {
|
| 114 |
+
display: flex;
|
| 115 |
+
align-items: center;
|
| 116 |
+
justify-content: center;
|
| 117 |
+
width: 32px;
|
| 118 |
+
height: 32px;
|
| 119 |
+
border-radius: var(--radius-md);
|
| 120 |
+
background: var(--fraud-red-muted);
|
| 121 |
+
border: 1px solid var(--fraud-red-border);
|
| 122 |
+
flex-shrink: 0;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
.logo-text-group {
|
| 126 |
+
display: flex;
|
| 127 |
+
align-items: center;
|
| 128 |
+
gap: 8px;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
.logo-img {
|
| 132 |
+
object-fit: contain;
|
| 133 |
+
flex-shrink: 0;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.logo-name {
|
| 137 |
+
font-weight: 600;
|
| 138 |
+
font-size: 15px;
|
| 139 |
+
letter-spacing: -0.01em;
|
| 140 |
+
display: none;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
@media (min-width: 640px) {
|
| 144 |
+
.logo-name { display: block; }
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.version-tag {
|
| 148 |
+
display: none;
|
| 149 |
+
align-items: center;
|
| 150 |
+
padding: 2px 8px;
|
| 151 |
+
border-radius: var(--radius-sm);
|
| 152 |
+
font-family: var(--font-mono);
|
| 153 |
+
font-size: 10px;
|
| 154 |
+
font-weight: 500;
|
| 155 |
+
background: var(--fraud-red-muted);
|
| 156 |
+
color: var(--fraud-red);
|
| 157 |
+
border: 1px solid var(--fraud-red-border);
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
@media (min-width: 768px) {
|
| 161 |
+
.version-tag { display: inline-flex; }
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
/* Nav */
|
| 165 |
+
.nav-desktop {
|
| 166 |
+
display: none;
|
| 167 |
+
align-items: center;
|
| 168 |
+
gap: 4px;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
@media (min-width: 768px) {
|
| 172 |
+
.nav-desktop { display: flex; }
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
.nav-link {
|
| 176 |
+
display: flex;
|
| 177 |
+
align-items: center;
|
| 178 |
+
gap: 8px;
|
| 179 |
+
padding: 8px 16px;
|
| 180 |
+
border-radius: var(--radius-md);
|
| 181 |
+
font-size: 14px;
|
| 182 |
+
font-weight: 500;
|
| 183 |
+
color: var(--muted-foreground);
|
| 184 |
+
border: 1px solid transparent;
|
| 185 |
+
transition: all 0.15s ease;
|
| 186 |
+
white-space: nowrap;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.nav-link:hover {
|
| 190 |
+
color: var(--foreground);
|
| 191 |
+
background: rgba(255,255,255,0.04);
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
.nav-link.active {
|
| 195 |
+
background: var(--fraud-red-muted);
|
| 196 |
+
color: var(--fraud-red);
|
| 197 |
+
border-color: var(--fraud-red-border);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
/* Header Right */
|
| 201 |
+
.header-right {
|
| 202 |
+
display: flex;
|
| 203 |
+
align-items: center;
|
| 204 |
+
gap: 12px;
|
| 205 |
+
flex-shrink: 0;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
.status-badge {
|
| 209 |
+
display: none;
|
| 210 |
+
align-items: center;
|
| 211 |
+
gap: 8px;
|
| 212 |
+
padding: 6px 12px;
|
| 213 |
+
border-radius: var(--radius-md);
|
| 214 |
+
background: var(--legit-green-muted);
|
| 215 |
+
border: 1px solid var(--legit-green-border);
|
| 216 |
+
color: var(--legit-green);
|
| 217 |
+
font-family: var(--font-mono);
|
| 218 |
+
font-size: 12px;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
@media (min-width: 640px) {
|
| 222 |
+
.status-badge { display: flex; }
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
.pulse-dot {
|
| 226 |
+
width: 6px;
|
| 227 |
+
height: 6px;
|
| 228 |
+
border-radius: 50%;
|
| 229 |
+
background: var(--legit-green);
|
| 230 |
+
animation: pulse-slow 2s ease-in-out infinite;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
@keyframes pulse-slow {
|
| 234 |
+
0%, 100% { transform: scale(0.9); opacity: 0.6; }
|
| 235 |
+
50% { transform: scale(1.2); opacity: 1; }
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
.mobile-menu-btn {
|
| 239 |
+
display: flex;
|
| 240 |
+
align-items: center;
|
| 241 |
+
justify-content: center;
|
| 242 |
+
padding: 8px;
|
| 243 |
+
border-radius: var(--radius-md);
|
| 244 |
+
background: transparent;
|
| 245 |
+
border: none;
|
| 246 |
+
color: var(--muted-foreground);
|
| 247 |
+
transition: color 0.2s;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
.mobile-menu-btn:hover { color: var(--foreground); }
|
| 251 |
+
|
| 252 |
+
@media (min-width: 768px) {
|
| 253 |
+
.mobile-menu-btn { display: none; }
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
/* Mobile Nav Dropdown */
|
| 257 |
+
.nav-mobile {
|
| 258 |
+
border-top: 1px solid var(--border);
|
| 259 |
+
background: var(--card);
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
.mobile-nav-inner {
|
| 263 |
+
padding: 12px 16px;
|
| 264 |
+
display: flex;
|
| 265 |
+
flex-direction: column;
|
| 266 |
+
gap: 4px;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
.mobile-nav-link {
|
| 270 |
+
display: flex;
|
| 271 |
+
align-items: center;
|
| 272 |
+
justify-content: space-between;
|
| 273 |
+
padding: 12px 16px;
|
| 274 |
+
border-radius: var(--radius-md);
|
| 275 |
+
color: var(--foreground);
|
| 276 |
+
transition: background 0.2s;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.mobile-nav-link:hover { background: var(--muted); }
|
| 280 |
+
.mobile-nav-link.active { background: var(--fraud-red-muted); color: var(--fraud-red); }
|
| 281 |
+
|
| 282 |
+
.mobile-nav-left {
|
| 283 |
+
display: flex;
|
| 284 |
+
align-items: center;
|
| 285 |
+
gap: 12px;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
.mobile-nav-label {
|
| 289 |
+
font-size: 14px;
|
| 290 |
+
font-weight: 500;
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
.mobile-nav-desc {
|
| 294 |
+
font-size: 12px;
|
| 295 |
+
color: var(--muted-foreground);
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
/* ===== MAIN ===== */
|
| 299 |
+
.main-content {
|
| 300 |
+
width: 100%;
|
| 301 |
+
max-width: 1536px;
|
| 302 |
+
margin: 0 auto;
|
| 303 |
+
padding: 32px 24px;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
/* ===== SCREENS ===== */
|
| 307 |
+
.screen { width: 100%; }
|
| 308 |
+
.hidden { display: none !important; }
|
| 309 |
+
|
| 310 |
+
/* ===== TYPOGRAPHY HELPERS ===== */
|
| 311 |
+
.section-label {
|
| 312 |
+
display: inline-block;
|
| 313 |
+
font-family: var(--font-heading);
|
| 314 |
+
text-transform: uppercase;
|
| 315 |
+
font-size: 11px;
|
| 316 |
+
font-weight: 700;
|
| 317 |
+
letter-spacing: 0.08em;
|
| 318 |
+
color: var(--fraud-red);
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
.page-title {
|
| 322 |
+
font-family: var(--font-heading);
|
| 323 |
+
font-size: 24px;
|
| 324 |
+
font-weight: 600;
|
| 325 |
+
letter-spacing: -0.02em;
|
| 326 |
+
color: var(--foreground);
|
| 327 |
+
margin-top: 4px;
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
.page-subtitle {
|
| 331 |
+
font-size: 14px;
|
| 332 |
+
color: var(--muted-foreground);
|
| 333 |
+
margin-top: 4px;
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
.text-xs { font-size: 12px; }
|
| 337 |
+
.text-sm { font-size: 14px; }
|
| 338 |
+
.text-xl { font-size: 20px; font-weight: 600; font-family: var(--font-heading); }
|
| 339 |
+
.font-mono { font-family: var(--font-mono); }
|
| 340 |
+
.font-mono-nums { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
|
| 341 |
+
.font-semibold { font-weight: 600; }
|
| 342 |
+
.font-bold { font-weight: 700; }
|
| 343 |
+
.font-medium { font-weight: 500; }
|
| 344 |
+
.tracking-wider { letter-spacing: 0.05em; }
|
| 345 |
+
.tracking-widest { letter-spacing: 0.1em; }
|
| 346 |
+
|
| 347 |
+
.mb-1 { margin-bottom: 4px; }
|
| 348 |
+
.mb-2 { margin-bottom: 8px; }
|
| 349 |
+
.mb-3 { margin-bottom: 12px; }
|
| 350 |
+
.mb-4 { margin-bottom: 16px; }
|
| 351 |
+
.mb-5 { margin-bottom: 20px; }
|
| 352 |
+
.mb-6 { margin-bottom: 24px; }
|
| 353 |
+
.mb-8 { margin-bottom: 32px; }
|
| 354 |
+
.mt-1 { margin-top: 4px; }
|
| 355 |
+
.mt-6 { margin-top: 24px; }
|
| 356 |
+
.p-4 { padding: 16px; }
|
| 357 |
+
.p-5 { padding: 20px; }
|
| 358 |
+
|
| 359 |
+
/* ===== PAGE HEADER ===== */
|
| 360 |
+
.page-header-top {
|
| 361 |
+
display: flex;
|
| 362 |
+
align-items: center;
|
| 363 |
+
gap: 8px;
|
| 364 |
+
margin-bottom: 8px;
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
.page-header-body {
|
| 368 |
+
display: flex;
|
| 369 |
+
justify-content: space-between;
|
| 370 |
+
align-items: flex-start;
|
| 371 |
+
flex-wrap: wrap;
|
| 372 |
+
gap: 16px;
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
.page-header-title-group { flex: 1; min-width: 200px; }
|
| 376 |
+
|
| 377 |
+
/* Alert Badge */
|
| 378 |
+
.alert-badge {
|
| 379 |
+
display: inline-flex;
|
| 380 |
+
align-items: center;
|
| 381 |
+
gap: 4px;
|
| 382 |
+
font-size: 10px;
|
| 383 |
+
font-family: var(--font-mono);
|
| 384 |
+
font-weight: 500;
|
| 385 |
+
padding: 2px 8px;
|
| 386 |
+
border-radius: var(--radius-sm);
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
.warning-badge {
|
| 390 |
+
background: var(--warn-amber-muted);
|
| 391 |
+
border: 1px solid var(--warn-amber-border);
|
| 392 |
+
color: var(--warn-amber);
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
/* Info Card */
|
| 396 |
+
.info-card {
|
| 397 |
+
display: flex;
|
| 398 |
+
align-items: flex-start;
|
| 399 |
+
gap: 12px;
|
| 400 |
+
padding: 12px 16px;
|
| 401 |
+
border-radius: var(--radius-lg);
|
| 402 |
+
background: var(--muted);
|
| 403 |
+
border: 1px solid var(--border);
|
| 404 |
+
max-width: 400px;
|
| 405 |
+
flex-shrink: 0;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
.info-card p {
|
| 409 |
+
color: var(--muted-foreground);
|
| 410 |
+
font-size: 11px;
|
| 411 |
+
line-height: 1.6;
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
/* Divider */
|
| 415 |
+
.header-divider {
|
| 416 |
+
height: 1px;
|
| 417 |
+
width: 100%;
|
| 418 |
+
background: linear-gradient(90deg, var(--fraud-red) 0%, var(--border) 40%, transparent 100%);
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
/* ===== CARD ===== */
|
| 422 |
+
.card-elevated {
|
| 423 |
+
background: var(--card-elevated);
|
| 424 |
+
border: 1px solid var(--border);
|
| 425 |
+
border-radius: var(--radius-lg);
|
| 426 |
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
/* ===== FORM GRID ===== */
|
| 430 |
+
.form-grid {
|
| 431 |
+
display: grid;
|
| 432 |
+
grid-template-columns: 1fr;
|
| 433 |
+
gap: 24px;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
@media (min-width: 1280px) {
|
| 437 |
+
.form-grid {
|
| 438 |
+
grid-template-columns: 1fr 1fr 1fr;
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
.inputs-column {
|
| 442 |
+
grid-column: span 2;
|
| 443 |
+
}
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
.inputs-column {
|
| 447 |
+
display: flex;
|
| 448 |
+
flex-direction: column;
|
| 449 |
+
gap: 24px;
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
.sidebar-column {
|
| 453 |
+
display: flex;
|
| 454 |
+
flex-direction: column;
|
| 455 |
+
gap: 16px;
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
/* ===== COLLAPSIBLE CARD ===== */
|
| 459 |
+
.collapsible-card { overflow: hidden; }
|
| 460 |
+
|
| 461 |
+
.collapsible-header {
|
| 462 |
+
width: 100%;
|
| 463 |
+
display: flex;
|
| 464 |
+
align-items: center;
|
| 465 |
+
justify-content: space-between;
|
| 466 |
+
padding: 16px 20px;
|
| 467 |
+
background: transparent;
|
| 468 |
+
border: none;
|
| 469 |
+
color: inherit;
|
| 470 |
+
cursor: pointer;
|
| 471 |
+
transition: background 0.2s ease;
|
| 472 |
+
border-radius: var(--radius-lg);
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
.collapsible-header:hover { background: rgba(255, 255, 255, 0.02); }
|
| 476 |
+
|
| 477 |
+
.collapsible-header-left {
|
| 478 |
+
display: flex;
|
| 479 |
+
align-items: center;
|
| 480 |
+
gap: 12px;
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
.header-icon-box {
|
| 484 |
+
display: flex;
|
| 485 |
+
align-items: center;
|
| 486 |
+
justify-content: center;
|
| 487 |
+
width: 28px;
|
| 488 |
+
height: 28px;
|
| 489 |
+
border-radius: var(--radius-md);
|
| 490 |
+
background: var(--muted);
|
| 491 |
+
border: 1px solid var(--border);
|
| 492 |
+
flex-shrink: 0;
|
| 493 |
+
}
|
| 494 |
+
|
| 495 |
+
.card-title {
|
| 496 |
+
font-size: 14px;
|
| 497 |
+
font-weight: 600;
|
| 498 |
+
text-align: left;
|
| 499 |
+
color: var(--foreground);
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
.card-subtitle {
|
| 503 |
+
font-size: 12px;
|
| 504 |
+
color: var(--muted-foreground);
|
| 505 |
+
text-align: left;
|
| 506 |
+
margin-top: 2px;
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
.chevron-icon {
|
| 510 |
+
color: var(--muted-foreground);
|
| 511 |
+
transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
| 512 |
+
flex-shrink: 0;
|
| 513 |
+
}
|
| 514 |
+
|
| 515 |
+
.collapsible-card.active .chevron-icon {
|
| 516 |
+
transform: rotate(180deg);
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
.collapsible-content {
|
| 520 |
+
max-height: 0;
|
| 521 |
+
overflow: hidden;
|
| 522 |
+
transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.25s ease;
|
| 523 |
+
padding: 0 20px;
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
.collapsible-card.active .collapsible-content {
|
| 527 |
+
max-height: 2000px;
|
| 528 |
+
padding-bottom: 24px;
|
| 529 |
+
border-top: 1px solid var(--border);
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
.inputs-grid {
|
| 533 |
+
display: grid;
|
| 534 |
+
grid-template-columns: 1fr;
|
| 535 |
+
gap: 16px;
|
| 536 |
+
padding-top: 20px;
|
| 537 |
+
}
|
| 538 |
+
|
| 539 |
+
@media (min-width: 640px) {
|
| 540 |
+
.inputs-grid { grid-template-columns: 1fr 1fr; }
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
/* ===== FORM INPUTS ===== */
|
| 544 |
+
.input-wrapper {
|
| 545 |
+
display: flex;
|
| 546 |
+
flex-direction: column;
|
| 547 |
+
gap: 5px;
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
.input-wrapper label {
|
| 551 |
+
font-size: 12px;
|
| 552 |
+
font-weight: 500;
|
| 553 |
+
color: var(--foreground);
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
.required { color: var(--fraud-red); }
|
| 557 |
+
|
| 558 |
+
.input-helper {
|
| 559 |
+
font-size: 11px;
|
| 560 |
+
color: var(--muted-foreground);
|
| 561 |
+
line-height: 1.4;
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
.input-error {
|
| 565 |
+
font-size: 11px;
|
| 566 |
+
color: var(--fraud-red);
|
| 567 |
+
}
|
| 568 |
+
|
| 569 |
+
.input-container {
|
| 570 |
+
position: relative;
|
| 571 |
+
display: flex;
|
| 572 |
+
align-items: center;
|
| 573 |
+
width: 100%;
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
.input-field {
|
| 577 |
+
width: 100%;
|
| 578 |
+
background: rgba(10, 10, 20, 0.6);
|
| 579 |
+
border: 1px solid var(--border);
|
| 580 |
+
color: var(--foreground);
|
| 581 |
+
padding: 10px 14px;
|
| 582 |
+
border-radius: var(--radius-md);
|
| 583 |
+
font-size: 14px;
|
| 584 |
+
transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
|
| 585 |
+
outline: none;
|
| 586 |
+
-webkit-appearance: none;
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
.prefix-container .input-field {
|
| 590 |
+
padding-left: 28px;
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
.input-prefix {
|
| 594 |
+
position: absolute;
|
| 595 |
+
left: 12px;
|
| 596 |
+
font-size: 14px;
|
| 597 |
+
font-family: var(--font-mono);
|
| 598 |
+
color: var(--muted-foreground);
|
| 599 |
+
pointer-events: none;
|
| 600 |
+
z-index: 1;
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
.input-field::placeholder { color: rgba(138, 138, 158, 0.4); }
|
| 604 |
+
|
| 605 |
+
.input-field:focus {
|
| 606 |
+
border-color: var(--fraud-red-border);
|
| 607 |
+
box-shadow: 0 0 0 3px var(--fraud-red-muted);
|
| 608 |
+
background: rgba(10, 10, 20, 0.9);
|
| 609 |
+
}
|
| 610 |
+
|
| 611 |
+
/* Remove number arrows */
|
| 612 |
+
.input-field[type="number"]::-webkit-inner-spin-button,
|
| 613 |
+
.input-field[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
|
| 614 |
+
.input-field[type="number"] { -moz-appearance: textfield; }
|
| 615 |
+
|
| 616 |
+
.select-field {
|
| 617 |
+
width: 100%;
|
| 618 |
+
background: rgba(10, 10, 20, 0.6);
|
| 619 |
+
border: 1px solid var(--border);
|
| 620 |
+
color: var(--foreground);
|
| 621 |
+
padding: 10px 36px 10px 14px;
|
| 622 |
+
border-radius: var(--radius-md);
|
| 623 |
+
font-size: 14px;
|
| 624 |
+
transition: border-color 0.2s, box-shadow 0.2s;
|
| 625 |
+
outline: none;
|
| 626 |
+
appearance: none;
|
| 627 |
+
-webkit-appearance: none;
|
| 628 |
+
cursor: pointer;
|
| 629 |
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238a8a9e' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
|
| 630 |
+
background-repeat: no-repeat;
|
| 631 |
+
background-position: right 12px center;
|
| 632 |
+
background-size: 14px;
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
.select-field:focus {
|
| 636 |
+
border-color: var(--fraud-red-border);
|
| 637 |
+
box-shadow: 0 0 0 3px var(--fraud-red-muted);
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
.select-field option {
|
| 641 |
+
background: #1a1a2e;
|
| 642 |
+
color: var(--foreground);
|
| 643 |
+
}
|
| 644 |
+
|
| 645 |
+
/* ===== RISK PREVIEW (SIDEBAR) ===== */
|
| 646 |
+
.risk-preview-empty {
|
| 647 |
+
padding: 16px;
|
| 648 |
+
border-radius: var(--radius-md);
|
| 649 |
+
background: var(--muted);
|
| 650 |
+
border: 1px dashed var(--border);
|
| 651 |
+
text-align: center;
|
| 652 |
+
min-height: 80px;
|
| 653 |
+
display: flex;
|
| 654 |
+
flex-direction: column;
|
| 655 |
+
align-items: center;
|
| 656 |
+
justify-content: center;
|
| 657 |
+
}
|
| 658 |
+
|
| 659 |
+
.risk-preview-filled {
|
| 660 |
+
border-radius: var(--radius-md);
|
| 661 |
+
padding: 16px;
|
| 662 |
+
border: 1px solid;
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
/* ===== MODEL INFO BOX ===== */
|
| 666 |
+
.model-info-box {
|
| 667 |
+
background: var(--muted);
|
| 668 |
+
border: 1px solid var(--border);
|
| 669 |
+
border-radius: var(--radius-md);
|
| 670 |
+
padding: 12px;
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
/* ===== BUTTONS ===== */
|
| 674 |
+
.btn-primary {
|
| 675 |
+
display: inline-flex;
|
| 676 |
+
align-items: center;
|
| 677 |
+
justify-content: center;
|
| 678 |
+
gap: 8px;
|
| 679 |
+
width: 100%;
|
| 680 |
+
padding: 12px 16px;
|
| 681 |
+
border-radius: var(--radius-md);
|
| 682 |
+
font-size: 14px;
|
| 683 |
+
font-weight: 600;
|
| 684 |
+
color: white;
|
| 685 |
+
background: var(--fraud-red);
|
| 686 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 687 |
+
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
|
| 688 |
+
transition: all 0.2s ease;
|
| 689 |
+
cursor: pointer;
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
.btn-primary:hover:not(:disabled) {
|
| 693 |
+
background: #dc2626;
|
| 694 |
+
transform: translateY(-1px);
|
| 695 |
+
box-shadow: 0 6px 18px rgba(239, 68, 68, 0.4);
|
| 696 |
+
}
|
| 697 |
+
|
| 698 |
+
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
|
| 699 |
+
|
| 700 |
+
.btn-secondary {
|
| 701 |
+
display: inline-flex;
|
| 702 |
+
align-items: center;
|
| 703 |
+
justify-content: center;
|
| 704 |
+
gap: 8px;
|
| 705 |
+
width: 100%;
|
| 706 |
+
padding: 10px 16px;
|
| 707 |
+
border-radius: var(--radius-md);
|
| 708 |
+
font-size: 13px;
|
| 709 |
+
font-weight: 500;
|
| 710 |
+
color: var(--foreground);
|
| 711 |
+
background: transparent;
|
| 712 |
+
border: 1px solid var(--border);
|
| 713 |
+
transition: all 0.2s ease;
|
| 714 |
+
cursor: pointer;
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
.btn-secondary:hover:not(:disabled) {
|
| 718 |
+
background: var(--muted);
|
| 719 |
+
border-color: var(--muted-foreground);
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
|
| 723 |
+
|
| 724 |
+
.btn-ghost {
|
| 725 |
+
display: inline-flex;
|
| 726 |
+
align-items: center;
|
| 727 |
+
justify-content: center;
|
| 728 |
+
gap: 6px;
|
| 729 |
+
padding: 6px 10px;
|
| 730 |
+
border-radius: var(--radius-md);
|
| 731 |
+
font-size: 13px;
|
| 732 |
+
font-weight: 500;
|
| 733 |
+
color: var(--muted-foreground);
|
| 734 |
+
background: transparent;
|
| 735 |
+
border: none;
|
| 736 |
+
transition: all 0.2s ease;
|
| 737 |
+
cursor: pointer;
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
.btn-ghost:hover {
|
| 741 |
+
background: var(--muted);
|
| 742 |
+
color: var(--foreground);
|
| 743 |
+
}
|
| 744 |
+
|
| 745 |
+
/* ===== ANALYST BADGE ===== */
|
| 746 |
+
.analyst-badge {
|
| 747 |
+
display: flex;
|
| 748 |
+
align-items: center;
|
| 749 |
+
gap: 12px;
|
| 750 |
+
padding: 14px 16px;
|
| 751 |
+
border-radius: var(--radius-lg);
|
| 752 |
+
background: var(--fraud-red-muted);
|
| 753 |
+
border: 1px solid var(--fraud-red-border);
|
| 754 |
+
}
|
| 755 |
+
|
| 756 |
+
/* ===== LOADING STATE ===== */
|
| 757 |
+
.loading-scanner {
|
| 758 |
+
position: relative;
|
| 759 |
+
width: 120px;
|
| 760 |
+
height: 120px;
|
| 761 |
+
border: 1px solid var(--border);
|
| 762 |
+
border-radius: var(--radius-lg);
|
| 763 |
+
background: rgba(16, 16, 25, 0.6);
|
| 764 |
+
overflow: hidden;
|
| 765 |
+
}
|
| 766 |
+
|
| 767 |
+
.scanner-line {
|
| 768 |
+
position: absolute;
|
| 769 |
+
left: 0;
|
| 770 |
+
width: 100%;
|
| 771 |
+
height: 2px;
|
| 772 |
+
background: var(--fraud-red);
|
| 773 |
+
box-shadow: 0 0 12px var(--fraud-red);
|
| 774 |
+
animation: scan-line 2.4s ease-in-out infinite;
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
@keyframes scan-line {
|
| 778 |
+
0% { top: 0; }
|
| 779 |
+
50% { top: calc(100% - 2px); }
|
| 780 |
+
100% { top: 0; }
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
/* ===== RESULT SCREEN ===== */
|
| 784 |
+
.result-page-header {
|
| 785 |
+
display: flex;
|
| 786 |
+
align-items: flex-start;
|
| 787 |
+
justify-content: space-between;
|
| 788 |
+
flex-wrap: wrap;
|
| 789 |
+
gap: 16px;
|
| 790 |
+
margin-bottom: 16px;
|
| 791 |
+
animation: fade-in-up 0.4s ease both;
|
| 792 |
+
}
|
| 793 |
+
|
| 794 |
+
/* 4-col result grid: left (1) | center (2) | right (1) */
|
| 795 |
+
.result-grid {
|
| 796 |
+
display: grid;
|
| 797 |
+
grid-template-columns: 1fr;
|
| 798 |
+
gap: 20px;
|
| 799 |
+
}
|
| 800 |
+
|
| 801 |
+
@media (min-width: 1024px) {
|
| 802 |
+
.result-grid {
|
| 803 |
+
grid-template-columns: 1fr 2fr;
|
| 804 |
+
}
|
| 805 |
+
.result-col-center { grid-column: 2; }
|
| 806 |
+
.result-col-right { grid-column: 1 / span 2; }
|
| 807 |
+
}
|
| 808 |
+
|
| 809 |
+
@media (min-width: 1280px) {
|
| 810 |
+
.result-grid {
|
| 811 |
+
grid-template-columns: minmax(260px, 1fr) 2fr minmax(240px, 1fr);
|
| 812 |
+
}
|
| 813 |
+
.result-col-center { grid-column: auto; }
|
| 814 |
+
.result-col-right { grid-column: auto; }
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
.result-col-left { display: flex; flex-direction: column; gap: 20px; }
|
| 818 |
+
.result-col-right { display: flex; flex-direction: column; gap: 20px; }
|
| 819 |
+
|
| 820 |
+
/* Verdict card */
|
| 821 |
+
.verdict-card {
|
| 822 |
+
border-radius: var(--radius-xl);
|
| 823 |
+
padding: 16px;
|
| 824 |
+
border: 1px solid;
|
| 825 |
+
}
|
| 826 |
+
|
| 827 |
+
.verdict-card.fraud {
|
| 828 |
+
background: var(--fraud-red-muted);
|
| 829 |
+
border-color: var(--fraud-red-border);
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
.verdict-card.review {
|
| 833 |
+
background: var(--warn-amber-muted);
|
| 834 |
+
border-color: var(--warn-amber-border);
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
+
.verdict-card.legit {
|
| 838 |
+
background: var(--legit-green-muted);
|
| 839 |
+
border-color: var(--legit-green-border);
|
| 840 |
+
}
|
| 841 |
+
|
| 842 |
+
.verdict-icon-box {
|
| 843 |
+
display: flex;
|
| 844 |
+
align-items: center;
|
| 845 |
+
justify-content: center;
|
| 846 |
+
width: 40px;
|
| 847 |
+
height: 40px;
|
| 848 |
+
border-radius: var(--radius-xl);
|
| 849 |
+
border: 1px solid;
|
| 850 |
+
flex-shrink: 0;
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
/* Verdict top badge */
|
| 854 |
+
.verdict-top-badge {
|
| 855 |
+
padding: 6px 12px;
|
| 856 |
+
border-radius: var(--radius-md);
|
| 857 |
+
font-size: 12px;
|
| 858 |
+
font-family: var(--font-mono);
|
| 859 |
+
font-weight: 700;
|
| 860 |
+
border: 1px solid;
|
| 861 |
+
}
|
| 862 |
+
|
| 863 |
+
/* Zone bars */
|
| 864 |
+
.zone-bar {
|
| 865 |
+
display: flex;
|
| 866 |
+
flex-direction: column;
|
| 867 |
+
align-items: center;
|
| 868 |
+
gap: 4px;
|
| 869 |
+
border-radius: 6px;
|
| 870 |
+
padding: 6px 4px;
|
| 871 |
+
border: 1px solid transparent;
|
| 872 |
+
transition: all 0.3s ease;
|
| 873 |
+
}
|
| 874 |
+
|
| 875 |
+
.zone-bar::before {
|
| 876 |
+
content: attr(data-label);
|
| 877 |
+
font-size: 10px;
|
| 878 |
+
font-family: var(--font-mono);
|
| 879 |
+
color: var(--muted-foreground);
|
| 880 |
+
}
|
| 881 |
+
|
| 882 |
+
/* Feature contribution row */
|
| 883 |
+
.contribution-row {
|
| 884 |
+
display: flex;
|
| 885 |
+
flex-direction: column;
|
| 886 |
+
gap: 6px;
|
| 887 |
+
}
|
| 888 |
+
|
| 889 |
+
.contribution-row-top {
|
| 890 |
+
display: flex;
|
| 891 |
+
align-items: center;
|
| 892 |
+
justify-content: space-between;
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
.contribution-label-group {
|
| 896 |
+
display: flex;
|
| 897 |
+
align-items: center;
|
| 898 |
+
gap: 8px;
|
| 899 |
+
}
|
| 900 |
+
|
| 901 |
+
.top-badge {
|
| 902 |
+
font-size: 10px;
|
| 903 |
+
padding: 2px 6px;
|
| 904 |
+
border-radius: 4px;
|
| 905 |
+
font-weight: 600;
|
| 906 |
+
background: var(--fraud-red-muted);
|
| 907 |
+
color: var(--fraud-red);
|
| 908 |
+
border: 1px solid var(--fraud-red-border);
|
| 909 |
+
}
|
| 910 |
+
|
| 911 |
+
.contribution-meta {
|
| 912 |
+
display: flex;
|
| 913 |
+
align-items: center;
|
| 914 |
+
gap: 12px;
|
| 915 |
+
}
|
| 916 |
+
|
| 917 |
+
.contrib-value-badge {
|
| 918 |
+
font-size: 11px;
|
| 919 |
+
font-family: var(--font-mono);
|
| 920 |
+
padding: 2px 8px;
|
| 921 |
+
border-radius: 4px;
|
| 922 |
+
background: var(--muted);
|
| 923 |
+
border: 1px solid var(--border);
|
| 924 |
+
color: var(--muted-foreground);
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
.contrib-pct {
|
| 928 |
+
font-size: 12px;
|
| 929 |
+
font-family: var(--font-mono);
|
| 930 |
+
font-weight: 600;
|
| 931 |
+
min-width: 40px;
|
| 932 |
+
text-align: right;
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
.progress-track {
|
| 936 |
+
position: relative;
|
| 937 |
+
height: 8px;
|
| 938 |
+
background: var(--muted);
|
| 939 |
+
border-radius: 9999px;
|
| 940 |
+
overflow: hidden;
|
| 941 |
+
}
|
| 942 |
+
|
| 943 |
+
.progress-fill {
|
| 944 |
+
position: absolute;
|
| 945 |
+
left: 0;
|
| 946 |
+
top: 0;
|
| 947 |
+
height: 100%;
|
| 948 |
+
border-radius: 9999px;
|
| 949 |
+
width: 0;
|
| 950 |
+
transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
|
| 951 |
+
}
|
| 952 |
+
|
| 953 |
+
/* Transaction summary rows */
|
| 954 |
+
.txn-summary-row {
|
| 955 |
+
display: flex;
|
| 956 |
+
align-items: center;
|
| 957 |
+
justify-content: space-between;
|
| 958 |
+
font-size: 12px;
|
| 959 |
+
padding: 6px 8px;
|
| 960 |
+
border-radius: 6px;
|
| 961 |
+
}
|
| 962 |
+
|
| 963 |
+
.txn-summary-row.highlight {
|
| 964 |
+
background: var(--fraud-red-muted);
|
| 965 |
+
border: 1px solid var(--fraud-red-border);
|
| 966 |
+
}
|
| 967 |
+
|
| 968 |
+
/* ===== GAUGE COLORS ===== */
|
| 969 |
+
.gauge-glow-red { text-shadow: 0 0 12px rgba(239, 68, 68, 0.7); }
|
| 970 |
+
.gauge-glow-amber { text-shadow: 0 0 12px rgba(245, 158, 11, 0.7); }
|
| 971 |
+
.gauge-glow-green { text-shadow: 0 0 12px rgba(34, 197, 94, 0.7); }
|
| 972 |
+
|
| 973 |
+
/* ===== TOAST NOTIFICATIONS ===== */
|
| 974 |
+
.toast {
|
| 975 |
+
display: flex;
|
| 976 |
+
align-items: center;
|
| 977 |
+
gap: 10px;
|
| 978 |
+
padding: 12px 16px;
|
| 979 |
+
border-radius: var(--radius-md);
|
| 980 |
+
font-size: 13px;
|
| 981 |
+
font-weight: 500;
|
| 982 |
+
min-width: 280px;
|
| 983 |
+
max-width: 380px;
|
| 984 |
+
backdrop-filter: blur(12px);
|
| 985 |
+
border: 1px solid;
|
| 986 |
+
box-shadow: 0 8px 24px rgba(0,0,0,0.4);
|
| 987 |
+
animation: toast-in 0.3s ease both;
|
| 988 |
+
}
|
| 989 |
+
|
| 990 |
+
.toast.success {
|
| 991 |
+
background: rgba(34, 197, 94, 0.12);
|
| 992 |
+
border-color: var(--legit-green-border);
|
| 993 |
+
color: var(--legit-green);
|
| 994 |
+
}
|
| 995 |
+
|
| 996 |
+
.toast.error {
|
| 997 |
+
background: rgba(239, 68, 68, 0.12);
|
| 998 |
+
border-color: var(--fraud-red-border);
|
| 999 |
+
color: var(--fraud-red);
|
| 1000 |
+
}
|
| 1001 |
+
|
| 1002 |
+
.toast.info {
|
| 1003 |
+
background: rgba(124, 58, 237, 0.12);
|
| 1004 |
+
border-color: rgba(124, 58, 237, 0.25);
|
| 1005 |
+
color: #a78bfa;
|
| 1006 |
+
}
|
| 1007 |
+
|
| 1008 |
+
@keyframes toast-in {
|
| 1009 |
+
from { opacity: 0; transform: translateX(20px); }
|
| 1010 |
+
to { opacity: 1; transform: translateX(0); }
|
| 1011 |
+
}
|
| 1012 |
+
|
| 1013 |
+
/* ===== ANIMATIONS ===== */
|
| 1014 |
+
@keyframes fade-in-up {
|
| 1015 |
+
from { opacity: 0; transform: translateY(12px); }
|
| 1016 |
+
to { opacity: 1; transform: translateY(0); }
|
| 1017 |
+
}
|
| 1018 |
+
|
| 1019 |
+
@keyframes scale-in {
|
| 1020 |
+
from { opacity: 0; transform: scale(0.96); }
|
| 1021 |
+
to { opacity: 1; transform: scale(1); }
|
| 1022 |
+
}
|
| 1023 |
+
|
| 1024 |
+
.animate-fade-in-up {
|
| 1025 |
+
animation: fade-in-up 0.4s ease both;
|
| 1026 |
+
}
|
| 1027 |
+
|
| 1028 |
+
.animate-scale-in {
|
| 1029 |
+
animation: scale-in 0.4s ease both;
|
| 1030 |
+
}
|
| 1031 |
+
|
| 1032 |
+
@keyframes spin {
|
| 1033 |
+
to { transform: rotate(360deg); }
|
| 1034 |
+
}
|
| 1035 |
+
|
| 1036 |
+
.animate-spin {
|
| 1037 |
+
animation: spin 1s linear infinite;
|
| 1038 |
+
}
|
| 1039 |
+
|
| 1040 |
+
/* ===== SCROLLBAR ===== */
|
| 1041 |
+
::-webkit-scrollbar { width: 6px; height: 6px; }
|
| 1042 |
+
::-webkit-scrollbar-track { background: var(--background); }
|
| 1043 |
+
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
|
| 1044 |
+
::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); }
|
static/style.css.metadata.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"summary": "Complete redesign of FraudLens CSS to exactly match original site: CSS variables, sticky header, collapsible cards, form inputs, result grid (4 columns), gauge, verdict card, feature bars, analyst actions, and animation keyframes.",
|
| 3 |
+
"updatedAt": "2026-07-09T14:57:53.687427600Z",
|
| 4 |
+
"userFacing": true
|
| 5 |
+
}
|
templates/index.html
ADDED
|
@@ -0,0 +1,705 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>FraudLens — ML-Powered Credit Card Fraud Detection</title>
|
| 7 |
+
<meta name="description" content="FraudLens gives fraud analysts instant ML-powered fraud probability scores with explainable feature breakdowns for any credit card transaction.">
|
| 8 |
+
<link rel="icon" href="/static/images/app_logo.png" type="image/png">
|
| 9 |
+
|
| 10 |
+
<!-- Google Fonts -->
|
| 11 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 12 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 13 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet">
|
| 14 |
+
|
| 15 |
+
<link rel="stylesheet" href="/static/style.css">
|
| 16 |
+
<script src="https://unpkg.com/lucide@latest"></script>
|
| 17 |
+
</head>
|
| 18 |
+
<body>
|
| 19 |
+
<div class="min-h-screen grid-scan-line">
|
| 20 |
+
|
| 21 |
+
<!-- ===== HEADER ===== -->
|
| 22 |
+
<header class="sticky-header" id="mainHeader">
|
| 23 |
+
<div class="header-inner">
|
| 24 |
+
<div class="header-content">
|
| 25 |
+
<!-- Logo -->
|
| 26 |
+
<a href="#" id="logoLink" class="logo-link">
|
| 27 |
+
<div class="logo-icon-box">
|
| 28 |
+
<i data-lucide="shield-alert" style="color: var(--fraud-red); width:16px; height:16px;"></i>
|
| 29 |
+
</div>
|
| 30 |
+
<div class="logo-text-group">
|
| 31 |
+
<img src="/static/images/app_logo.png" alt="FraudLens Logo" width="28" height="28" class="logo-img">
|
| 32 |
+
<span class="logo-name">FraudLens</span>
|
| 33 |
+
</div>
|
| 34 |
+
<span class="version-tag">ML v2.4</span>
|
| 35 |
+
</a>
|
| 36 |
+
|
| 37 |
+
<!-- Nav -->
|
| 38 |
+
<nav class="nav-desktop" id="desktopNav">
|
| 39 |
+
<a href="#" class="nav-link active" id="navAnalyzeBtn" data-screen="form">
|
| 40 |
+
<i data-lucide="file-search" style="width:15px;height:15px;"></i>
|
| 41 |
+
Analyze Transaction
|
| 42 |
+
</a>
|
| 43 |
+
<a href="#" class="nav-link" id="navResultBtn" data-screen="result">
|
| 44 |
+
<i data-lucide="activity" style="width:15px;height:15px;"></i>
|
| 45 |
+
Last Result
|
| 46 |
+
</a>
|
| 47 |
+
</nav>
|
| 48 |
+
|
| 49 |
+
<!-- Right Actions -->
|
| 50 |
+
<div class="header-right">
|
| 51 |
+
<div class="status-badge">
|
| 52 |
+
<span class="pulse-dot"></span>Model Online
|
| 53 |
+
</div>
|
| 54 |
+
<button class="mobile-menu-btn" id="mobileMenuBtn" aria-label="Toggle navigation menu">
|
| 55 |
+
<i data-lucide="menu" id="menuIconOpen" style="width:20px;height:20px;"></i>
|
| 56 |
+
<i data-lucide="x" id="menuIconClose" style="width:20px;height:20px;display:none;"></i>
|
| 57 |
+
</button>
|
| 58 |
+
</div>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
|
| 62 |
+
<!-- Mobile Nav -->
|
| 63 |
+
<div class="nav-mobile hidden" id="mobileNav">
|
| 64 |
+
<nav class="mobile-nav-inner">
|
| 65 |
+
<a href="#" class="mobile-nav-link" data-screen="form" id="mobileNavAnalyze">
|
| 66 |
+
<div class="mobile-nav-left">
|
| 67 |
+
<i data-lucide="file-search" style="width:16px;height:16px;"></i>
|
| 68 |
+
<div>
|
| 69 |
+
<div class="mobile-nav-label">Analyze Transaction</div>
|
| 70 |
+
<div class="mobile-nav-desc">Submit transaction for fraud analysis</div>
|
| 71 |
+
</div>
|
| 72 |
+
</div>
|
| 73 |
+
<i data-lucide="chevron-right" style="width:14px;height:14px;color:var(--muted-foreground);"></i>
|
| 74 |
+
</a>
|
| 75 |
+
<a href="#" class="mobile-nav-link" data-screen="result" id="mobileNavResult">
|
| 76 |
+
<div class="mobile-nav-left">
|
| 77 |
+
<i data-lucide="activity" style="width:16px;height:16px;"></i>
|
| 78 |
+
<div>
|
| 79 |
+
<div class="mobile-nav-label">Last Result</div>
|
| 80 |
+
<div class="mobile-nav-desc">View latest fraud prediction result</div>
|
| 81 |
+
</div>
|
| 82 |
+
</div>
|
| 83 |
+
<i data-lucide="chevron-right" style="width:14px;height:14px;color:var(--muted-foreground);"></i>
|
| 84 |
+
</a>
|
| 85 |
+
</nav>
|
| 86 |
+
</div>
|
| 87 |
+
</header>
|
| 88 |
+
|
| 89 |
+
<!-- ===== MAIN ===== -->
|
| 90 |
+
<main class="main-content">
|
| 91 |
+
|
| 92 |
+
<!-- ======== FORM SCREEN ======== -->
|
| 93 |
+
<section id="formScreen" class="screen animate-fade-in-up">
|
| 94 |
+
|
| 95 |
+
<!-- Page Header -->
|
| 96 |
+
<div class="page-header mb-8">
|
| 97 |
+
<div class="page-header-top">
|
| 98 |
+
<span class="section-label">Fraud Detection</span>
|
| 99 |
+
<span class="alert-badge warning-badge">
|
| 100 |
+
<i data-lucide="triangle-alert" style="width:10px;height:10px;"></i>
|
| 101 |
+
Real-time Analysis
|
| 102 |
+
</span>
|
| 103 |
+
</div>
|
| 104 |
+
<div class="page-header-body">
|
| 105 |
+
<div class="page-header-title-group">
|
| 106 |
+
<h1 class="page-title">Transaction Fraud Analyzer</h1>
|
| 107 |
+
<p class="page-subtitle">Enter transaction details to receive an instant ML-powered fraud probability score with feature-level explanations.</p>
|
| 108 |
+
</div>
|
| 109 |
+
<div class="info-card">
|
| 110 |
+
<i data-lucide="info" style="width:15px;height:15px;flex-shrink:0;margin-top:2px;color:var(--muted-foreground);"></i>
|
| 111 |
+
<p>Fields are aligned to the IEEE-CIS fraud detection training dataset. All 28 PCA-transformed features (V1–V28), transaction amount, and metadata are used by the model.</p>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
<div class="header-divider mt-6"></div>
|
| 115 |
+
</div>
|
| 116 |
+
|
| 117 |
+
<!-- Form -->
|
| 118 |
+
<form id="analyzerForm" novalidate>
|
| 119 |
+
<div class="form-grid">
|
| 120 |
+
|
| 121 |
+
<!-- Left column: collapsible cards -->
|
| 122 |
+
<div class="inputs-column">
|
| 123 |
+
|
| 124 |
+
<!-- Card 1: Transaction Details -->
|
| 125 |
+
<div class="collapsible-card card-elevated active" id="cardTransaction">
|
| 126 |
+
<button type="button" class="collapsible-header">
|
| 127 |
+
<div class="collapsible-header-left">
|
| 128 |
+
<div class="header-icon-box">
|
| 129 |
+
<i data-lucide="dollar-sign" style="color:var(--fraud-red);width:16px;height:16px;"></i>
|
| 130 |
+
</div>
|
| 131 |
+
<div>
|
| 132 |
+
<h2 class="card-title">Transaction Details</h2>
|
| 133 |
+
<p class="card-subtitle">Core financial attributes used as primary fraud signals</p>
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
<i data-lucide="chevron-down" class="chevron-icon"></i>
|
| 137 |
+
</button>
|
| 138 |
+
<div class="collapsible-content">
|
| 139 |
+
<div class="inputs-grid">
|
| 140 |
+
|
| 141 |
+
<div class="input-wrapper">
|
| 142 |
+
<label>Transaction Amount (INR) <span class="required">*</span></label>
|
| 143 |
+
<p class="input-helper">Dollar value of the transaction — high amounts elevate risk score</p>
|
| 144 |
+
<div class="input-container prefix-container">
|
| 145 |
+
<span class="input-prefix">₹</span>
|
| 146 |
+
<input class="input-field" type="number" step="0.01" min="0.01" name="amount" id="amount" placeholder="0.00" required>
|
| 147 |
+
</div>
|
| 148 |
+
<p class="input-error hidden" id="error-amount"></p>
|
| 149 |
+
</div>
|
| 150 |
+
|
| 151 |
+
<div class="input-wrapper">
|
| 152 |
+
<label>Distance from Home (km) <span class="required">*</span></label>
|
| 153 |
+
<p class="input-helper">Distance between transaction location and cardholder home</p>
|
| 154 |
+
<div class="input-container">
|
| 155 |
+
<input class="input-field" type="number" step="0.1" min="0" name="distanceFromHome" id="distanceFromHome" placeholder="e.g. 12.5" required>
|
| 156 |
+
</div>
|
| 157 |
+
<p class="input-error hidden" id="error-distanceFromHome"></p>
|
| 158 |
+
</div>
|
| 159 |
+
|
| 160 |
+
<div class="input-wrapper">
|
| 161 |
+
<label>Distance from Last Transaction (km) <span class="required">*</span></label>
|
| 162 |
+
<p class="input-helper">Distance from previous transaction location</p>
|
| 163 |
+
<div class="input-container">
|
| 164 |
+
<input class="input-field" type="number" step="0.1" min="0" name="distanceFromLastTxn" id="distanceFromLastTxn" placeholder="e.g. 1.2" required>
|
| 165 |
+
</div>
|
| 166 |
+
<p class="input-error hidden" id="error-distanceFromLastTxn"></p>
|
| 167 |
+
</div>
|
| 168 |
+
|
| 169 |
+
<div class="input-wrapper">
|
| 170 |
+
<label>Transaction Type <span class="required">*</span></label>
|
| 171 |
+
<p class="input-helper">Type of transaction initiated by the cardholder</p>
|
| 172 |
+
<select class="select-field" name="transactionType" id="transactionType">
|
| 173 |
+
<option value="purchase">Purchase</option>
|
| 174 |
+
<option value="refund">Refund</option>
|
| 175 |
+
<option value="transfer">Transfer</option>
|
| 176 |
+
<option value="cash_advance">Cash Advance</option>
|
| 177 |
+
<option value="withdrawal">Withdrawal</option>
|
| 178 |
+
</select>
|
| 179 |
+
</div>
|
| 180 |
+
|
| 181 |
+
<div class="input-wrapper">
|
| 182 |
+
<label>Merchant Category <span class="required">*</span></label>
|
| 183 |
+
<p class="input-helper">Merchant category code — online retail and crypto flag higher risk</p>
|
| 184 |
+
<select class="select-field" name="merchantCategory" id="merchantCategory">
|
| 185 |
+
<option value="grocery">Grocery / Supermarket</option>
|
| 186 |
+
<option value="gas_station">Gas Station</option>
|
| 187 |
+
<option value="restaurant">Restaurant / Food</option>
|
| 188 |
+
<option value="online_retail">Online Retail</option>
|
| 189 |
+
<option value="department_store">Department Store</option>
|
| 190 |
+
<option value="travel">Travel / Airlines</option>
|
| 191 |
+
<option value="healthcare">Healthcare / Pharmacy</option>
|
| 192 |
+
<option value="entertainment">Entertainment</option>
|
| 193 |
+
<option value="crypto">Cryptocurrency Exchange</option>
|
| 194 |
+
<option value="utilities">Utilities / Bills</option>
|
| 195 |
+
<option value="other">Other</option>
|
| 196 |
+
</select>
|
| 197 |
+
</div>
|
| 198 |
+
|
| 199 |
+
<div class="input-wrapper">
|
| 200 |
+
<label>Merchant Name <span class="required">*</span></label>
|
| 201 |
+
<p class="input-helper">Name of the merchant where transaction occurred</p>
|
| 202 |
+
<div class="input-container">
|
| 203 |
+
<input class="input-field" type="text" name="merchantName" id="merchantName" placeholder="e.g. Amazon, Walmart, Shell" required>
|
| 204 |
+
</div>
|
| 205 |
+
<p class="input-error hidden" id="error-merchantName"></p>
|
| 206 |
+
</div>
|
| 207 |
+
|
| 208 |
+
<div class="input-wrapper">
|
| 209 |
+
<label>Product Code (ProductCD) <span class="required">*</span></label>
|
| 210 |
+
<p class="input-helper">Internal product category code from the transaction record</p>
|
| 211 |
+
<select class="select-field" name="productCD" id="productCD">
|
| 212 |
+
<option value="W">W — Physical goods</option>
|
| 213 |
+
<option value="H">H — Hotel / Travel</option>
|
| 214 |
+
<option value="C">C — Cash / ATM</option>
|
| 215 |
+
<option value="S">S — Services</option>
|
| 216 |
+
<option value="R">R — Retail / Digital</option>
|
| 217 |
+
</select>
|
| 218 |
+
</div>
|
| 219 |
+
|
| 220 |
+
<div class="input-wrapper">
|
| 221 |
+
<label>Billing Address Match? <span class="required">*</span></label>
|
| 222 |
+
<p class="input-helper">Does the billing address match the card owner's home address?</p>
|
| 223 |
+
<select class="select-field" name="addressMatch" id="addressMatch">
|
| 224 |
+
<option value="yes">Yes — Matched</option>
|
| 225 |
+
<option value="no">No — Mismatch</option>
|
| 226 |
+
</select>
|
| 227 |
+
</div>
|
| 228 |
+
|
| 229 |
+
<div class="input-wrapper">
|
| 230 |
+
<label>Country Match? <span class="required">*</span></label>
|
| 231 |
+
<p class="input-helper">Does transaction country match the card issuing country?</p>
|
| 232 |
+
<select class="select-field" name="countryMatch" id="countryMatch">
|
| 233 |
+
<option value="yes">Yes — Same country</option>
|
| 234 |
+
<option value="no">No — Cross-border</option>
|
| 235 |
+
</select>
|
| 236 |
+
</div>
|
| 237 |
+
|
| 238 |
+
<div class="input-wrapper">
|
| 239 |
+
<label>Email Domain</label>
|
| 240 |
+
<p class="input-helper">Email domain of the cardholder — suspicious TLDs elevate risk</p>
|
| 241 |
+
<div class="input-container">
|
| 242 |
+
<input class="input-field" type="text" name="emailDomain" id="emailDomain" placeholder="e.g. gmail.com">
|
| 243 |
+
</div>
|
| 244 |
+
</div>
|
| 245 |
+
|
| 246 |
+
</div>
|
| 247 |
+
</div>
|
| 248 |
+
</div>
|
| 249 |
+
|
| 250 |
+
<!-- Card 2: Card & Account Details -->
|
| 251 |
+
<div class="collapsible-card card-elevated" id="cardDetails">
|
| 252 |
+
<button type="button" class="collapsible-header">
|
| 253 |
+
<div class="collapsible-header-left">
|
| 254 |
+
<div class="header-icon-box">
|
| 255 |
+
<i data-lucide="credit-card" style="color:var(--chart-tertiary);width:16px;height:16px;"></i>
|
| 256 |
+
</div>
|
| 257 |
+
<div>
|
| 258 |
+
<h2 class="card-title">Card & Account Details</h2>
|
| 259 |
+
<p class="card-subtitle">Cardholder and account profile attributes</p>
|
| 260 |
+
</div>
|
| 261 |
+
</div>
|
| 262 |
+
<i data-lucide="chevron-down" class="chevron-icon"></i>
|
| 263 |
+
</button>
|
| 264 |
+
<div class="collapsible-content">
|
| 265 |
+
<div class="inputs-grid">
|
| 266 |
+
|
| 267 |
+
<div class="input-wrapper">
|
| 268 |
+
<label>Card Type <span class="required">*</span></label>
|
| 269 |
+
<p class="input-helper">Debit or credit — credit cards show different fraud patterns</p>
|
| 270 |
+
<select class="select-field" name="cardType" id="cardType">
|
| 271 |
+
<option value="credit">Credit</option>
|
| 272 |
+
<option value="debit">Debit</option>
|
| 273 |
+
</select>
|
| 274 |
+
</div>
|
| 275 |
+
|
| 276 |
+
<div class="input-wrapper">
|
| 277 |
+
<label>Card Network (card4) <span class="required">*</span></label>
|
| 278 |
+
<p class="input-helper">Payment network — Visa, Mastercard, Amex, Discover</p>
|
| 279 |
+
<select class="select-field" name="cardCategory" id="cardCategory">
|
| 280 |
+
<option value="visa">Visa</option>
|
| 281 |
+
<option value="mastercard">Mastercard</option>
|
| 282 |
+
<option value="american_express">American Express</option>
|
| 283 |
+
<option value="discover">Discover</option>
|
| 284 |
+
</select>
|
| 285 |
+
</div>
|
| 286 |
+
|
| 287 |
+
<div class="input-wrapper">
|
| 288 |
+
<label>Card Issuer Bank (card3) <span class="required">*</span></label>
|
| 289 |
+
<p class="input-helper">Issuing bank tier — affects baseline fraud rate</p>
|
| 290 |
+
<select class="select-field" name="cardIssuerBank" id="cardIssuerBank">
|
| 291 |
+
<option value="150">Tier 1 — Major national bank</option>
|
| 292 |
+
<option value="185">Tier 2 — Regional bank</option>
|
| 293 |
+
<option value="117">Tier 3 — Credit union</option>
|
| 294 |
+
<option value="226">Tier 4 — Fintech / Neobank</option>
|
| 295 |
+
<option value="137">Tier 5 — Prepaid / Reloadable</option>
|
| 296 |
+
</select>
|
| 297 |
+
</div>
|
| 298 |
+
|
| 299 |
+
<div class="input-wrapper">
|
| 300 |
+
<label>Account Age (months) <span class="required">*</span></label>
|
| 301 |
+
<p class="input-helper">How long the account has been open — newer accounts flag higher</p>
|
| 302 |
+
<div class="input-container">
|
| 303 |
+
<input class="input-field" type="number" min="0" max="600" name="accountAge" id="accountAge" placeholder="e.g. 36" required>
|
| 304 |
+
</div>
|
| 305 |
+
<p class="input-error hidden" id="error-accountAge"></p>
|
| 306 |
+
</div>
|
| 307 |
+
|
| 308 |
+
<div class="input-wrapper">
|
| 309 |
+
<label>Credit Limit (INR) <span class="required">*</span></label>
|
| 310 |
+
<p class="input-helper">Total authorized credit limit on the card (card5 feature)</p>
|
| 311 |
+
<div class="input-container prefix-container">
|
| 312 |
+
<span class="input-prefix">₹</span>
|
| 313 |
+
<input class="input-field" type="number" min="0" name="creditLimit" id="creditLimit" placeholder="5000" required>
|
| 314 |
+
</div>
|
| 315 |
+
<p class="input-error hidden" id="error-creditLimit"></p>
|
| 316 |
+
</div>
|
| 317 |
+
|
| 318 |
+
<div class="input-wrapper">
|
| 319 |
+
<label>Current Balance (INR) <span class="required">*</span></label>
|
| 320 |
+
<p class="input-helper">Outstanding balance — high utilization ratio elevates risk</p>
|
| 321 |
+
<div class="input-container prefix-container">
|
| 322 |
+
<span class="input-prefix">₹</span>
|
| 323 |
+
<input class="input-field" type="number" min="0" name="currentBalance" id="currentBalance" placeholder="1240" required>
|
| 324 |
+
</div>
|
| 325 |
+
<p class="input-error hidden" id="error-currentBalance"></p>
|
| 326 |
+
</div>
|
| 327 |
+
|
| 328 |
+
<div class="input-wrapper">
|
| 329 |
+
<label>Previous Balance (INR)</label>
|
| 330 |
+
<p class="input-helper">Balance from the prior billing cycle — sudden spikes flag fraud</p>
|
| 331 |
+
<div class="input-container prefix-container">
|
| 332 |
+
<span class="input-prefix">₹</span>
|
| 333 |
+
<input class="input-field" type="number" min="0" name="previousBalance" id="previousBalance" placeholder="980">
|
| 334 |
+
</div>
|
| 335 |
+
</div>
|
| 336 |
+
|
| 337 |
+
</div>
|
| 338 |
+
</div>
|
| 339 |
+
</div>
|
| 340 |
+
|
| 341 |
+
</div><!-- /inputs-column -->
|
| 342 |
+
|
| 343 |
+
<!-- Right Sidebar -->
|
| 344 |
+
<div class="sidebar-column">
|
| 345 |
+
|
| 346 |
+
<!-- Live Risk Preview -->
|
| 347 |
+
<div class="card-elevated p-4 animate-fade-in-up" id="riskPreviewCard" style="animation-delay:0.05s; opacity:0;">
|
| 348 |
+
<p class="section-label mb-3">Risk Preview</p>
|
| 349 |
+
<div id="liveRiskPreview" class="risk-preview-empty">
|
| 350 |
+
<i data-lucide="shield" style="width:24px;height:24px;color:var(--muted-foreground);display:block;margin:0 auto 8px;"></i>
|
| 351 |
+
<p class="text-xs" style="color:var(--muted-foreground);">Enter transaction amount to see a live risk preview</p>
|
| 352 |
+
</div>
|
| 353 |
+
</div>
|
| 354 |
+
|
| 355 |
+
<!-- Run Fraud Analysis -->
|
| 356 |
+
<div class="card-elevated p-5" style="display:flex;flex-direction:column;gap:16px;">
|
| 357 |
+
<div>
|
| 358 |
+
<h3 class="text-sm font-semibold mb-1">Run Fraud Analysis</h3>
|
| 359 |
+
<p class="text-xs" style="color:var(--muted-foreground);">Submit the transaction details to the Random Forest model. Results include a fraud probability score and per-feature contribution breakdown.</p>
|
| 360 |
+
</div>
|
| 361 |
+
|
| 362 |
+
<!-- Model Info Box -->
|
| 363 |
+
<div class="model-info-box">
|
| 364 |
+
<div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
|
| 365 |
+
<i data-lucide="circle-alert" style="color:var(--warn-amber);width:12px;height:12px;"></i>
|
| 366 |
+
<span style="color:var(--warn-amber);font-size:12px;font-weight:500;">Model Info</span>
|
| 367 |
+
</div>
|
| 368 |
+
<div style="display:flex;flex-direction:column;gap:4px;font-size:11px;">
|
| 369 |
+
<div style="display:flex;justify-content:space-between;">
|
| 370 |
+
<span style="color:var(--muted-foreground);">Algorithm</span>
|
| 371 |
+
<span style="font-family:var(--font-mono);color:var(--foreground);">Random Forest v1.0</span>
|
| 372 |
+
</div>
|
| 373 |
+
<div style="display:flex;justify-content:space-between;">
|
| 374 |
+
<span style="color:var(--muted-foreground);">Training AUC</span>
|
| 375 |
+
<span style="font-family:var(--font-mono);color:var(--legit-green);">0.9481</span>
|
| 376 |
+
</div>
|
| 377 |
+
<div style="display:flex;justify-content:space-between;">
|
| 378 |
+
<span style="color:var(--muted-foreground);">Features used</span>
|
| 379 |
+
<span style="font-family:var(--font-mono);color:var(--foreground);">29</span>
|
| 380 |
+
</div>
|
| 381 |
+
</div>
|
| 382 |
+
</div>
|
| 383 |
+
|
| 384 |
+
<button type="submit" form="analyzerForm" class="btn-primary" id="btnSubmit">
|
| 385 |
+
<i data-lucide="shield-alert" style="width:15px;height:15px;"></i>
|
| 386 |
+
Analyze for Fraud
|
| 387 |
+
<i data-lucide="chevron-right" style="width:15px;height:15px;margin-left:auto;"></i>
|
| 388 |
+
</button>
|
| 389 |
+
|
| 390 |
+
<button type="button" class="btn-secondary" id="btnClearForm">
|
| 391 |
+
<i data-lucide="rotate-ccw" style="width:14px;height:14px;"></i>
|
| 392 |
+
Clear Form
|
| 393 |
+
</button>
|
| 394 |
+
</div>
|
| 395 |
+
|
| 396 |
+
<!-- Training Dataset -->
|
| 397 |
+
<div class="card-elevated p-4">
|
| 398 |
+
<p class="section-label mb-3">Training Dataset</p>
|
| 399 |
+
<div style="display:flex;flex-direction:column;gap:8px;font-family:var(--font-mono);font-size:11px;">
|
| 400 |
+
<div style="display:flex;justify-content:space-between;">
|
| 401 |
+
<span style="color:var(--muted-foreground);">Source</span>
|
| 402 |
+
<span>IEEE-CIS Fraud Detection</span>
|
| 403 |
+
</div>
|
| 404 |
+
<div style="display:flex;justify-content:space-between;">
|
| 405 |
+
<span style="color:var(--muted-foreground);">Records</span>
|
| 406 |
+
<span>284,807 txns</span>
|
| 407 |
+
</div>
|
| 408 |
+
<div style="display:flex;justify-content:space-between;">
|
| 409 |
+
<span style="color:var(--muted-foreground);">Fraud rate</span>
|
| 410 |
+
<span>0.17%</span>
|
| 411 |
+
</div>
|
| 412 |
+
<div style="display:flex;justify-content:space-between;">
|
| 413 |
+
<span style="color:var(--muted-foreground);">PCA features</span>
|
| 414 |
+
<span>V1 – V28</span>
|
| 415 |
+
</div>
|
| 416 |
+
<div style="display:flex;justify-content:space-between;">
|
| 417 |
+
<span style="color:var(--muted-foreground);">Period</span>
|
| 418 |
+
<span>Jan – Sep 2017</span>
|
| 419 |
+
</div>
|
| 420 |
+
</div>
|
| 421 |
+
</div>
|
| 422 |
+
|
| 423 |
+
<!-- Analyst Badge -->
|
| 424 |
+
<div class="analyst-badge">
|
| 425 |
+
<div style="width:36px;height:36px;border-radius:50%;background:var(--fraud-red);display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;color:white;flex-shrink:0;">PS</div>
|
| 426 |
+
<div>
|
| 427 |
+
<p style="font-size:12px;font-weight:600;">Analyst: Parth Saxena</p>
|
| 428 |
+
<p style="font-size:11px;color:var(--muted-foreground);">Risk Operations · Session active</p>
|
| 429 |
+
</div>
|
| 430 |
+
</div>
|
| 431 |
+
|
| 432 |
+
</div><!-- /sidebar-column -->
|
| 433 |
+
</div>
|
| 434 |
+
</form>
|
| 435 |
+
</section>
|
| 436 |
+
|
| 437 |
+
<!-- ======== LOADING STATE ======== -->
|
| 438 |
+
<section id="loadingScreen" class="screen hidden">
|
| 439 |
+
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;padding:80px 0;">
|
| 440 |
+
<div class="loading-scanner">
|
| 441 |
+
<div class="scanner-line"></div>
|
| 442 |
+
</div>
|
| 443 |
+
<h2 class="text-xl font-semibold mt-6 mb-2">Analyzing Transaction...</h2>
|
| 444 |
+
<p class="text-sm" style="color:var(--muted-foreground);">Running details against Random Forest ML Model v1.0 and computing explainable features</p>
|
| 445 |
+
</div>
|
| 446 |
+
</section>
|
| 447 |
+
|
| 448 |
+
<!-- ======== RESULT SCREEN ======== -->
|
| 449 |
+
<section id="resultScreen" class="screen hidden">
|
| 450 |
+
|
| 451 |
+
<!-- Result Header (breadcrumb + title + badge) -->
|
| 452 |
+
<div id="resultHeader" class="animate-fade-in-up result-page-header">
|
| 453 |
+
<div>
|
| 454 |
+
<div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
|
| 455 |
+
<button type="button" class="btn-ghost text-xs" id="btnNewAnalysis">
|
| 456 |
+
<i data-lucide="arrow-left" style="width:13px;height:13px;"></i>
|
| 457 |
+
New Analysis
|
| 458 |
+
</button>
|
| 459 |
+
<span style="color:var(--border);">/</span>
|
| 460 |
+
<span class="section-label">Prediction Result</span>
|
| 461 |
+
</div>
|
| 462 |
+
<h1 class="page-title">Fraud Analysis Result</h1>
|
| 463 |
+
<div style="display:flex;align-items:center;gap:12px;margin-top:4px;flex-wrap:wrap;">
|
| 464 |
+
<span class="font-mono text-xs" style="color:var(--muted-foreground);" id="resultTxnId">TXN-0000000</span>
|
| 465 |
+
<span style="color:var(--border);">·</span>
|
| 466 |
+
<div style="display:flex;align-items:center;gap:4px;font-size:11px;color:var(--muted-foreground);">
|
| 467 |
+
<i data-lucide="clock" style="width:11px;height:11px;"></i>
|
| 468 |
+
<span id="resultTimestamp"></span>
|
| 469 |
+
</div>
|
| 470 |
+
</div>
|
| 471 |
+
</div>
|
| 472 |
+
<div style="display:flex;align-items:center;gap:8px;">
|
| 473 |
+
<button type="button" class="btn-ghost text-xs" id="btnExportReport">
|
| 474 |
+
<i data-lucide="download" style="width:13px;height:13px;"></i>
|
| 475 |
+
Export Report
|
| 476 |
+
</button>
|
| 477 |
+
<div class="verdict-top-badge" id="verdictTopBadge">⚠ FRAUD FLAGGED</div>
|
| 478 |
+
</div>
|
| 479 |
+
</div>
|
| 480 |
+
|
| 481 |
+
<!-- Gradient Divider -->
|
| 482 |
+
<div class="header-divider" id="resultDivider" style="margin-bottom:24px;"></div>
|
| 483 |
+
|
| 484 |
+
<!-- 4-column result grid: [gauge | feature bars (2 col) | sidebar] -->
|
| 485 |
+
<div class="result-grid">
|
| 486 |
+
|
| 487 |
+
<!-- Column 1: Gauge + Verdict + Confidence -->
|
| 488 |
+
<div class="result-col-left">
|
| 489 |
+
|
| 490 |
+
<!-- Gauge -->
|
| 491 |
+
<div class="card-elevated p-5 animate-scale-in" style="animation-delay:0.1s;opacity:0;">
|
| 492 |
+
<p class="section-label mb-4">Fraud Probability</p>
|
| 493 |
+
<div style="display:flex;flex-direction:column;align-items:center;">
|
| 494 |
+
<div style="position:relative;width:220px;height:130px;">
|
| 495 |
+
<svg width="220" height="130" viewBox="0 0 220 130" fill="none" xmlns="http://www.w3.org/2000/svg">
|
| 496 |
+
<defs>
|
| 497 |
+
<linearGradient id="gaugeGradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
| 498 |
+
<stop offset="0%" stop-color="#22c55e"/>
|
| 499 |
+
<stop offset="40%" stop-color="#f59e0b"/>
|
| 500 |
+
<stop offset="70%" stop-color="#f97316"/>
|
| 501 |
+
<stop offset="100%" stop-color="#ef4444"/>
|
| 502 |
+
</linearGradient>
|
| 503 |
+
<filter id="gaugeGlow">
|
| 504 |
+
<feGaussianBlur stdDeviation="3" result="coloredBlur"/>
|
| 505 |
+
<feMerge>
|
| 506 |
+
<feMergeNode in="coloredBlur"/>
|
| 507 |
+
<feMergeNode in="SourceGraphic"/>
|
| 508 |
+
</feMerge>
|
| 509 |
+
</filter>
|
| 510 |
+
</defs>
|
| 511 |
+
<!-- Background arc -->
|
| 512 |
+
<path d="M 30 110 A 80 80 0 0 1 190 110" stroke="var(--border)" stroke-width="10" fill="none" stroke-linecap="round"/>
|
| 513 |
+
<!-- Zone markers -->
|
| 514 |
+
<line x1="30" y1="110" x2="24" y2="110" stroke="var(--border)" stroke-width="2"/>
|
| 515 |
+
<line x1="110" y1="30" x2="110" y2="24" stroke="var(--border)" stroke-width="2"/>
|
| 516 |
+
<line x1="190" y1="110" x2="196" y2="110" stroke="var(--border)" stroke-width="2"/>
|
| 517 |
+
<!-- Active arc -->
|
| 518 |
+
<path id="gaugeFill" d="M 30 110 A 80 80 0 0 1 190 110"
|
| 519 |
+
stroke="url(#gaugeGradient)" stroke-width="10" fill="none" stroke-linecap="round"
|
| 520 |
+
stroke-dasharray="251.2" stroke-dashoffset="251.2"
|
| 521 |
+
filter="url(#gaugeGlow)"
|
| 522 |
+
style="transition:stroke-dashoffset 0.05s linear;"/>
|
| 523 |
+
<!-- Needle -->
|
| 524 |
+
<g id="gaugeNeedle">
|
| 525 |
+
<line id="needleLine" x1="110" y1="110" x2="38" y2="110" stroke="#22c55e" stroke-width="2.5" stroke-linecap="round" style="filter:drop-shadow(0 0 4px #22c55e)"/>
|
| 526 |
+
<circle cx="110" cy="110" r="5" id="needleCircleOuter" fill="#22c55e"/>
|
| 527 |
+
<circle cx="110" cy="110" r="3" fill="var(--card)"/>
|
| 528 |
+
</g>
|
| 529 |
+
<!-- Labels -->
|
| 530 |
+
<text x="18" y="125" fill="var(--legit-green)" font-size="9" font-weight="600" font-family="Inter,sans-serif">Safe</text>
|
| 531 |
+
<text x="92" y="32" fill="var(--warn-amber)" font-size="9" font-weight="600" font-family="Inter,sans-serif" text-anchor="middle">Review</text>
|
| 532 |
+
<text x="185" y="125" fill="var(--fraud-red)" font-size="9" font-weight="600" font-family="Inter,sans-serif" text-anchor="end">Fraud</text>
|
| 533 |
+
</svg>
|
| 534 |
+
<!-- Score overlay -->
|
| 535 |
+
<div style="position:absolute;bottom:4px;left:0;right:0;display:flex;flex-direction:column;align-items:center;">
|
| 536 |
+
<span id="gaugeScoreText" class="font-mono-nums" style="font-size:30px;font-weight:700;line-height:1;color:#22c55e;">0.0</span>
|
| 537 |
+
<span style="font-size:11px;font-family:var(--font-mono);color:var(--muted-foreground);">%</span>
|
| 538 |
+
</div>
|
| 539 |
+
</div>
|
| 540 |
+
<!-- Risk label -->
|
| 541 |
+
<div style="margin-top:12px;text-align:center;">
|
| 542 |
+
<span id="gaugeRiskLabel" class="text-xs font-bold tracking-widest" style="color:#22c55e;">LOW RISK</span>
|
| 543 |
+
</div>
|
| 544 |
+
<!-- Zone bars -->
|
| 545 |
+
<div style="margin-top:16px;width:100%;display:grid;grid-template-columns:repeat(4,1fr);gap:4px;" id="zoneBars">
|
| 546 |
+
<div class="zone-bar" data-zone="safe" data-label="0–30%" data-color="#22c55e"></div>
|
| 547 |
+
<div class="zone-bar" data-zone="review" data-label="30–50%" data-color="#f59e0b"></div>
|
| 548 |
+
<div class="zone-bar" data-zone="high" data-label="50–70%" data-color="#f97316"></div>
|
| 549 |
+
<div class="zone-bar" data-zone="fraud" data-label="70–100%" data-color="#ef4444"></div>
|
| 550 |
+
</div>
|
| 551 |
+
</div>
|
| 552 |
+
</div>
|
| 553 |
+
|
| 554 |
+
<!-- Verdict Card -->
|
| 555 |
+
<div class="verdict-card animate-fade-in-up" id="verdictCard" style="animation-delay:0.2s;opacity:0;">
|
| 556 |
+
<div style="display:flex;align-items:center;gap:12px;margin-bottom:12px;">
|
| 557 |
+
<div class="verdict-icon-box" id="verdictIconBox">
|
| 558 |
+
<i data-lucide="shield-off" id="verdictIcon" style="width:20px;height:20px;"></i>
|
| 559 |
+
</div>
|
| 560 |
+
<div>
|
| 561 |
+
<p id="verdictLabel" class="text-sm font-bold tracking-wider">FRAUDULENT</p>
|
| 562 |
+
<p id="verdictSublabel" class="text-xs" style="color:var(--muted-foreground);">Transaction flagged for fraud</p>
|
| 563 |
+
</div>
|
| 564 |
+
</div>
|
| 565 |
+
<p id="verdictDescription" class="text-xs" style="color:var(--muted-foreground);line-height:1.6;">This transaction has been flagged by the ML model as likely fraudulent. Immediate review and potential block recommended.</p>
|
| 566 |
+
</div>
|
| 567 |
+
|
| 568 |
+
<!-- Confidence Analysis -->
|
| 569 |
+
<div class="card-elevated p-4 animate-fade-in-up" style="animation-delay:0.3s;opacity:0;">
|
| 570 |
+
<p class="section-label mb-3">Confidence Analysis</p>
|
| 571 |
+
<div style="margin-bottom:16px;">
|
| 572 |
+
<div style="display:flex;justify-content:space-between;margin-bottom:4px;">
|
| 573 |
+
<span class="text-xs" style="color:var(--muted-foreground);">Model confidence</span>
|
| 574 |
+
<span class="text-xs font-mono font-semibold" id="confidenceText">—</span>
|
| 575 |
+
</div>
|
| 576 |
+
<div style="height:6px;background:var(--muted);border-radius:3px;overflow:hidden;">
|
| 577 |
+
<div id="confidenceBar" style="height:100%;width:0%;border-radius:3px;background:linear-gradient(90deg,var(--chart-tertiary),var(--fraud-red));transition:width 1s ease;"></div>
|
| 578 |
+
</div>
|
| 579 |
+
</div>
|
| 580 |
+
<div style="background:var(--muted);border:1px solid var(--border);border-radius:8px;padding:12px;margin-bottom:16px;">
|
| 581 |
+
<p style="font-size:11px;font-weight:500;color:var(--muted-foreground);margin-bottom:4px;">95% Confidence Interval</p>
|
| 582 |
+
<div style="display:flex;align-items:center;gap:8px;font-family:var(--font-mono);">
|
| 583 |
+
<span id="ciLow" style="color:var(--legit-green);font-size:11px;">—</span>
|
| 584 |
+
<div style="flex:1;height:1px;background:var(--border);"></div>
|
| 585 |
+
<span id="ciMid" style="color:var(--foreground);font-weight:600;font-size:11px;">—</span>
|
| 586 |
+
<div style="flex:1;height:1px;background:var(--border);"></div>
|
| 587 |
+
<span id="ciHigh" style="color:var(--fraud-red);font-size:11px;">—</span>
|
| 588 |
+
</div>
|
| 589 |
+
</div>
|
| 590 |
+
<p class="section-label mb-2">Model Performance</p>
|
| 591 |
+
<div style="display:flex;flex-direction:column;gap:8px;">
|
| 592 |
+
<div style="display:flex;justify-content:space-between;font-size:12px;">
|
| 593 |
+
<span style="color:var(--muted-foreground);">Model Precision</span>
|
| 594 |
+
<span style="font-family:var(--font-mono);font-weight:600;color:var(--legit-green);">94.2%</span>
|
| 595 |
+
</div>
|
| 596 |
+
<div style="display:flex;justify-content:space-between;font-size:12px;">
|
| 597 |
+
<span style="color:var(--muted-foreground);">Fraud Recall</span>
|
| 598 |
+
<span style="font-family:var(--font-mono);font-weight:600;color:var(--warn-amber);">91.7%</span>
|
| 599 |
+
</div>
|
| 600 |
+
<div style="display:flex;justify-content:space-between;font-size:12px;">
|
| 601 |
+
<span style="color:var(--muted-foreground);">F1 Score</span>
|
| 602 |
+
<span style="font-family:var(--font-mono);font-weight:600;color:var(--chart-tertiary);">0.929</span>
|
| 603 |
+
</div>
|
| 604 |
+
<div style="display:flex;justify-content:space-between;font-size:12px;">
|
| 605 |
+
<span style="color:var(--muted-foreground);">AUC-ROC</span>
|
| 606 |
+
<span style="font-family:var(--font-mono);font-weight:600;color:var(--fraud-red);">0.9481</span>
|
| 607 |
+
</div>
|
| 608 |
+
</div>
|
| 609 |
+
</div>
|
| 610 |
+
|
| 611 |
+
</div><!-- /result-col-left -->
|
| 612 |
+
|
| 613 |
+
<!-- Column 2: Feature Contributions -->
|
| 614 |
+
<div class="result-col-center">
|
| 615 |
+
<div class="card-elevated p-5 animate-fade-in-up" style="animation-delay:0.15s;opacity:0;height:100%;">
|
| 616 |
+
<div style="display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:4px;">
|
| 617 |
+
<div>
|
| 618 |
+
<p class="section-label">Feature Contribution Analysis</p>
|
| 619 |
+
<h3 style="font-size:15px;font-weight:600;margin-top:4px;">SHAP-Style Risk Factor Breakdown</h3>
|
| 620 |
+
</div>
|
| 621 |
+
<div style="display:flex;align-items:center;gap:16px;font-size:11px;color:var(--muted-foreground);">
|
| 622 |
+
<div style="display:flex;align-items:center;gap:6px;">
|
| 623 |
+
<div style="width:10px;height:10px;border-radius:2px;background:var(--fraud-red);"></div>
|
| 624 |
+
Increases fraud risk
|
| 625 |
+
</div>
|
| 626 |
+
<div style="display:flex;align-items:center;gap:6px;">
|
| 627 |
+
<div style="width:10px;height:10px;border-radius:2px;background:var(--legit-green);"></div>
|
| 628 |
+
Decreases fraud risk
|
| 629 |
+
</div>
|
| 630 |
+
</div>
|
| 631 |
+
</div>
|
| 632 |
+
<p class="text-xs mb-5" style="color:var(--muted-foreground);">Each bar shows how much a specific feature contributed to the fraud score. Longer bars indicate stronger influence.</p>
|
| 633 |
+
<div id="contributionsList" style="display:flex;flex-direction:column;gap:12px;">
|
| 634 |
+
<!-- Populated dynamically -->
|
| 635 |
+
</div>
|
| 636 |
+
<div style="margin-top:20px;display:flex;align-items:flex-start;gap:8px;background:var(--muted);border:1px solid var(--border);border-radius:8px;padding:12px;">
|
| 637 |
+
<i data-lucide="info" style="width:13px;height:13px;color:var(--muted-foreground);flex-shrink:0;margin-top:2px;"></i>
|
| 638 |
+
<p style="font-size:11px;color:var(--muted-foreground);line-height:1.6;">Feature contributions are computed using SHAP (SHapley Additive exPlanations) values from the Random Forest model. Red bars push the prediction toward fraud; green bars push it toward legitimate.</p>
|
| 639 |
+
</div>
|
| 640 |
+
</div>
|
| 641 |
+
</div>
|
| 642 |
+
|
| 643 |
+
<!-- Column 3: Transaction Summary + Analyst Actions -->
|
| 644 |
+
<div class="result-col-right">
|
| 645 |
+
|
| 646 |
+
<!-- Transaction Summary -->
|
| 647 |
+
<div class="card-elevated p-4 animate-fade-in-up" style="animation-delay:0.2s;opacity:0;">
|
| 648 |
+
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;">
|
| 649 |
+
<p class="section-label">Transaction Summary</p>
|
| 650 |
+
<button type="button" id="btnCopyTxnId" style="display:flex;align-items:center;gap:6px;font-size:10px;padding:4px 8px;border-radius:6px;background:var(--muted);border:1px solid var(--border);color:var(--muted-foreground);cursor:pointer;">
|
| 651 |
+
<i data-lucide="copy" style="width:11px;height:11px;"></i>
|
| 652 |
+
<span id="copyTxnIdText" class="font-mono" style="font-size:10px;">TXN-...</span>
|
| 653 |
+
</button>
|
| 654 |
+
</div>
|
| 655 |
+
<div id="txnSummaryList" style="display:flex;flex-direction:column;gap:4px;">
|
| 656 |
+
<!-- Populated dynamically -->
|
| 657 |
+
</div>
|
| 658 |
+
</div>
|
| 659 |
+
|
| 660 |
+
<!-- Analyst Actions -->
|
| 661 |
+
<div class="card-elevated p-4 animate-fade-in-up" style="animation-delay:0.3s;opacity:0;">
|
| 662 |
+
<p class="section-label mb-3">Analyst Actions</p>
|
| 663 |
+
<div style="display:flex;align-items:center;gap:8px;background:var(--muted);border:1px solid var(--border);border-radius:8px;padding:6px 10px;margin-bottom:12px;">
|
| 664 |
+
<div style="width:20px;height:20px;border-radius:50%;background:var(--chart-tertiary);display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;color:white;flex-shrink:0;">PS</div>
|
| 665 |
+
<span style="font-size:11px;color:var(--muted-foreground);">Analyst:</span>
|
| 666 |
+
<span style="font-size:12px;font-weight:500;">Parth Saxena</span>
|
| 667 |
+
</div>
|
| 668 |
+
<div id="analystActionsPanel">
|
| 669 |
+
<div style="display:flex;flex-direction:column;gap:8px;">
|
| 670 |
+
<button type="button" class="btn-primary" id="btnBlockTransaction">
|
| 671 |
+
<i data-lucide="shield-off" style="width:14px;height:14px;"></i>
|
| 672 |
+
Block Transaction
|
| 673 |
+
</button>
|
| 674 |
+
<button type="button" class="btn-secondary" id="btnApproveTransaction">
|
| 675 |
+
<i data-lucide="check" style="width:14px;height:14px;"></i>
|
| 676 |
+
Approve Transaction
|
| 677 |
+
</button>
|
| 678 |
+
<button type="button" class="btn-ghost" id="btnFlagEscalation">
|
| 679 |
+
<i data-lucide="flag" style="width:13px;height:13px;"></i>
|
| 680 |
+
Flag for Escalation
|
| 681 |
+
</button>
|
| 682 |
+
</div>
|
| 683 |
+
</div>
|
| 684 |
+
<div style="margin-top:12px;padding-top:12px;border-top:1px solid var(--border);">
|
| 685 |
+
<button type="button" id="btnAnalyzeAnother" style="width:100%;display:flex;align-items:center;justify-content:center;gap:8px;font-size:12px;padding:8px;border-radius:8px;background:transparent;border:none;color:var(--muted-foreground);cursor:pointer;transition:color 0.2s;">
|
| 686 |
+
<i data-lucide="file-search" style="width:13px;height:13px;"></i>
|
| 687 |
+
Analyze another transaction
|
| 688 |
+
<i data-lucide="chevron-right" style="width:12px;height:12px;"></i>
|
| 689 |
+
</button>
|
| 690 |
+
</div>
|
| 691 |
+
</div>
|
| 692 |
+
|
| 693 |
+
</div><!-- /result-col-right -->
|
| 694 |
+
</div>
|
| 695 |
+
</section>
|
| 696 |
+
|
| 697 |
+
<!-- ======== TOAST CONTAINER ======== -->
|
| 698 |
+
<div id="toastContainer" style="position:fixed;bottom:24px;right:24px;z-index:9999;display:flex;flex-direction:column;gap:8px;"></div>
|
| 699 |
+
|
| 700 |
+
</main>
|
| 701 |
+
</div>
|
| 702 |
+
|
| 703 |
+
<script src="/static/app.js"></script>
|
| 704 |
+
</body>
|
| 705 |
+
</html>
|
templates/index.html.metadata.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"summary": "Complete rewrite of FraudLens index.html to precisely match the original site's layout: sticky header with logo/nav/badge, form screen with 2-column collapsible cards, and a full result screen with gauge, verdict, feature contributions, transaction summary, and analyst actions.",
|
| 3 |
+
"updatedAt": "2026-07-09T14:56:14.421034500Z",
|
| 4 |
+
"userFacing": true
|
| 5 |
+
}
|