Spaces:
Running
Running
Download index.html from lousyrich/anycoder-014fe5ea: direct link, hf CLI and curl.
- Browser
- Download file 38.6 kB
-
https://huggingface.co/spaces/lousyrich/anycoder-014fe5ea/resolve/main/index.html
- Command line
-
hf download hf://spaces/lousyrich/anycoder-014fe5ea/index.html
-
curl -L -o index.html https://huggingface.co/spaces/lousyrich/anycoder-014fe5ea/resolve/main/index.html
38.6 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CIO Financial Crime & Fraud Monitoring Dashboard</title>
<!-- Importing FontAwesome for Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* --- CSS VARIABLES & RESET --- */
:root {
--bg-body: #0f172a;
--bg-panel: #1e293b;
--bg-panel-hover: #334155;
--primary: #3b82f6;
--primary-glow: rgba(59, 130, 246, 0.5);
--accent-green: #10b981;
--accent-red: #ef4444;
--accent-amber: #f59e0b;
--accent-purple: #8b5cf6;
--text-main: #f8fafc;
--text-muted: #94a3b8;
--border: #334155;
--radius: 12px;
--font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--transition: all 0.3s ease;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: var(--font-family);
background-color: var(--bg-body);
color: var(--text-main);
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden; /* Dashboard handles internal scrolling */
}
/* --- LAYOUT STRUCTURE --- */
header {
background-color: var(--bg-panel);
border-bottom: 1px solid var(--border);
padding: 0 24px;
height: 64px;
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
z-index: 10;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
font-weight: 700;
font-size: 1.2rem;
color: var(--primary);
text-shadow: 0 0 10px var(--primary-glow);
}
.brand i {
font-size: 1.5rem;
}
.header-controls {
display: flex;
align-items: center;
gap: 20px;
}
.built-with {
font-size: 0.85rem;
color: var(--text-muted);
text-decoration: none;
display: flex;
align-items: center;
gap: 6px;
transition: var(--transition);
}
.built-with:hover {
color: var(--primary);
}
.user-profile {
display: flex;
align-items: center;
gap: 12px;
font-size: 0.9rem;
}
.avatar {
width: 36px;
height: 36px;
border-radius: 50%;
background: linear-gradient(135deg, var(--primary), var(--accent-purple));
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
border: 2px solid var(--bg-body);
}
main {
flex: 1;
display: grid;
grid-template-columns: 260px 1fr;
grid-template-rows: auto 1fr;
overflow: hidden;
}
/* --- SIDEBAR --- */
aside {
background-color: var(--bg-panel);
border-right: 1px solid var(--border);
padding: 24px 16px;
display: flex;
flex-direction: column;
gap: 8px;
grid-row: 1 / -1;
}
.nav-item {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 16px;
border-radius: var(--radius);
color: var(--text-muted);
text-decoration: none;
transition: var(--transition);
cursor: pointer;
}
.nav-item:hover, .nav-item.active {
background-color: rgba(59, 130, 246, 0.1);
color: var(--primary);
}
.nav-item i {
width: 20px;
text-align: center;
}
/* --- DASHBOARD CONTENT --- */
.dashboard-container {
padding: 24px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 24px;
}
/* --- KPI CARDS --- */
.kpi-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 20px;
}
.kpi-card {
background-color: var(--bg-panel);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 20px;
position: relative;
overflow: hidden;
transition: var(--transition);
}
.kpi-card:hover {
border-color: var(--primary);
transform: translateY(-2px);
}
.kpi-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 12px;
}
.kpi-title {
font-size: 0.85rem;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.5px;
}
.kpi-icon {
padding: 8px;
border-radius: 8px;
background-color: rgba(255, 255, 255, 0.05);
color: var(--primary);
}
.kpi-value {
font-size: 1.8rem;
font-weight: 700;
margin-bottom: 8px;
}
.kpi-trend {
display: flex;
align-items: center;
gap: 6px;
font-size: 0.85rem;
}
.trend-up { color: var(--accent-green); }
.trend-down { color: var(--accent-red); }
/* --- CHARTS & ANALYSIS SECTION --- */
.analysis-grid {
display: grid;
grid-template-columns: 2fr 1fr;
gap: 20px;
min-height: 400px;
}
.panel {
background-color: var(--bg-panel);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 20px;
display: flex;
flex-direction: column;
}
.panel-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.panel-title {
font-size: 1.1rem;
font-weight: 600;
}
.filter-bar {
display: flex;
gap: 12px;
}
select {
background-color: var(--bg-body);
border: 1px solid var(--border);
color: var(--text-main);
padding: 6px 12px;
border-radius: 6px;
font-size: 0.9rem;
outline: none;
}
select:focus {
border-color: var(--primary);
}
/* Custom SVG Chart */
.chart-container {
flex: 1;
position: relative;
width: 100%;
min-height: 300px;
display: flex;
align-items: flex-end;
justify-content: space-between;
padding: 20px 0;
}
svg.trend-chart {
width: 100%;
height: 100%;
overflow: visible;
}
.chart-line {
fill: none;
stroke: var(--primary);
stroke-width: 3;
stroke-linecap: round;
stroke-linejoin: round;
vector-effect: non-scaling-stroke;
filter: drop-shadow(0 0 4px var(--primary-glow));
transition: d 0.5s ease;
}
.chart-area {
fill: url(#gradientArea);
stroke: none;
opacity: 0.3;
}
.chart-grid-line {
stroke: var(--border);
stroke-width: 1;
stroke-dasharray: 4 4;
}
.chart-tooltip {
position: absolute;
background: rgba(15, 23, 42, 0.9);
border: 1px solid var(--border);
padding: 8px 12px;
border-radius: 6px;
font-size: 0.8rem;
pointer-events: none;
opacity: 0;
transition: opacity 0.2s;
transform: translate(-50%, -120%);
white-space: nowrap;
z-index: 20;
}
/* Fraud Type Breakdown */
.breakdown-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.breakdown-item {
display: flex;
flex-direction: column;
gap: 4px;
}
.breakdown-header {
display: flex;
justify-content: space-between;
font-size: 0.9rem;
}
.progress-track {
height: 8px;
background-color: var(--bg-body);
border-radius: 4px;
overflow: hidden;
}
.progress-fill {
height: 100%;
border-radius: 4px;
background-color: var(--primary);
transition: width 1s ease-out;
}
/* --- TRANSACTION TABLE --- */
.table-container {
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
}
th {
text-align: left;
padding: 12px 16px;
color: var(--text-muted);
font-weight: 600;
border-bottom: 1px solid var(--border);
}
td {
padding: 12px 16px;
border-bottom: 1px solid var(--border);
color: var(--text-main);
}
tr:hover td {
background-color: rgba(255, 255, 255, 0.02);
cursor: pointer;
}
.status-badge {
padding: 4px 8px;
border-radius: 12px;
font-size: 0.75rem;
font-weight: 600;
display: inline-block;
}
.status-alert {
background-color: rgba(239, 68, 68, 0.15);
color: var(--accent-red);
border: 1px solid rgba(239, 68, 68, 0.3);
}
.status-warning {
background-color: rgba(245, 158, 11, 0.15);
color: var(--accent-amber);
border: 1px solid rgba(245, 158, 11, 0.3);
}
.status-safe {
background-color: rgba(16, 185, 129, 0.15);
color: var(--accent-green);
border: 1px solid rgba(16, 185, 129, 0.3);
}
/* --- MODAL (DRILL DOWN) --- */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
backdrop-filter: blur(4px);
display: flex;
justify-content: center;
align-items: center;
z-index: 100;
opacity: 0;
pointer-events: none;
transition: opacity 0.3s ease;
}
.modal-overlay.active {
opacity: 1;
pointer-events: all;
}
.modal-content {
background-color: var(--bg-panel);
border: 1px solid var(--border);
border-radius: var(--radius);
width: 90%;
max-width: 600px;
max-height: 85vh;
display: flex;
flex-direction: column;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
transform: scale(0.95);
transition: transform 0.3s ease;
}
.modal-overlay.active .modal-content {
transform: scale(1);
}
.modal-header {
padding: 20px;
border-bottom: 1px solid var(--border);
display: flex;
justify-content: space-between;
align-items: center;
}
.modal-body {
padding: 20px;
overflow-y: auto;
}
.close-modal {
background: none;
border: none;
color: var(--text-muted);
font-size: 1.2rem;
cursor: pointer;
}
.detail-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
margin-bottom: 24px;
}
.detail-item label {
display: block;
font-size: 0.8rem;
color: var(--text-muted);
margin-bottom: 4px;
}
.detail-item div {
font-size: 1rem;
font-weight: 500;
}
.workflow-steps {
display: flex;
flex-direction: column;
gap: 12px;
}
.step {
display: flex;
align-items: center;
gap: 12px;
padding: 12px;
background-color: var(--bg-body);
border-radius: 8px;
border-left: 3px solid var(--text-muted);
}
.step.completed {
border-left-color: var(--accent-green);
}
.step.pending {
border-left-color: var(--accent-amber);
}
.step-icon {
width: 24px;
height: 24px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.8rem;
}
.modal-footer {
padding: 20px;
border-top: 1px solid var(--border);
display: flex;
justify-content: flex-end;
gap: 12px;
}
.btn {
padding: 8px 16px;
border-radius: 6px;
border: none;
font-weight: 600;
cursor: pointer;
transition: var(--transition);
}
.btn-primary {
background-color: var(--primary);
color: white;
}
.btn-primary:hover {
background-color: #2563eb;
}
.btn-secondary {
background-color: transparent;
border: 1px solid var(--border);
color: var(--text-muted);
}
.btn-secondary:hover {
background-color: rgba(255, 255, 255, 0.05);
color: var(--text-main);
}
/* --- TOAST --- */
.toast-container {
position: fixed;
bottom: 24px;
right: 24px;
display: flex;
flex-direction: column;
gap: 10px;
z-index: 200;
}
.toast {
background-color: var(--bg-panel);
border-left: 4px solid var(--accent-green);
padding: 16px;
border-radius: 4px;
box-shadow: var(--shadow);
display: flex;
align-items: center;
gap: 12px;
min-width: 300px;
animation: slideIn 0.3s ease forwards;
}
@keyframes slideIn {
from { transform: translateX(100%); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
.analysis-grid {
grid-template-columns: 1fr;
}
}
@media (max-width: 768px) {
main {
grid-template-columns: 1fr;
}
aside {
display: none; /* In a real app, add a hamburger menu */
}
.header-controls span {
display: none;
}
.detail-grid {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<header>
<div class="brand">
<i class="fa-solid fa-shield-halved"></i>
<span>FraudGuard CIO</span>
</div>
<div class="header-controls">
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="built-with">
Built with anycoder <i class="fa-solid fa-arrow-up-right-from-square"></i>
</a>
<div class="user-profile">
<span>Dr. A. Vance</span>
<div class="avatar">AV</div>
</div>
</div>
</header>
<main>
<aside>
<a href="#" class="nav-item active" onclick="setActiveNav(this)">
<i class="fa-solid fa-chart-line"></i> Dashboard
</a>
<a href="#" class="nav-item" onclick="setActiveNav(this)">
<i class="fa-solid fa-globe"></i> Global Map
</a>
<a href="#" class="nav-item" onclick="setActiveNav(this)">
<i class="fa-solid fa-file-contract"></i> Compliance
</a>
<a href="#" class="nav-item" onclick="setActiveNav(this)">
<i class="fa-solid fa-users-gear"></i> Operations
</a>
<a href="#" class="nav-item" onclick="setActiveNav(this)">
<i class="fa-solid fa-sliders"></i> Model Config
</a>
</aside>
<div class="dashboard-container">
<!-- KPI Section -->
<section class="kpi-grid">
<div class="kpi-card">
<div class="kpi-header">
<span class="kpi-title">Total Fraud Loss Prevented</span>
<div class="kpi-icon" style="color: var(--accent-green); background: rgba(16,185,129,0.1);">
<i class="fa-solid fa-dollar-sign"></i>
</div>
</div>
<div class="kpi-value">$1,240,500</div>
<div class="kpi-trend trend-up">
<i class="fa-solid fa-arrow-trend-up"></i>
<span>+12.5% vs last month</span>
</div>
</div>
<div class="kpi-card">
<div class="kpi-header">
<span class="kpi-title">Detection Rate</span>
<div class="kpi-icon" style="color: var(--primary); background: rgba(59,130,246,0.1);">
<i class="fa-solid fa-radar"></i>
</div>
</div>
<div class="kpi-value">98.2%</div>
<div class="kpi-trend trend-down">
<i class="fa-solid fa-arrow-trend-down"></i>
<span>-0.4% (Target: 98.5%)</span>
</div>
</div>
<div class="kpi-card">
<div class="kpi-header">
<span class="kpi-title">Avg. Investigation Time</span>
<div class="kpi-icon" style="color: var(--accent-amber); background: rgba(245,158,11,0.1);">
<i class="fa-solid fa-stopwatch"></i>
</div>
</div>
<div class="kpi-value">4h 12m</div>
<div class="kpi-trend trend-up">
<i class="fa-solid fa-arrow-trend-up"></i>
<span>+8m (Efficiency drop)</span>
</div>
</div>
<div class="kpi-card">
<div class="kpi-header">
<span class="kpi-title">System Uptime</span>
<div class="kpi-icon" style="color: var(--accent-purple); background: rgba(139,92,246,0.1);">
<i class="fa-solid fa-server"></i>
</div>
</div>
<div class="kpi-value">99.99%</div>
<div class="kpi-trend trend-safe">
<span>Operational</span>
</div>
</div>
</section>
<!-- Charts Section -->
<section class="analysis-grid">
<div class="panel">
<div class="panel-header">
<span class="panel-title">Fraud Trend Analysis</span>
<div class="filter-bar">
<select id="periodSelect" onchange="updateCharts()">
<option value="7d">Last 7 Days</option>
<option value="30d" selected>Last 30 Days</option>
<option value="90d">Last Quarter</option>
</select>
</div>
</div>
<!-- SVG Chart Container -->
<div class="chart-container" id="trendChartContainer">
<svg class="trend-chart" preserveAspectRatio="none">
<defs>
<linearGradient id="gradientArea" x1="0" x2="0" y1="0" y2="1">
<stop offset="0%" stop-color="var(--primary)"/>
<stop offset="100%" stop-color="transparent"/>
</linearGradient>
</defs>
<g id="gridLines"></g>
<path id="chartArea" class="chart-area"></path>
<path id="chartLine" class="chart-line"></path>
<g id="chartPoints"></g>
</svg>
<div id="chartTooltip" class="chart-tooltip"></div>
</div>
</div>
<div class="panel">
<div class="panel-header">
<span class="panel-title">Fraud Types</span>
</div>
<div class="breakdown-list" id="breakdownContainer">
<!-- Injected via JS -->
</div>
</div>
</section>
<!-- Transaction Table -->
<section class="panel">
<div class="panel-header">
<span class="panel-title">Live Transaction Feed</span>
<div class="filter-bar">
<select id="merchantFilter" onchange="updateTable()">
<option value="All">All Merchants</option>
<option value="OnlineRetail">Online Retail</option>
<option value="Travel">Travel</option>
<option value="Food">Food & Beverage</option>
</select>
<select id="riskFilter" onchange="updateTable()">
<option value="All">All Risks</option>
<option value="High">High Risk</option>
<option value="Medium">Medium Risk</option>
</select>
</div>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>Transaction ID</th>
<th>Merchant</th>
<th>Category</th>
<th>Amount</th>
<th>Fraud Score</th>
<th>Status</th>
<th>Time</th>
</tr>
</thead>
<tbody id="transactionTableBody">
<!-- Injected via JS -->
</tbody>
</table>
</div>
</section>
</div>
</main>
<!-- Drilled Down Modal -->
<div class="modal-overlay" id="detailModal">
<div class="modal-content">
<div class="modal-header">
<h3 class="panel-title">Transaction Investigation</h3>
<button class="close-modal" onclick="closeModal()"><i class="fa-solid fa-xmark"></i></button>
</div>
<div class="modal-body">
<div class="detail-grid">
<div class="detail-item">
<label>Transaction ID</label>
<div id="modalTxId">#TX-00000</div>
</div>
<div class="detail-item">
<label>Detected By</label>
<div>Model v4.2 (AI Core)</div>
</div>
<div class="detail-item">
<label>Amount</label>
<div id="modalAmount" style="color: var(--accent-red);">$0.00</div>
</div>
<div class="detail-item">
<label>Fraud Type</label>
<div id="modalType">CNP Fraud</div>
</div>
<div class="detail-item">
<label>Merchant Category</label>
<div id="modalMerchant">Online Retail</div>
</div>
<div class="detail-item">
<label>Detected At</label>
<div id="modalTime">2023-10-27 14:30:00</div>
</div>
</div>
<h4 style="margin-bottom: 12px; font-size: 0.95rem;">Investigation Workflow</h4>
<div class="workflow-steps">
<div class="step completed" id="step1">
<div class="step-icon" style="background: var(--accent-green); color: white;"><i class="fa-solid fa-check"></i></div>
<div>
<div style="font-weight:600; font-size:0.9rem;">Rule Engine Match</div>
<div style="font-size:0.8rem; color:var(--text-muted);">Threshold breached > 85%</div>
</div>
</div>
<div class="step pending" id="step2">
<div class="step-icon" style="background: var(--bg-body); border: 1px solid var(--border);"><i class="fa-solid fa-hourglass-half"></i></div>
<div>
<div style="font-weight:600; font-size:0.9rem;">Identity Verification</div>
<div style="font-size:0.8rem; color:var(--text-muted);">Awaiting identity check</div>
</div>
</div>
<div class="step" id="step3">
<div class="step-icon" style="background: var(--bg-body); border: 1px solid var(--border);"><i class="fa-solid fa-gavel"></i></div>
<div>
<div style="font-weight:600; font-size:0.9rem;">Resolution</div>
<div style="font-size:0.8rem; color:var(--text-muted);">Pending decision</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" onclick="closeModal()">Close</button>
<button class="btn btn-primary" onclick="resolveTransaction()">Mark as Fraudulent</button>
</div>
</div>
</div>
<!-- Toast Container -->
<div class="toast-container" id="toastContainer"></div>
<script>
// --- DATA SIMULATION ---
const merchantCategories = ['Online Retail', 'Travel', 'Food & Beverage', 'Luxury Goods', 'Tech'];
const fraudTypes = ['CNP Fraud', 'ATO', 'Synthetic', 'Friendly Fraud', 'CP Fraud'];
// Generate Dummy Transactions
function generateTransactions(count) {
const data = [];
for (let i = 0; i < count; i++) {
const isFraud = Math.random() > 0.85; // 15% fraud
const score = isFraud ? (80 + Math.random() * 19).toFixed(1) : (Math.random() * 20).toFixed(1);
const type = fraudTypes[Math.floor(Math.random() * fraudTypes.length)];
const merchant = merchantCategories[Math.floor(Math.random() * merchantCategories.length)];
data.push({
id: `TX-${100000 + i}`,
merchant: merchant,
category: type,
amount: (Math.random() * 1000 + 10).toFixed(2),
score: parseFloat(score),
status: score > 70 ? 'Flagged' : 'Cleared',
type: type,
time: new Date(Date.now() - Math.floor(Math.random() * 1000000000)).toISOString()
});
}
return data.sort((a, b) => new Date(b.time) - new Date(a.time));
}
let transactions = generateTransactions(50);
let currentModalTx = null;
// --- RENDER FUNCTIONS ---
function renderKPIs() {
// Calculated from transactions
const fraudAmount = transactions
.filter(t => t.score > 70)
.reduce((acc, curr) => acc + parseFloat(curr.amount), 0);
// Update DOM (Static for this demo, but logic is ready)
const kpiFraud = document.querySelector('.kpi-value:nth-child(1)'); // Loss Prevented
// Just animating text for effect
kpiFraud.innerText = `$${fraudAmount.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 0})}`;
}
function renderBreakdown() {
const container = document.getElementById('breakdownContainer');
container.innerHTML = '';
// Group data
const counts = {};
fraudTypes.forEach(t => counts[t] = 0);
transactions.forEach(t => {
if (counts[t.category] !== undefined) counts[t.category]++;
});
const total = transactions.length;
// Color mapping
const colors = {
'CNP Fraud': '#3b82f6',
'ATO': '#ef4444',
'Synthetic': '#8b5cf6',
'Friendly Fraud': '#f59e0b',
'CP Fraud': '#10b981'
};
Object.keys(counts).forEach(type => {
const count = counts[type];
const pct = ((count / total) * 100).toFixed(1);
const item = document.createElement('div');
item.className = 'breakdown-item';
item.innerHTML = `
<div class="breakdown-header">
<span>${type}</span>
<span>${count} (${pct}%)</span>
</div>
<div class="progress-track">
<div class="progress-fill" style="width: ${pct}%; background-color: ${colors[type] || 'var(--text-muted)'}"></div>
</div>
`;
container.appendChild(item);
});
}
function renderTable() {
const tbody = document.getElementById('transactionTableBody');
const merchantFilter = document.getElementById('merchantFilter').value;
const riskFilter = document.getElementById('riskFilter').value;
tbody.innerHTML = '';
const filtered = transactions.filter(t => {
const matchMerchant = merchantFilter === 'All' || t.merchant === merchantFilter;
let matchRisk = true;
if (riskFilter === 'High') matchRisk = t.score > 70;
if (riskFilter === 'Medium') matchRisk = t.score > 40 && t.score <= 70;
return matchMerchant && matchRisk;
});
filtered.forEach(t => {
const tr = document.createElement('tr');
tr.onclick = () => openModal(t);
let statusClass = 'status-safe';
if (t.score > 70) statusClass = 'status-alert';
else if (t.score > 40) statusClass = 'status-warning';
tr.innerHTML = `
<td style="font-family:monospace; color:var(--primary)">${t.id}</td>
<td>${t.merchant}</td>
<td>${t.category}</td>
<td>$${parseFloat(t.amount).toFixed(2)}</td>
<td>
<div style="display:flex; align-items:center; gap:8px;">
<div style="width:50px; height:4px; background:#334155; border-radius:2px; overflow:hidden;">
<div style="width:${t.score}%; height:100%; background:${t.score > 70 ? 'var(--accent-red)' : 'var(--accent-green)'}"></div>
</div>
${t.score}
</div>
</td>
<td><span class="status-badge ${statusClass}">${t.status}</span></td>
<td style="color:var(--text-muted)">${new Date(t.time).toLocaleTimeString()}</td>
`;
tbody.appendChild(tr);
});
}
// --- SVG CHART LOGIC ---
function renderChart() {
const svg = document.querySelector('.trend-chart');
const width = svg.clientWidth;
const height = svg.clientHeight;
const padding = 20;
// Generate fake time-series data based on current transactions
const dataPoints = 7; // Last 7 days
const data = [];
for(let i=0; i<dataPoints; i++) {
data.push(Math.floor(Math.random() * 50) + 20); // Random volume/value
}
const maxVal = Math.max(...data) * 1.2;
const minVal = 0;
// Coordinate mapping
const getX = (index) => padding + (index / (dataPoints - 1)) * (width - padding * 2);
const getY = (val) => height - padding - ((val / maxVal) * (height - padding * 2));
// Build Path
let pathD = `M ${getX(0)} ${getY(data[0])}`;
let areaD = `M ${getX(0)} ${height - padding} L ${getX(0)} ${getY(data[0])}`;
data.forEach((val, i) => {
if (i === 0) return;
// Simple Bezier curve for smoothness
const x = getX(i);
const y = getY(val);
const prevX = getX(i-1);
const prevY = getY(data[i-1]);
const cp1x = prevX + (x - prevX) / 2;
const cp1y = prevY;
const cp2x = prevX + (x - prevX) / 2;
const cp2y = y;
pathD += ` C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${x} ${y}`;
areaD += ` C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${x} ${y}`;
});
areaD += ` L ${getX(dataPoints-1)} ${height - padding} Z`;
document.getElementById('chartLine').setAttribute('d', pathD);
document.getElementById('chartArea').setAttribute('d', areaD);
// Draw Grid
const gridGroup = document.getElementById('gridLines');
gridGroup.innerHTML = '';
for(let i=1; i<=4; i++) {
const y = height - padding - (i * (height - padding*2) / 4);
const line = document.createElementNS("http://www.w3.org/2000/svg", "line");
line.setAttribute("x1", padding);
line.setAttribute("y1", y);
line.setAttribute("x2", width - padding);
line.setAttribute("y2", y);
line.setAttribute("class", "chart-grid-line");
gridGroup.appendChild(line);
}
}
// --- INTERACTION LOGIC ---
function openModal(transaction) {
currentModalTx = transaction;
document.getElementById('modalTxId').innerText = transaction.id;
document.getElementById('modalAmount').innerText = `$${parseFloat(transaction.amount).toFixed(2)}`;
document.getElementById('modalType').innerText = transaction.category;
document.getElementById('modalMerchant').innerText = transaction.merchant;
document.getElementById('modalTime').innerText = transaction.time.replace('T', ' ').slice(0, 19);
// Reset workflow
document.getElementById('step1').className = 'step completed';
document.getElementById('step2').className = 'step pending';
document.getElementById('step3').className = 'step';
document.getElementById('detailModal').classList.add('active');
}
function closeModal() {
document.getElementById('detailModal').classList.remove('active');
currentModalTx = null;
}
function resolveTransaction() {
if(!currentModalTx) return;
// Simulate processing
const btn = document.querySelector('.modal-footer .btn-primary');
const originalText = btn.innerText;
btn.innerText = 'Processing...';
btn.disabled = true;
setTimeout(() => {
closeModal();
showToast(`Transaction ${currentModalTx.id} marked as Fraudulent.`, 'success');
btn.innerText = originalText;
btn.disabled = false;
// Update Data
currentModalTx.status = 'Resolved';
currentModalTx.score = 100;
renderTable();
renderBreakdown();
}, 1000);
}
function showToast(message, type) {
const container = document.getElementById('toastContainer');
const toast = document.createElement('div');
toast.className = 'toast';
const icon = type === 'success' ? '<i class="fa
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CIO Financial Crime & Fraud Monitoring Dashboard</title>
<!-- Importing FontAwesome for Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* --- CSS VARIABLES & RESET --- */
:root {
--bg-body: #0f172a;
--bg-panel: #1e293b;
--bg-panel-hover: #334155;
--primary: #3b82f6;
--primary-glow: rgba(59, 130, 246, 0.5);
--accent-green: #10b981;
--accent-red: #ef4444;
--accent-amber: #f59e0b;
--accent-purple: #8b5cf6;
--text-main: #f8fafc;
--text-muted: #94a3b8;
--border: #334155;
--radius: 12px;
--font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--transition: all 0.3s ease;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: var(--font-family);
background-color: var(--bg-body);
color: var(--text-main);
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden; /* Dashboard handles internal scrolling */
}
/* --- LAYOUT STRUCTURE --- */
header {
background-color: var(--bg-panel);
border-bottom: 1px solid var(--border);
padding: 0 24px;
height: 64px;
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
z-index: 10;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
font-weight: 700;
font-size: 1.2rem;
color: var(--primary);
text-shadow: 0 0 10px var(--primary-glow);
}
.brand i {
font-size: 1.5rem;
}
.header-controls {
display: flex;
align-items: center;
gap: 20px;
}
.built-with {
font-size: 0.85rem;
color: var(--text-muted);
text-decoration: none;
display: flex;
align-items: center;
gap: 6px;
transition: var(--transition);
}
.built-with:hover {
color: var(--primary);
}
.user-profile {
display: flex;
align-items: center;
gap: 12px;
font-size: 0.9rem;
}