<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OmniAnti — Real Threat Protection</title>
<link href="https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Rajdhani:wght@300;400;600;700&family=Orbitron:wght@400;700;900&display=swap" rel="stylesheet">
<style>
:root {
  --bg: #020b14; --panel: #040f1c; --border: #0a2540;
  --accent: #00d4ff; --accent2: #ff3b3b; --accent3: #00ff88;
  --text: #c8e0f4; --dim: #3a5a7a; --warn: #ffaa00;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
  background:var(--bg); color:var(--text);
  font-family:'Rajdhani',sans-serif; min-height:100vh; overflow-x:hidden;
}
body::before {
  content:''; position:fixed; inset:0;
  background-image: linear-gradient(rgba(0,212,255,0.025) 1px,transparent 1px),
                    linear-gradient(90deg,rgba(0,212,255,0.025) 1px,transparent 1px);
  background-size:40px 40px; pointer-events:none; z-index:0;
}
body::after {
  content:''; position:fixed; top:-50%; left:-50%; width:200%; height:200%;
  background: radial-gradient(ellipse at 60% 40%,rgba(0,60,120,0.15) 0%,transparent 60%),
              radial-gradient(ellipse at 20% 80%,rgba(0,212,255,0.05) 0%,transparent 50%);
  pointer-events:none; z-index:0;
}
.wrap { position:relative; z-index:1; max-width:1280px; margin:0 auto; padding:0 20px; }

/* HEADER */
header { padding:16px 0; border-bottom:1px solid var(--border); }
.hdr { display:flex; align-items:center; justify-content:space-between; }
.logo { display:flex; align-items:center; gap:12px; }
.logo svg { animation:shieldPulse 2s ease-in-out infinite; }
@keyframes shieldPulse {
  0%,100%{ filter:drop-shadow(0 0 6px rgba(0,212,255,.6)); }
  50%{ filter:drop-shadow(0 0 18px rgba(0,212,255,1)); }
}
.logo h1 { font-family:'Orbitron',sans-serif; font-size:20px; font-weight:900; letter-spacing:4px; color:#fff; text-shadow:0 0 20px rgba(0,212,255,.5); }
.logo p { font-size:10px; letter-spacing:3px; color:var(--dim); font-family:'Share Tech Mono',monospace; margin-top:2px; }
.hdr-right { display:flex; align-items:center; gap:20px; }
.badge { display:flex; align-items:center; gap:7px; font-family:'Share Tech Mono',monospace; font-size:11px; letter-spacing:1px; }
.dot { width:8px; height:8px; border-radius:50%; animation:blink 1.5s ease-in-out infinite; }
.dot.green { background:var(--accent3); box-shadow:0 0 8px var(--accent3); }
.dot.red { background:var(--accent2); box-shadow:0 0 8px var(--accent2); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
.sys-info { font-family:'Share Tech Mono',monospace; font-size:10px; color:var(--dim); }

/* LAYOUT */
.main { display:grid; grid-template-columns:260px 1fr; gap:16px; padding:16px 0; min-height:calc(100vh - 80px); }

/* PANELS */
.panel { background:var(--panel); border:1px solid var(--border); border-radius:4px; overflow:hidden; position:relative; }
.panel::before { content:''; position:absolute; top:0; left:0; right:0; height:2px; background:linear-gradient(90deg,transparent,var(--accent),transparent); opacity:.4; }
.ph { padding:10px 14px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.pt { font-family:'Orbitron',sans-serif; font-size:9px; letter-spacing:3px; color:var(--accent); text-transform:uppercase; }
.pb { padding:14px; }

/* SIDEBAR */
.sidebar { display:flex; flex-direction:column; gap:14px; }
.nav-item { display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:3px; cursor:pointer; font-size:13px; font-weight:600; letter-spacing:1px; transition:all .2s; border:1px solid transparent; margin-bottom:3px; color:var(--dim); }
.nav-item:hover,.nav-item.active { background:rgba(0,212,255,.07); border-color:rgba(0,212,255,.2); color:var(--accent); }

.ring-wrap { display:flex; justify-content:center; padding:16px 0; }
.ring-out { width:110px; height:110px; border-radius:50%; border:1.5px solid rgba(0,212,255,.2); display:flex; align-items:center; justify-content:center; position:relative; }
.ring-out::after { content:''; position:absolute; inset:-20px; border-radius:50%; border:1px solid transparent; border-top-color:rgba(0,212,255,.35); animation:spin 6s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }
.ring-in { width:74px; height:74px; border-radius:50%; background:radial-gradient(circle,rgba(0,212,255,.12),transparent); border:1px solid rgba(0,212,255,.25); display:flex; flex-direction:column; align-items:center; justify-content:center; font-family:'Orbitron',sans-serif; }
.ring-num { font-size:18px; font-weight:700; color:var(--accent3); line-height:1; }
.ring-lbl { font-size:7px; letter-spacing:1px; color:var(--dim); margin-top:2px; }
.mini-stats { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.mini-stat { background:rgba(0,0,0,.3); border:1px solid var(--border); border-radius:3px; padding:8px; text-align:center; }
.mn { font-family:'Orbitron',sans-serif; font-size:15px; font-weight:700; }
.ml { font-size:10px; color:var(--dim); letter-spacing:1px; margin-top:2px; text-transform:uppercase; }

/* QUICK ACTIONS */
.qa-btn { width:100%; padding:9px; font-family:'Orbitron',sans-serif; font-size:10px; letter-spacing:2px; cursor:pointer; border-radius:3px; transition:all .2s; margin-bottom:7px; }
.qa-blue { background:rgba(0,212,255,.1); border:1px solid var(--accent); color:var(--accent); }
.qa-green { background:rgba(0,255,136,.07); border:1px solid rgba(0,255,136,.3); color:var(--accent3); }
.qa-yellow { background:rgba(255,170,0,.07); border:1px solid rgba(255,170,0,.3); color:var(--warn); }
.qa-btn:hover { filter:brightness(1.25); box-shadow:0 0 12px rgba(0,212,255,.2); }

/* CONTENT */
.content { display:flex; flex-direction:column; gap:14px; }
.stat-row { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; }
.sc { background:var(--panel); border:1px solid var(--border); border-radius:4px; padding:14px; position:relative; overflow:hidden; }
.sc::after { content:''; position:absolute; bottom:0; left:0; right:0; height:2px; }
.sc.c1::after{background:var(--accent)} .sc.c2::after{background:var(--accent2)} .sc.c3::after{background:var(--accent3)} .sc.c4::after{background:var(--warn)}
.sc-num { font-family:'Orbitron',sans-serif; font-size:26px; font-weight:700; line-height:1; }
.sc.c1 .sc-num{color:var(--accent)} .sc.c2 .sc-num{color:var(--accent2)} .sc.c3 .sc-num{color:var(--accent3)} .sc.c4 .sc-num{color:var(--warn)}
.sc-lbl { font-size:10px; color:var(--dim); letter-spacing:2px; text-transform:uppercase; margin-top:5px; }
.sc-sub { font-family:'Share Tech Mono',monospace; font-size:10px; color:var(--dim); margin-top:6px; }

/* SCAN PANEL */
.scan-panel { background:var(--panel); border:1px solid var(--border); border-radius:4px; overflow:hidden; position:relative; }
.scan-panel::before { content:''; position:absolute; top:0; left:0; right:0; height:2px; background:linear-gradient(90deg,var(--accent2),var(--accent),var(--accent3)); }
.scan-hdr { padding:16px 20px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.scan-hdr h2 { font-family:'Orbitron',sans-serif; font-size:13px; letter-spacing:3px; color:#fff; }
.tabs { display:flex; border-bottom:1px solid var(--border); padding:0 20px; }
.tab { padding:10px 16px; font-family:'Share Tech Mono',monospace; font-size:10px; letter-spacing:1px; color:var(--dim); cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; text-transform:uppercase; transition:all .2s; }
.tab.active { color:var(--accent); border-bottom-color:var(--accent); }
.tc { display:none; } .tc.active { display:block; }

/* SCAN TYPES */
.scan-opts { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; padding:16px 20px; border-bottom:1px solid var(--border); }
.so { background:rgba(0,0,0,.3); border:1px solid var(--border); border-radius:4px; padding:14px; cursor:pointer; transition:all .2s; position:relative; }
.so:hover,.so.sel { border-color:var(--accent); background:rgba(0,212,255,.05); }
.so.sel::after { content:'✓'; position:absolute; top:7px; right:9px; color:var(--accent); font-size:11px; }
.so-icon { font-size:22px; margin-bottom:6px; }
.so-name { font-size:12px; font-weight:700; letter-spacing:1px; color:#fff; }
.so-desc { font-size:10px; color:var(--dim); margin-top:3px; }

/* FILE EXPLORER */
.ft-wrap { padding:16px 20px; }
.ft-title { font-family:'Share Tech Mono',monospace; font-size:10px; letter-spacing:2px; color:var(--dim); margin-bottom:10px; text-transform:uppercase; }
.ft-path { display:flex; gap:8px; margin-bottom:10px; }
.ft-path input {
  flex:1; background:rgba(0,0,0,.4); border:1px solid var(--border); color:var(--text);
  padding:7px 10px; font-family:'Share Tech Mono',monospace; font-size:11px; border-radius:3px;
}
.ft-path input:focus { outline:none; border-color:var(--accent); }
.ft-path button { background:rgba(0,212,255,.1); border:1px solid var(--accent); color:var(--accent); padding:7px 14px; font-family:'Orbitron',monospace; font-size:9px; letter-spacing:1px; cursor:pointer; border-radius:3px; }
.file-tree { background:rgba(0,0,0,.4); border:1px solid var(--border); border-radius:3px; padding:10px; max-height:180px; overflow-y:auto; font-family:'Share Tech Mono',monospace; font-size:11px; }
.ti { display:flex; align-items:center; gap:7px; padding:3px 5px; border-radius:2px; cursor:pointer; transition:background .15s; }
.ti:hover,.ti.sel { background:rgba(0,212,255,.07); }
.ti.threat { color:var(--accent2); }
.ti .ind { margin-left:14px; }
.ti .ind2 { margin-left:28px; }

/* CMD CHECKS */
.cmd-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:7px; padding:14px 20px; }
.ci { background:rgba(0,0,0,.3); border:1px solid var(--border); border-radius:3px; padding:9px 12px; display:flex; align-items:center; gap:9px; font-family:'Share Tech Mono',monospace; font-size:10px; cursor:pointer; transition:all .2s; color:var(--dim); }
.ci:hover { border-color:rgba(0,212,255,.3); color:var(--text); }
.cd { width:6px; height:6px; border-radius:50%; flex-shrink:0; }
.ci.done .cd { background:var(--accent3); box-shadow:0 0 6px var(--accent3); }
.ci.running .cd { background:var(--warn); animation:blink .7s infinite; }
.ci.pending .cd { background:var(--dim); }

/* CMD OUTPUT */
.cmd-out { background:rgba(0,0,0,.5); border:1px solid var(--border); border-radius:3px; padding:10px; max-height:160px; overflow-y:auto; font-family:'Share Tech Mono',monospace; font-size:10px; color:#667; margin:0 20px 14px; display:none; }
.cmd-out.show { display:block; }

/* RESULTS */
.threats-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:9px; padding:14px 20px; }
.tcard { background:rgba(255,59,59,.05); border:1px solid rgba(255,59,59,.2); border-radius:3px; padding:11px; animation:fadeIn .3s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateX(-5px)} to{opacity:1;transform:none} }
.tc-hdr { display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
.tc-name { font-family:'Share Tech Mono',monospace; font-size:11px; color:var(--accent2); font-weight:bold; }
.sev { font-size:9px; padding:2px 7px; border-radius:2px; font-family:'Share Tech Mono',monospace; }
.s-hi { background:rgba(255,59,59,.2); color:var(--accent2); border:1px solid rgba(255,59,59,.4); }
.s-me { background:rgba(255,170,0,.2); color:var(--warn); border:1px solid rgba(255,170,0,.4); }
.s-lo { background:rgba(0,212,255,.1); color:var(--accent); border:1px solid rgba(0,212,255,.2); }
.tc-path { font-family:'Share Tech Mono',monospace; font-size:9px; color:var(--dim); word-break:break-all; margin-bottom:8px; }
.tc-btns { display:flex; gap:7px; }
.btn-q { font-size:9px; padding:3px 9px; border:1px solid var(--warn); background:rgba(255,170,0,.1); color:var(--warn); border-radius:2px; cursor:pointer; font-family:'Share Tech Mono',monospace; }
.btn-r { font-size:9px; padding:3px 9px; border:1px solid var(--accent2); background:rgba(255,59,59,.1); color:var(--accent2); border-radius:2px; cursor:pointer; font-family:'Share Tech Mono',monospace; }

/* SCAN CONTROLS */
.scan-ctrl { padding:16px 20px; display:flex; align-items:center; gap:14px; border-top:1px solid var(--border); }
.btn-start { background:linear-gradient(135deg,rgba(0,212,255,.2),rgba(0,212,255,.08)); border:1px solid var(--accent); color:var(--accent); padding:11px 32px; font-family:'Orbitron',sans-serif; font-size:10px; letter-spacing:3px; cursor:pointer; border-radius:3px; transition:all .25s; }
.btn-start:hover { box-shadow:0 0 20px rgba(0,212,255,.3); }
.btn-stop { background:rgba(255,59,59,.1); border:1px solid var(--accent2); color:var(--accent2); padding:11px 22px; font-family:'Orbitron',sans-serif; font-size:10px; letter-spacing:3px; cursor:pointer; border-radius:3px; display:none; }
.prog-wrap { flex:1; display:none; flex-direction:column; gap:5px; }
.prog-out { height:5px; background:rgba(0,0,0,.5); border:1px solid var(--border); border-radius:3px; overflow:hidden; }
.prog-in { height:100%; background:linear-gradient(90deg,var(--accent),var(--accent3)); width:0%; transition:width .4s; box-shadow:0 0 8px rgba(0,212,255,.5); }
.prog-txt { font-family:'Share Tech Mono',monospace; font-size:10px; color:var(--dim); display:flex; justify-content:space-between; }

/* BANNER */
.banner { margin:0 20px 12px; border-radius:3px; padding:12px 16px; font-family:'Share Tech Mono',monospace; font-size:11px; display:none; align-items:center; gap:10px; }
.banner.ok { background:rgba(0,255,136,.05); border:1px solid rgba(0,255,136,.2); color:var(--accent3); }
.banner.danger { background:rgba(255,59,59,.05); border:1px solid rgba(255,59,59,.2); color:var(--accent2); }
.no-results { padding:20px; text-align:center; font-family:'Share Tech Mono',monospace; font-size:11px; color:var(--dim); }

/* TERMINAL */
.terminal { background:rgba(0,0,0,.55); border:1px solid var(--border); border-radius:4px; overflow:hidden; }
.term-hdr { padding:9px 14px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:7px; background:rgba(0,0,0,.25); }
.tdot { width:8px; height:8px; border-radius:50%; }
.term-body { padding:12px; font-family:'Share Tech Mono',monospace; font-size:11px; line-height:1.75; height:200px; overflow-y:auto; }
.ll { animation:fadeIn .25s ease; }
.l-ok{color:var(--accent3)} .l-warn{color:var(--warn)} .l-threat{color:var(--accent2)} .l-info{color:var(--accent)} .l-cmd{color:#556} .l-error{color:#f44}

/* NOTIF */
.notif { position:fixed; top:16px; right:16px; background:var(--panel); border:1px solid var(--border); border-left:3px solid var(--accent3); border-radius:3px; padding:12px 16px; font-family:'Share Tech Mono',monospace; font-size:11px; color:var(--text); z-index:100; transform:translateX(120%); transition:transform .3s; max-width:280px; }
.notif.show { transform:translateX(0); }
.notif.bad { border-left-color:var(--accent2); }

::-webkit-scrollbar { width:4px; height:4px; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:2px; }
</style>
</head>
<body>
<div class="wrap">
  <!-- HEADER -->
  <header>
    <div class="hdr">
      <div class="logo">
        <svg width="42" height="42" viewBox="0 0 44 44" fill="none">
          <path d="M22 3 L38 10 L38 22 C38 31 30 39 22 41 C14 39 6 31 6 22 L6 10 Z" stroke="#00d4ff" stroke-width="1.5" fill="rgba(0,212,255,0.08)"/>
          <path d="M16 22 L20 26 L28 18" stroke="#00ff88" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
        </svg>
        <div>
          <h1>OMNIANTI</h1>
          <p>REAL SYSTEM SCANNER v1.0 — <span id="osPlatform">Detecting...</span></p>
        </div>
      </div>
      <div class="hdr-right">
        <div class="badge" id="serverBadge">
          <div class="dot red" id="serverDot"></div>
          <span id="serverStatus" style="color:var(--accent2)">CONNECTING...</span>
        </div>
        <div class="sys-info" id="sysInfo">Loading system info...</div>
      </div>
    </div>
  </header>

  <div class="main">
    <!-- SIDEBAR -->
    <div class="sidebar">
      <div class="panel">
        <div class="ph"><span class="pt">Navigation</span></div>
        <div style="padding:6px 8px;">
          <div class="nav-item active">
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg> SCANNER
          </div>
          <div class="nav-item">
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg> QUARANTINE
          </div>
          <div class="nav-item">
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14,2 14,8 20,8"/></svg> LOGS
          </div>
        </div>
      </div>

      <div class="panel">
        <div class="ph"><span class="pt">Protection Status</span></div>
        <div class="pb">
          <div class="ring-wrap">
            <div class="ring-out">
              <div class="ring-in">
                <div class="ring-num" id="protPct">100%</div>
                <div class="ring-lbl" id="protLbl">SECURE</div>
              </div>
            </div>
          </div>
          <div class="mini-stats">
            <div class="mini-stat"><div class="mn" id="sFiles" style="color:var(--accent)">0</div><div class="ml">Scanned</div></div>
            <div class="mini-stat"><div class="mn" id="sThreats" style="color:var(--accent2)">0</div><div class="ml">Threats</div></div>
          </div>
        </div>
      </div>

      <div class="panel">
        <div class="ph"><span class="pt">Quick Actions</span></div>
        <div class="pb" style="padding:10px;">
          <button class="qa-btn qa-blue" onclick="startScan('quick')">⚡ QUICK SCAN</button>
          <button class="qa-btn qa-green" onclick="startScan('full')">🛡 FULL SCAN</button>
          <button class="qa-btn qa-yellow" onclick="stopScan()">■ STOP SCAN</button>
        </div>
      </div>
    </div>

    <!-- CONTENT -->
    <div class="content">
      <!-- STATS -->
      <div class="stat-row">
        <div class="sc c1"><div class="sc-num" id="s1">0</div><div class="sc-lbl">Files Scanned</div><div class="sc-sub" id="s1sub">Real filesystem scan</div></div>
        <div class="sc c2"><div class="sc-num" id="s2">0</div><div class="sc-lbl">Threats Found</div><div class="sc-sub">Live detection</div></div>
        <div class="sc c3"><div class="sc-num" id="s3">0</div><div class="sc-lbl">Quarantined</div><div class="sc-sub">Actions taken</div></div>
        <div class="sc c4"><div class="sc-num" id="s4">0</div><div class="sc-lbl">CMD Checks</div><div class="sc-sub">Real commands run</div></div>
      </div>

      <!-- SCAN PANEL -->
      <div class="scan-panel">
        <div class="scan-hdr">
          <h2>SCAN ENGINE — REAL SYSTEM</h2>
          <span style="font-family:'Share Tech Mono',monospace;font-size:10px;color:var(--dim);">REAL CHECKS ACTIVE</span>
        </div>

        <div class="tabs">
          <div class="tab active" data-tab="type">Scan Type</div>
          <div class="tab" data-tab="files">File Explorer</div>
          <div class="tab" data-tab="cmds">CMD Checks</div>
          <div class="tab" data-tab="results">Results</div>
        </div>

        <!-- SCAN TYPE -->
        <div class="tc active" id="tc-type">
          <div class="scan-opts">
            <div class="so sel" data-type="quick">
              <div class="so-icon">⚡</div>
              <div class="so-name">QUICK SCAN</div>
              <div class="so-desc">Temp dirs, Downloads, startup entries, processes</div>
            </div>
            <div class="so" data-type="full">
              <div class="so-icon">🛡️</div>
              <div class="so-name">FULL SYSTEM</div>
              <div class="so-desc">All drives, every folder, hidden files + all checks</div>
            </div>
            <div class="so" data-type="custom">
              <div class="so-icon">🎯</div>
              <div class="so-name">CUSTOM PATH</div>
              <div class="so-desc">Specify exact path in File Explorer tab</div>
            </div>
            <div class="so" data-type="memory">
              <div class="so-icon">💾</div>
              <div class="so-name">PROCESS SCAN</div>
              <div class="so-desc">Running processes, open ports, active connections</div>
            </div>
            <div class="so" data-type="network">
              <div class="so-icon">🌐</div>
              <div class="so-name">NETWORK SCAN</div>
              <div class="so-desc">netstat, DNS cache, suspicious domains</div>
            </div>
            <div class="so" data-type="rootkit">
              <div class="so-icon">🔬</div>
              <div class="so-name">DEEP SCAN</div>
              <div class="so-desc">Services, scheduled tasks, registry, event logs</div>
            </div>
          </div>
        </div>

        <!-- FILE EXPLORER -->
        <div class="tc" id="tc-files">
          <div class="ft-wrap">
            <div class="ft-title">▶ Enter Custom Path to Scan</div>
            <div class="ft-path">
              <input type="text" id="customPath" placeholder="e.g. C:\Users\YourName\Downloads or /home/user" />
              <button onclick="setCustomPath()">SET PATH</button>
            </div>
            <div class="ft-title" style="margin-top:12px;">▶ Default Scan Targets (Quick Scan)</div>
            <div class="file-tree" id="fileTree">
              <div class="ti sel">📁 %TEMP% — Temporary Files</div>
              <div class="ti sel">📁 ~/Downloads — Download Folder</div>
              <div class="ti sel">📁 ~/Desktop — Desktop</div>
              <div class="ti">📁 C:\Windows\Temp</div>
              <div class="ti">📁 C:\Users\Public</div>
              <div class="ti">📄 Registry — HKLM\...\Run</div>
              <div class="ti">📄 Registry — HKCU\...\Run</div>
              <div class="ti">📄 Scheduled Tasks</div>
              <div class="ti">📄 Running Processes</div>
              <div class="ti">📄 Network Connections</div>
              <div class="ti">📄 DNS Cache</div>
              <div class="ti">📄 System Services</div>
              <div class="ti">📄 Security Event Logs</div>
            </div>
          </div>
        </div>

        <!-- CMD CHECKS -->
        <div class="tc" id="tc-cmds">
          <div class="cmd-grid" id="cmdGrid">
            <div class="ci pending" data-cmd="netstat -ano"><div class="cd"></div>netstat -ano (open ports)</div>
            <div class="ci pending" data-cmd="tasklist /v"><div class="cd"></div>tasklist /v (all processes)</div>
            <div class="ci pending" data-cmd="reg query HKLM Run"><div class="cd"></div>Registry — HKLM Startup</div>
            <div class="ci pending" data-cmd="reg query HKCU Run"><div class="cd"></div>Registry — HKCU Startup</div>
            <div class="ci pending" data-cmd="sfc /scannow"><div class="cd"></div>sfc /scannow (file integrity)</div>
            <div class="ci pending" data-cmd="ipconfig /displaydns"><div class="cd"></div>ipconfig /displaydns</div>
            <div class="ci pending" data-cmd="sc query all"><div class="cd"></div>sc query (all services)</div>
            <div class="ci pending" data-cmd="schtasks /query"><div class="cd"></div>schtasks /query (tasks)</div>
            <div class="ci pending" data-cmd="wevtutil Security log"><div class="cd"></div>wevtutil (security events)</div>
            <div class="ci pending" data-cmd="dir %TEMP%"><div class="cd"></div>dir %TEMP% (temp files)</div>
            <div class="ci pending" data-cmd="ps aux / WMIC"><div class="cd"></div>Process deep scan (WMIC)</div>
            <div class="ci pending" data-cmd="SHA-256 hash check"><div class="cd"></div>SHA-256 hash checking</div>
          </div>
          <div class="cmd-out" id="cmdOut"></div>
        </div>

        <!-- RESULTS -->
        <div class="tc" id="tc-results">
          <div class="banner ok" id="bannerOk">
            <span style="font-size:18px;">✅</span>
            <div><div style="font-weight:bold;letter-spacing:1px;">SCAN COMPLETE — CLEAN</div>
            <div style="color:var(--dim);font-size:10px;margin-top:2px;" id="cleanSummary">No threats detected.</div></div>
          </div>
          <div class="banner danger" id="bannerThreat">
            <span style="font-size:18px;">⚠️</span>
            <div><div style="font-weight:bold;letter-spacing:1px;">REAL THREATS DETECTED</div>
            <div style="color:var(--dim);font-size:10px;margin-top:2px;" id="threatSummary">See details below.</div></div>
          </div>
          <div class="threats-grid" id="threatsGrid"></div>
          <div class="no-results" id="noResults">Run a scan to see real results here.</div>
        </div>

        <!-- CONTROLS -->
        <div class="scan-ctrl">
          <button class="btn-start" id="btnStart" onclick="startScan()">▶ START SCAN</button>
          <button class="btn-stop" id="btnStop" onclick="stopScan()">■ STOP</button>
          <div class="prog-wrap" id="progWrap">
            <div class="prog-out"><div class="prog-in" id="progBar"></div></div>
            <div class="prog-txt"><span id="progLbl">Scanning...</span><span id="progPct">0%</span></div>
          </div>
        </div>
      </div>

      <!-- TERMINAL -->
      <div class="terminal">
        <div class="term-hdr">
          <div class="tdot" style="background:#ff5f57"></div>
          <div class="tdot" style="background:#ffbd2e"></div>
          <div class="tdot" style="background:#28ca41"></div>
          <span style="font-family:'Share Tech Mono',monospace;font-size:10px;color:var(--dim);margin-left:6px;">OMNIANTI — REAL-TIME SYSTEM LOG</span>
          <span style="margin-left:auto;font-family:'Share Tech Mono',monospace;font-size:10px;color:var(--dim);" id="clock"></span>
        </div>
        <div class="term-body" id="termBody">
          <div class="ll l-info">[OMNIANTI] Initializing real system scanner...</div>
          <div class="ll l-info">[OMNIANTI] Connecting to backend server at localhost:5000...</div>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="notif" id="notif"></div>

<script>
const API = 'http://localhost:5000/api';
let polling = null;
let logOffset = 0;
let selectedScanType = 'quick';
let customScanPath = null;
let quarantineCount = 0;
let cmdsDoneCount = 0;
let serverOnline = false;

// ── CLOCK ──
function updateClock() {
  document.getElementById('clock').textContent = new Date().toLocaleTimeString('en-US',{hour12:false});
}
setInterval(updateClock, 1000); updateClock();

// ── TABS ──
document.querySelectorAll('.tab').forEach(tab => {
  tab.onclick = () => {
    document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
    document.querySelectorAll('.tc').forEach(c => c.classList.remove('active'));
    tab.classList.add('active');
    document.getElementById('tc-' + tab.dataset.tab).classList.add('active');
  };
});

// ── SCAN TYPE SELECTION ──
document.querySelectorAll('.so').forEach(opt => {
  opt.onclick = () => {
    document.querySelectorAll('.so').forEach(s => s.classList.remove('sel'));
    opt.classList.add('sel');
    selectedScanType = opt.dataset.type;
  };
});

// ── TERMINAL LOG ──
function addLog(msg, level='info') {
  const body = document.getElementById('termBody');
  const d = document.createElement('div');
  d.className = `ll l-${level}`;
  const ts = new Date().toLocaleTimeString('en-US',{hour12:false});
  d.textContent = `[${ts}] ${msg}`;
  body.appendChild(d);
  body.scrollTop = body.scrollHeight;
}

// ── NOTIFICATION ──
function notify(msg, bad=false) {
  const n = document.getElementById('notif');
  n.textContent = msg;
  n.className = 'notif show' + (bad ? ' bad' : '');
  setTimeout(() => n.classList.remove('show'), 3500);
}

// ── CHECK SERVER ──
async function checkServer() {
  try {
    const r = await fetch(`${API}/sysinfo`, {signal: AbortSignal.timeout(2000)});
    if (!r.ok) throw new Error();
    const info = await r.json();
    serverOnline = true;
    document.getElementById('serverDot').className = 'dot green';
    document.getElementById('serverStatus').style.color = 'var(--accent3)';
    document.getElementById('serverStatus').textContent = 'CONNECTED';
    document.getElementById('osPlatform').textContent = info.os;
    document.getElementById('sysInfo').textContent = `HOST: ${info.hostname} | ${info.machine}`;
    addLog(`Connected to backend. Platform: ${info.os}`, 'ok');
    addLog(`Host: ${info.hostname} | Python ${info.python}`, 'info');
    return true;
  } catch(e) {
    serverOnline = false;
    document.getElementById('serverDot').className = 'dot red';
    document.getElementById('serverStatus').style.color = 'var(--accent2)';
    document.getElementById('serverStatus').textContent = 'OFFLINE';
    document.getElementById('osPlatform').textContent = 'Server not running';
    return false;
  }
}

// ── START SCAN ──
async function startScan(forcedType) {
  const type = forcedType || selectedScanType;

  if (!serverOnline) {
    const ok = await checkServer();
    if (!ok) {
      addLog('ERROR: Backend server not running. Start app.py first!', 'error');
      notify('⚠ Backend offline! Run: python app.py', true);
      return;
    }
  }

  logOffset = 0;
  document.getElementById('threatsGrid').innerHTML = '';
  document.getElementById('noResults').textContent = 'Scan in progress...';
  document.getElementById('bannerOk').style.display = 'none';
  document.getElementById('bannerThreat').style.display = 'none';

  // Reset cmd indicators
  document.querySelectorAll('.ci').forEach(c => {
    c.classList.remove('done','running'); c.classList.add('pending');
  });

  // Show progress
  document.getElementById('btnStart').style.display = 'none';
  document.getElementById('btnStop').style.display = 'block';
  document.getElementById('progWrap').style.display = 'flex';

  const url = `${API}/start?type=${type}` + (customScanPath ? `&path=${encodeURIComponent(customScanPath)}` : '');

  try {
    const r = await fetch(url);
    const data = await r.json();
    addLog(`Scan started: ${data.scan_type.toUpperCase()} mode`, 'info');
    notify(`Scan started: ${data.scan_type.toUpperCase()}`);

    // Start polling
    clearInterval(polling);
    polling = setInterval(pollStatus, 800);
  } catch(e) {
    addLog('Failed to start scan. Is app.py running?', 'error');
    notify('Failed to start scan.', true);
    resetControls();
  }
}

// ── STOP SCAN ──
async function stopScan() {
  try {
    await fetch(`${API}/stop`);
    addLog('Scan stopped by user.', 'warn');
    notify('Scan stopped.');
  } catch(e) {}
  clearInterval(polling);
  resetControls();
}

function resetControls() {
  document.getElementById('btnStart').style.display = 'block';
  document.getElementById('btnStop').style.display = 'none';
  document.getElementById('progWrap').style.display = 'none';
}

// ── POLL STATUS ──
async function pollStatus() {
  try {
    const [statusRes, logsRes, threatsRes, cmdsRes] = await Promise.all([
      fetch(`${API}/status`),
      fetch(`${API}/logs?since=${logOffset}`),
      fetch(`${API}/threats`),
      fetch(`${API}/cmds`),
    ]);

    const status = await statusRes.json();
    const logs = await logsRes.json();
    const threats = await threatsRes.json();
    const cmds = await cmdsRes.json();

    // Update progress
    const pct = Math.floor(status.progress);
    document.getElementById('progBar').style.width = pct + '%';
    document.getElementById('progPct').textContent = pct + '%';

    // Update stats
    document.getElementById('s1').textContent = status.files_scanned.toLocaleString();
    document.getElementById('s2').textContent = status.threat_count;
    document.getElementById('s4').textContent = cmds.length;
    document.getElementById('sFiles').textContent = status.files_scanned.toLocaleString();
    document.getElementById('sThreats').textContent = status.threat_count;

    // Ring
    const secLevel = Math.max(0, 100 - status.threat_count * 15);
    document.getElementById('protPct').textContent = secLevel + '%';
    document.getElementById('protLbl').textContent = secLevel === 100 ? 'SECURE' : secLevel > 50 ? 'AT RISK' : 'DANGER';

    // Append new logs
    logs.forEach(entry => {
      addLog(entry.msg, entry.level);
      logOffset++;

      // Update CMD indicators
      if (entry.level === 'cmd') {
        const cmds = document.querySelectorAll('.ci');
        for (const c of cmds) {
          if (c.classList.contains('pending')) {
            c.classList.remove('pending'); c.classList.add('running');
            setTimeout(() => { c.classList.remove('running'); c.classList.add('done'); cmdsDoneCount++; document.getElementById('s4').textContent = cmdsDoneCount; }, 1500);
            break;
          }
        }
        // Show cmd output tab hint
        const co = document.getElementById('cmdOut');
        co.classList.add('show');
        co.textContent = entry.msg;
      }
    });

    // Render threats
    renderThreats(threats);

    // Scan complete
    if (status.complete) {
      clearInterval(polling);
      resetControls();

      // Mark all cmds done
      document.querySelectorAll('.ci').forEach(c => { c.classList.remove('pending','running'); c.classList.add('done'); });
      cmdsDoneCount = document.querySelectorAll('.ci').length;
      document.getElementById('s4').textContent = cmdsDoneCount;

      if (status.threat_count === 0) {
        document.getElementById('bannerOk').style.display = 'flex';
        document.getElementById('cleanSummary').textContent = `${status.files_scanned.toLocaleString()} files scanned. System appears clean.`;
        notify('✅ Scan complete. System clean!');
      } else {
        document.getElementById('bannerThreat').style.display = 'flex';
        document.getElementById('threatSummary').textContent = `${status.threat_count} real threat(s) in ${status.files_scanned.toLocaleString()} files.`;
        notify(`⚠ ${status.threat_count} REAL threats found!`, true);
      }

      // Auto-switch to results tab
      document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
      document.querySelectorAll('.tc').forEach(c => c.classList.remove('active'));
      document.querySelectorAll('.tab')[3].classList.add('active');
      document.getElementById('tc-results').classList.add('active');
    }

  } catch(e) {
    addLog('Lost connection to backend.', 'error');
  }
}

// ── RENDER THREATS ──
let renderedThreats = new Set();
function renderThreats(threats) {
  const grid = document.getElementById('threatsGrid');
  threats.forEach((t, i) => {
    if (renderedThreats.has(i)) return;
    renderedThreats.add(i);

    const sevClass = t.severity === 'HIGH' ? 's-hi' : t.severity === 'MEDIUM' ? 's-me' : 's-lo';
    const div = document.createElement('div');
    div.className = 'tcard';
    div.innerHTML = `
      <div class="tc-hdr">
        <span class="tc-name">${t.name}</span>
        <span class="sev ${sevClass}">${t.severity}</span>
      </div>
      <div class="tc-path">${t.path}</div>
      <div style="font-family:'Share Tech Mono',monospace;font-size:9px;color:var(--dim);margin-bottom:7px;">Detected: ${t.time}</div>
      <div class="tc-btns">
        <button class="btn-q" onclick="quarantine(this,'${t.name}')">🔒 QUARANTINE</button>
        <button class="btn-r" onclick="removeThreat(this,'${t.name}')">🗑 DELETE</button>
      </div>`;
    grid.appendChild(div);

    document.getElementById('noResults').style.display = 'none';
  });
}

function quarantine(btn, name) {
  const card = btn.closest('.tcard');
  card.style.opacity = '.4';
  btn.disabled = true;
  quarantineCount++;
  document.getElementById('s3').textContent = quarantineCount;
  addLog(`QUARANTINED: ${name}`, 'warn');
  notify(`🔒 ${name} quarantined.`);
}

function removeThreat(btn, name) {
  const card = btn.closest('.tcard');
  card.style.transition = 'all .3s'; card.style.opacity = '0'; card.style.transform = 'translateX(20px)';
  setTimeout(() => card.remove(), 300);
  addLog(`DELETED: ${name}`, 'ok');
  notify(`🗑 ${name} deleted.`);
}

function setCustomPath() {
  const p = document.getElementById('customPath').value.trim();
  if (p) {
    customScanPath = p;
    addLog(`Custom scan path set: ${p}`, 'info');
    notify(`Path set: ${p}`);
    document.querySelectorAll('.so').forEach(s => s.classList.remove('sel'));
    document.querySelector('[data-type="custom"]').classList.add('sel');
    selectedScanType = 'custom';
  }
}

// ── INIT ──
checkServer().then(ok => {
  if (ok) {
    addLog('Backend ready. All real system checks available.', 'ok');
    addLog('Click START SCAN to begin real analysis.', 'info');
  } else {
    addLog('IMPORTANT: Backend server is not running!', 'error');
    addLog('To enable real scanning: open a terminal and run:', 'warn');
    addLog('  cd OmniAnti && python app.py', 'warn');
    addLog('Then refresh this page.', 'warn');
    notify('⚠ Start app.py to enable real scanning!', true);
  }
});

// Retry connection every 5s if offline
setInterval(async () => {
  if (!serverOnline) await checkServer();
}, 5000);
</script>
</body>
</html>
